call plug#begin('~/.local/share/nvim/plugged') Plug 'tpope/vim-sensible' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-surround' Plug 'tpope/vim-eunuch' Plug 'jiangmiao/auto-pairs' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'sheerun/vim-polyglot' Plug 'tpope/vim-repeat' Plug 'mileszs/ack.vim' " File Finder " PlugInstall and PlugUpdate will clone fzf in ~/.fzf and run the install script Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'junegunn/fzf.vim' Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } " Future plugins " https://github.com/michaelb/sniprun " Git Plug 'airblade/vim-gitgutter' Plug 'terryma/vim-multiple-cursors' Plug 'ggandor/leap.nvim' Plug 'scrooloose/nerdcommenter' Plug 'mattn/emmet-vim', { 'for': 'html' } Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'honza/vim-snippets' Plug 'nathanaelkane/vim-indent-guides' Plug 'chiel92/vim-autoformat' Plug 'christoomey/vim-tmux-navigator' " Both of these are for vim-markdown Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } " Style Plug 'junegunn/seoul256.vim' Plug 'arcticicestudio/nord-vim' Plug 'folke/tokyonight.nvim', { 'branch': 'main' } Plug 'shaunsingh/oxocarbon.nvim' Plug 'olimorris/onedarkpro.nvim' Plug 'marko-cerovac/material.nvim' " Plug 'rebelot/kanagawa.nvim' Plug 'junegunn/limelight.vim' Plug 'junegunn/goyo.vim' " Go Plug 'fatih/vim-go', { 'tag': 'v1.28', 'do': ':GoUpdateBinaries', 'for': 'go' } " Python Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins','for': 'python' } " for Python semantic highlight " Rust Plug 'rust-lang/rust.vim' " Terraform Plug 'hashivim/vim-terraform' " Cue Plug 'jjo/vim-cue' " Earthly Plug 'earthly/earthly.vim', { 'branch': 'main' } " SQL " Plug 'vim-scripts/SQLComplete.vim', { 'for': 'sql' } " Plug 'vim-scripts/dbext.vim', { 'for': 'sql' } " Maybe consider switching for formatter " https://vimawesome.com/plugin/sqlutilities " Code Exploration Plug 'vim-scripts/taglist.vim' "" FUTURE PLUGINS " https://vimawesome.com/plugin/ultisnips " https://github.com/tpope/vim-unimpaired " https://github.com/svermeulen/vim-easyclip " " Testing Copilot Plug 'github/copilot.vim' " Testing WakaTime Plug 'wakatime/vim-wakatime' " CoC Plugins Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-prettier', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-yank', {'do': 'yarn install --frozen-lockfile'} Plug 'yaegassy/coc-tailwindcss3', {'do': 'yarn install --frozen-lockfile'} Plug 'yaegassy/coc-marksman', {'do': 'yarn install --frozen-lockfile'} Plug 'yaegassy/coc-ruff', {'do': 'yarn install --frozen-lockfile'} " Plug 'yaegassy/coc-sqlfluff', {'do': 'yarn install --frozen-lockfile'} " Plug 'yaegassy/coc-pydocstring', {'do': 'yarn install --frozen-lockfile'} " Plug 'yaegassy/coc-vitest', {'do': 'yarn install --frozen-lockfile'} " Plug 'coc-extensions/coc-svelte', {'do': 'yarn install --frozen-lockfile'} Plug 'qiuxiang/coc-solidity', {'do': 'yarn install --frozen-lockfile'} Plug 'fannheyward/coc-pyright', {'do': 'yarn install --frozen-lockfile'} Plug 'fannheyward/coc-deno', {'do': 'yarn install --frozen-lockfile'} " https://github.com/fannheyward/coc-react-refactor " " Trying out TreeSitter for syntax highlighting Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " MUST BE LAST Plug 'ryanoasis/vim-devicons' "" Initialize plugin system call plug#end() " Remap leader key let mapleader = "\" " jj and jk to escape inoremap jj inoremap jk " Ctrl+C to yank to clipboard vnoremap "*y " Always use spaces set tabstop=2 shiftwidth=2 expandtab " Spellcheck set spell spelllang=en_us " Correct Next Mispelling nnoremap f 1z= " Toggle Spellcheck nnoremap s :set spell! " Nerd Tree set splitright let NERDTreeShowHidden=1 "" Tree Explorer map nt :NERDTreeToggle " Show indents guides (Toggle with ig) let g:indent_guides_enable_on_vim_startup = 1 " Nerdcommenter " Add spaces after comment delimiters by default let g:NERDSpaceDelims = 1 " Use compact syntax for prettified multi-line comments let g:NERDCompactSexyComs = 1 " Allow commenting and inverting empty lines (useful when commenting a region) let g:NERDCommentEmptyLines = 1 " Enable trimming of trailing whitespace when uncommenting let g:NERDTrimTrailingWhitespace = 1 " Ctrl P Ignore Node Modules let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn))$' " Terraform " https://github.com/hashivim/vim-terraform let g:terraform_align=1 let g:terraform_fmt_on_save=1 " Markdown " Disable auto folding let g:vim_markdown_folding_disabled = 1 " Python for NVIM let g:python3_host_prog = "$HOME/.pyenv/shims/python3" " Go " https://github.com/fatih/vim-go-tutorial#vimrc-improvements " https://github.com/golang/tools/blob/master/gopls/doc/vim.md#vim-go let g:go_def_mode='gopls' let g:go_info_mode='gopls' let g:go_fmt_command = "goimports" autocmd FileType go let b:go_fmt_options = { \ 'goimports': '-local ' . \ trim(system('{cd '. shellescape(expand('%:h')) .' && go list -m;}')), \ } " Use Coc for gd let g:go_def_mapping_enabled = 0 " Save files on :make. This enables auto save on :GoBuild set autowrite map :cnext map :cprevious nnoremap a :cclose autocmd FileType go nmap i (go-install) autocmd FileType go nmap r (go-run) autocmd FileType go nmap t (go-test) autocmd FileType go nmap tf (go-test-func) autocmd FileType go nmap v (go-vet) autocmd FileType go nmap err (go-iferr) autocmd FileType go nmap cv (go-coverage) autocmd FileType go nmap ct (go-coverage-toggle) " Shortcuts for GoAlternate splits autocmd Filetype go command! -bang A call go#alternate#Switch(0, 'edit') autocmd Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') autocmd Filetype go command! -bang AS call go#alternate#Switch(0, 'split') autocmd Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') " " run :GoBuild or :GoTestCompile based on the go file function! s:build_go_files() let l:file = expand('%') if l:file =~# '^\f\+_test\.go$' call go#test#Test(0, 1) elseif l:file =~# '^\f\+\.go$' call go#cmd#Build(0) endif endfunction autocmd FileType go nmap b :call build_go_files() let g:go_auto_type_info = 1 let g:go_def_mode='gopls' let g:go_info_mode='gopls' let g:go_highlight_types = 1 " let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_build_constraints = 1 " let g:go_auto_sameids = 1 " Goyo +_LimeLight autocmd! User GoyoEnter Limelight autocmd! User GoyoLeave Limelight! " Neovim Terminal Mode " https://neovim.io/doc/user/nvim_terminal_emulator.html :tnoremap :tnoremap '"'.nr2char(getchar()).'pi' :tnoremap h :tnoremap j :tnoremap k :tnoremap l :inoremap h :inoremap j :inoremap k :inoremap l :nnoremap h :nnoremap j :nnoremap k :nnoremap l " https://vim.fandom.com/wiki/Search_for_visually_selected_text " Maps // to search for visually selected text " Search for selected text, forwards or backwards. vnoremap * : \let old_reg=getreg('"')let old_regtype=getregtype('"') \gvy/=&ic?'\c':'\C'=substitute( \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g') \gVzv:call setreg('"', old_reg, old_regtype) vnoremap # : \let old_reg=getreg('"')let old_regtype=getregtype('"') \gvy?=&ic?'\c':'\C'=substitute( \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g') \gVzv:call setreg('"', old_reg, old_regtype) " Rust Config let g:rustfmt_autosave = 1 " -------- " BEGIN -- CoC Config " -------- " https://github.com/neoclide/coc.nvim/wiki/F.A.Q#some-highlight-groups-not-work-after-colorscheme-command autocmd ColorScheme * call Highlight() function! Highlight() abort hi Conceal ctermfg=239 guifg=#504945 hi CocSearch ctermfg=12 guifg=#18A3FF endfunction " Some servers have issues with backup files, see #649. set nobackup set nowritebackup " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable " delays and poor user experience. set updatetime=300 " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " NOTE: There's always complete item selected by default, you may want to enable " no select by `"suggest.noselect": true` in your configuration file. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. " inoremap " \ coc#pum#visible() ? coc#pum#next(1) : " \ CheckBackspace() ? "\" : " \ coc#refresh() " https://github.com/neoclide/coc.nvim/wiki/F.A.Q#tab-not-working-well-with-copilotvim let g:copilot_no_tab_map = v:true inoremap \ coc#pum#visible() ? coc#pum#next(1): \ exists('b:_copilot.suggestions') ? copilot#Accept("\") : \ CheckBackSpace() ? "\" : \ coc#refresh() " inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" inoremap \ coc#pum#visible() ? coc#pum#prev(1): \ exists('b:_copilot.suggestions') ? copilot#Accept("\") : \ CheckBackSpace() ? "\" : \ coc#refresh() " Make to accept selected completion item or notify coc.nvim to format " u breaks current undo, please make your own choice. inoremap coc#pum#visible() ? coc#pum#confirm() \: "\u\\=coc#on_enter()\" function! CheckBackspace() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() endif " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call ShowDocumentation() function! ShowDocumentation() if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') else call feedkeys('K', 'in') endif endfunction " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) " Formatting selected code. xmap f (coc-format-selected) nmap f (coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Applying codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Run the Code Lens action on the current line. nmap cl (coc-codelens-action) " Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap af (coc-funcobj-a) xmap ic (coc-classobj-i) omap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ac (coc-classobj-a) " Remap and for scroll float windows/popups. if has('nvim-0.4.0') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif " Use CTRL-S for selections ranges. " Requires 'textDocument/selectionRange' support of language server. nmap (coc-range-select) xmap (coc-range-select) " Add `:Format` command to format current buffer. command! -nargs=0 Format :call CocActionAsync('format') " Add `:Fold` command to fold current buffer. command! -nargs=? Fold :call CocAction('fold', ) " Add `:OR` command for organize imports of the current buffer. command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') " Add (Neo)Vim's native statusline support. " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Mappings for CoCList " Show all diagnostics. nnoremap a :CocList diagnostics " Manage extensions. nnoremap e :CocList extensions " Show commands. nnoremap c :CocList commands " Find symbol of current document. nnoremap o :CocList outline " Search workspace symbols. nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list. nnoremap p :CocListResume command! -nargs=0 Prettier :CocCommand prettier.formatFile vmap f (coc-format-selected) nmap f (coc-format-selected) " -------- " END -- CoC Config " -------- " Svelte Config let g:vim_svelte_plugin_load_full_syntax = 1 let g:vim_svelte_plugin_use_typescript = 1 " Color Scheme " After CoC config syntax on " colorscheme onedark colorscheme material let g:airline_theme='onedark' " let g:material_style='deep ocean' let g:material_style = 'palenight' " colorscheme nord " colorscheme seoul256 " autocmd vimenter * ++nested colorscheme tokyonight " autocmd vimenter * ++nested colorscheme oxocarbon let g:seoul256_background = 235 set background=dark set termguicolors set number " Fonts set conceallevel=3 set encoding=UTF-8 set guifont=SpaceMono\ Font:h11 let g:airline_powerline_fonts = 1 if exists("g:loaded_webdevicons") call webdevicons#refresh() endif " https://www.reddit.com/r/neovim/comments/ypvrwp/comment/ivmehp0/?utm_source=share&utm_medium=web2x&context=3 autocmd TextYankPost * silent! lua vim.highlight.on_yank { higroup='IncSearch', timeout=400 } " FZF Customization " Set ctrl-p to search git files nnoremap :GFiles noremap ff :Files nnoremap fg :GFiles nnoremap fb :Buffers " Enable Leap " https://github.com/ggandor/leap.nvim#faq lua require('leap').add_default_mappings() " TODO: Re-map d to x " Current Copilot doesn't support >= Node 18 " " vimscript let g:copilot_node_command = "~/.nvm/versions/node/v16.15.0/bin/node"