Skip to content

Instantly share code, notes, and snippets.

@daviek19
Last active February 13, 2025 15:20
Show Gist options
  • Save daviek19/604556a77f552ef2311c2a3ede2c2c36 to your computer and use it in GitHub Desktop.
Save daviek19/604556a77f552ef2311c2a3ede2c2c36 to your computer and use it in GitHub Desktop.
my-nvim-config
" Basic settings
set number
set autoindent
set tabstop=4
set shiftwidth=4
set smarttab
set softtabstop=4
set mouse=a
set encoding=UTF-8
set completeopt-=preview " For No Previews
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set shortmess+=c
set signcolumn=yes
" Plugin setup
call plug#begin('~/AppData/Local/nvim/site/plugged')
Plug 'fatih/vim-go'
Plug 'neoclide/coc.nvim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree'
Plug 'tpope/vim-commentary'
Plug 'ap/vim-css-color'
Plug 'rafi/awesome-vim-colorschemes'
Plug 'ryanoasis/vim-devicons'
Plug 'tc50cal/vim-terminal'
Plug 'terryma/vim-multiple-cursors'
Plug 'honza/vim-snippets'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-unimpaired'
Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
Plug 'williamboman/nvim-lsp-installer'
Plug 'neovim/nvim-lspconfig'
call plug#end()
" airline symbols
let g:airline_powerline_fonts = 1
let g:airline_theme='light'
" NERDTree mappings
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
" Code navigation mappings
nmap <C-d> <Plug>(coc-definition)
nmap <C-i> <Plug>(coc-implementation)
nmap <C-q> <Plug>(coc-type-definition)
nmap <C-r> <Plug>(coc-references)
" Code formatting
nnoremap <C-f> :call CocActionAsync('format')<CR>
" View documentation
"nmap <silent> kk :call <SID>show_documentation()<CR>
nnoremap <C-k> :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Code actions
nmap <silent> ca <Plug>(coc-codeaction)
nmap <silent> cf <Plug>(coc-fix-current)
nmap <silent> rn <Plug>(coc-rename)
" Autocomplete configuration
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? "\<Tab>" : coc#refresh()
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"
inoremap <silent><expr> <C-Space> coc#refresh()
" Error navigation
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Autoformat settings
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,javascript,arduino AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,sass,scss,less,json AutoFormatBuffer js-beautify
autocmd FileType java AutoFormatBuffer google-java-format
autocmd FileType python AutoFormatBuffer yapf
" Alternative: autocmd FileType python AutoFormatBuffer autopep8
autocmd FileType rust AutoFormatBuffer rustfmt
autocmd FileType vue AutoFormatBuffer prettier
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment