call plug#begin('~/.vim/plugged') Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Amazing combination of features. Plug 'jmcantrell/vim-virtualenv' " Plug 'mg979/vim-visual-multi' Plug 'airblade/vim-rooter' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'majutsushi/tagbar' " install exuberant-ctags Plug 'tpope/vim-commentary' Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' " Plug 'SirVer/ultisnips' " Plug 'neomake/neomake' " Plug 'godlygeek/tabular' " Plug 'lepture/vim-jinja' " Plug 'b4b4r07/vim-hcl' " Plug 'hashivim/vim-packer' " Plug 'hashivim/vim-terraform' " Plug 'scrooloose/nerdtree' Plug 'preservim/nerdtree' Plug 'ryanoasis/vim-devicons' Plug 'towolf/vim-helm' " Plug 'PotatoesMaster/i3-vim-syntax' "Plug 'tpope/vim-surround' "Plugin 'jiangmiao/auto-pairs' " Plug 'tsandall/vim-rego' " Plug 'honza/vim-snippets' Plug 'psliwka/vim-smoothie' Plug 'Yggdroot/indentLine' if !has('nvim') " Plugins for when you're not using neovim endif if has('nvim') Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.8' } " Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc.nvim', {'branch': 'release'} "Plug 'jodosha/vim-godebug' " Debugger integration via delve Plug 'github/copilot.vim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'folke/todo-comments.nvim' Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.11.0'} Plug 'neovim/nvim-lspconfig' " Plug 'mfussenegger/nvim-dap-python' " Plug 'linux-cultist/venv-selector.nvim', {'branch': 'regexp'} endif " All of your Plugs must be added before the following line call plug#end() """"""""""""""""" " Plugin Config " """"""""""""""""" let mapleader = " " """ coc if has('nvim') " --------------------------------------------------------------------------- " coc.nvim default settings " --------------------------------------------------------------------------- let g:coc_global_extensions = [ \'coc-json', \'coc-go', \'@yaegassy/coc-pylsp', \'coc-pydocstring', \'coc-yaml', \'coc-snippets', \'coc-lua', \'coc-solargraph', \'coc-toml', \'coc-docker', \'coc-clangd', \'coc-tsserver', \'coc-html' \] " Some servers have issues with backup files, see #649 " set nobackup " set nowritebackup " Having longer updatetime (default is 4000 ms = 4s) 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 " 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 `[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 code actions to the selected code block " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying code actions at the cursor position nmap ac (coc-codeaction-cursor) " Remap keys for apply code actions affect whole buffer nmap as (coc-codeaction-source) " Apply the most preferred quickfix action to fix diagnostic on the current line nmap qf (coc-fix-current) " Remap keys for applying refactor code actions nmap re (coc-codeaction-refactor) xmap r (coc-codeaction-refactor-selected) nmap r (coc-codeaction-refactor-selected) " 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 to 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 " Code Gen nmap ga (coc-codeaction-line) xmap ga (coc-codeaction-selected) nmap gA (coc-codeaction) " 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 " 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 """" Snippets " Use for trigger snippet expand. imap (coc-snippets-expand) " Use for select text for visual placeholder of snippet. vmap (coc-snippets-select) " Use for jump to next placeholder, it's default of coc.nvim let g:coc_snippet_next = '' " Use for jump to previous placeholder, it's default of coc.nvim let g:coc_snippet_prev = '' " Use for both expand and jump (make expand higher priority.) imap (coc-snippets-expand-jump) " Use x for convert visual selected code to snippet xmap x (coc-convert-snippet) " inoremap " \ pumvisible() ? coc#_select_confirm() : " \ coc#expandableOrJumpable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : " \ check_back_space() ? "\" : " \ coc#refresh() " function! s:check_back_space() abort " let col = col('.') - 1 " return !col || getline('.')[col - 1] =~# '\s' " endfunction " let g:coc_snippet_next = '' endif """ tagbar nmap b :TagbarToggle " let g:tagbar_type_go = { " \ 'ctagstype' : 'go', " \ 'kinds' : [ " \ 'p:package', " \ 'i:imports:1', " \ 'c:constants', " \ 'v:variables', " \ 't:types', " \ 'n:interfaces', " \ 'w:fields', " \ 'e:embedded', " \ 'm:methods', " \ 'r:constructor', " \ 'f:functions' " \ ], " \ 'sro' : '.', " \ 'kind2scope' : { " \ 't' : 'ctype', " \ 'n' : 'ntype' " \ }, " \ 'scope2kind' : { " \ 'ctype' : 't', " \ 'ntype' : 'n' " \ }, " \ 'ctagsbin' : 'gotags', " \ 'ctagsargs' : '-sort -silent' " \ } """ vim-rooter " let g:rooter_use_lcd = 1 let g:rooter_cd_cmd="lcd" let g:rooter_silent_chdir = 1 let g:rooter_resolve_links = 1 """ vim-terraform " let g:terraform_fmt_on_save=1 "autocmd filetype tf set syntax=terraform " autocmd FileType terraform setlocal commentstring=#%s """ vim-jinja " autocmd BufNewFile,BufRead *.j2 set filetype=jinja """ vim-go " " disable all linters as that is taken care of by coc.nvim " let g:go_diagnostics_enabled = 0 " let g:go_metalinter_enabled = [] " " don't jump to errors after metalinter is invoked " let g:go_jump_to_error = 0 " " run go imports on file save " let g:go_fmt_command = "gofmt" " " automatically highlight variable your cursor is on " let g:go_auto_sameids = 0 " let g:go_highlight_types = 1 " 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_operators = 1 " let g:go_highlight_extra_types = 1 " let g:go_highlight_build_constraints = 1 " let g:go_highlight_generate_tags = 1 " " let g:go_def_mode='gopls' " " let g:go_info_mode='gopls' " let g:go_term_enabled = 1 " " disable vim-go :GoDef short cut (gd) " " this is handled by LanguageClient [LC] " let g:go_def_mapping_enabled = 0 """ neomake " Full config: when writing or reading a buffer, and on changes in insert and " normal mode (after 1s; no delay when writing). " call neomake#configure#automake('nrwi', 500) """ NERDtree nnoremap n :NERDTreeFocus nnoremap f :NERDTreeToggle nnoremap o :NERDTreeFind " Open NERDTree on the right side of the window. let g:NERDTreeWinPos = "right" " Start NERDTree when Vim starts with a directory argument. autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif " Start NERDTree when Vim is started without file arguments. autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " Close the tab if NERDTree is the only window remaining in it. autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif """ airline let g:airline_theme='powerlineish' " is a valid theme name let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#formatter = 'unique_tail_improved' let g:airline#extensions#virtualenv#enabled = 1 let g:airline#extensions#virtualenv#ft = ['python', 'markdown', 'dosini', 'text', 'make'] " customize the statusline. " let g:airline_section_w=%{virtualenv#statusline()} " let g:airline_section_w = %{coc#status()}%{get(b:,'coc_current_function','')} """ Telescope " Find files using Telescope command-line sugar. nnoremap ff Telescope find_files nnoremap fg Telescope live_grep nnoremap fb Telescope buffers nnoremap fh Telescope help_tags """ TreeSitter luafile ~/.vim/vimrc.d/treesitter.lua """ todo-comments luafile ~/.vim/vimrc.d/todo-comments.lua """ toggleterm lua require("toggleterm").setup() nnoremap t :ToggleTerm """ venv-selector " luafile ~/.vim/vimrc.d/venv-selector.lua " nnoremap vs :VenvSelect """ vim-smoothie """"""""""""""""""""" " Personal Settings " """"""""""""""""""""" set number colorscheme Czar hi Normal guibg=NONE ctermbg=NONE command! W w !sudo tee >/dev/null % set backupdir=~/.vim/tmp/backup// set directory=~/.vim/tmp/swap// set undodir=~/.vim/tmp/undo// set completeopt-=preview "set list lcs=tab:\┆\ ,trail:▓,space:. "set list lcs=tab:\⇥\ ,trail:▓,space:. set list lcs=tab:\⇥\ ,trail:▓ set colorcolumn=80 autocmd Filetype java setlocal colorcolumn=100 autocmd Filetype html setlocal colorcolumn=100 autocmd Filetype go setlocal colorcolumn=100 autocmd Filetype netrw setlocal colorcolumn= autocmd Filetype netrw setlocal signcolumn=0 set tabstop=2 set shiftwidth=2 set noexpandtab autocmd FileType python setlocal expandtab autocmd FileType python setlocal tabstop=4 autocmd FileType python setlocal shiftwidth=4 " autocmd filetype json setlocal expandtab autocmd filetype tf setlocal expandtab autocmd filetype terraform setlocal expandtab autocmd FileType terraform setlocal tabstop=4 autocmd FileType terraform setlocal shiftwidth=4 autocmd FileType helm setlocal expandtab let g:indentLine_concealcursor = 'nc' """ Help Navigation " autocmd FileType help nnoremap " autocmd FileType help nnoremap " autocmd FileType help nnoremap o /'\l\{2,\}' " autocmd FileType help nnoremap O ?'\l\{2,\}' " autocmd FileType help nnoremap s /\|\zs\S\+\ze\| " autocmd FileType help nnoremap S ?\|\zs\S\+\ze\|