Skip to content

Instantly share code, notes, and snippets.

@RGGH
Created May 15, 2024 11:04
Show Gist options
  • Save RGGH/3ba6b194bef3b75186ac3cfb45890ee9 to your computer and use it in GitHub Desktop.
Save RGGH/3ba6b194bef3b75186ac3cfb45890ee9 to your computer and use it in GitHub Desktop.
call plug#begin(stdpath("data") . '/plugged')
Plug 'catppuccin/nvim', { 'as': 'catppuccin' }
Plug 'styled-components/vim-styled-components'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'folke/trouble.nvim'
Plug 'mengelbrecht/lightline-bufferline'
Plug 'preservim/nerdcommenter'
"Plug 'jiangmiao/auto-pairs'
Plug 'simrat39/rust-tools.nvim'
Plug 'luochen1990/rainbow'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/completion-treesitter'
Plug 'preservim/nerdtree'
Plug 'matze/vim-move'
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.2' }
Plug 'ryanoasis/vim-devicons'
Plug 'vim-airline/vim-airline'
call plug#end()
" Theme
set termguicolors
colorscheme catppuccin
let g:airline_theme = 'catppuccin'
syntax enable
let g:rainbow_active = 1
let g:airline_powerline_fonts = 1
let g:one_allow_italics = 1
" Remember folds
set foldcolumn=1
set sessionoptions+=folds
set relativenumber
noremap <S-\> <S-^>
vnoremap kj <esc>
" Trouble - squares
nnoremap <leader>xx <cmd>TroubleToggle<cr>
let g:trouble_signs_icon = {'Error': '', 'Warning': '', 'Information': '', 'Hint': ''}
" nav buffers
nnoremap <PageUp> :bprevious<CR>
nnoremap <PageDown> :bnext<CR>
" display open buffers
set statusline+=%n\ %f\ %h%m%r%y%=%w\ %l/%L\ %p%%\ %c
" noh
nnoremap <Leader>n :noh<CR>
" file explorer
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" esc in command mode
cnoremap kj <C-C>
inoremap kj <C-C>
" Map Ctrl + S to save
nnoremap <C-s> :w<CR>
inoremap <C-s> <Esc>:w<CR>
" Map F3 to run :!cargo r
nnoremap <C-b> :vsp \| :term cargo run --quiet<CR>
" Map F2 to open the file explorer
nnoremap <F2> :Ve<CR>
" Remap 'cargo fmt' in a terminal window
nnoremap <leader>cf :!cargo fmt<CR><CR>
" Map <S-`> to insert text at the top of the file
nnoremap <C-a> <Esc>ggO#![allow(unused)]<Esc>
" Remap Shift+Tab in insert mode to insert println!("{:?}", x); and position the cursor after x
inoremap <S-Tab> println!("{:?}", x);<Left>
nnoremap <S-Tab> println!("{:?}", x);<Left>
" Search and replacer
nnoremap <Leader>r :%s///g<Left><Left>
" toggle inlayHints
nnoremap <Leader>ti :CocCommand document.toggleInlayHint<CR>
" nav between splits using ctrl
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
filetype plugin on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment