2 " Specify a directory for plugins
3 call plug#begin('~/.config/nvim/plugins/plugged')
5 Plug 'neoclide/coc.nvim', {'branch': 'release'}
6 Plug 'scrooloose/nerdtree'
7 "Plug 'tsony-tsonev/nerdtree-git-plugin'
8 Plug 'Xuyuanp/nerdtree-git-plugin'
9 Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
10 Plug 'ryanoasis/vim-devicons'
11 Plug 'airblade/vim-gitgutter'
12 Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
13 Plug 'scrooloose/nerdcommenter'
14 "This is a linter for python
15 Plug 'metakirby5/codi.vim'
16 Plug 'christoomey/vim-tmux-navigator'
17 Plug 'morhetz/gruvbox'
18 Plug 'dracula/vim',{'as':'dracula'}
19 Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
21 " Initialize plugin system
26 "jk in insert mode takes you back to normal mode
28 "Ctrl-n activates nerd toggle
29 nmap <C-n> :NERDTreeToggle<CR>
32 "++ in vmap or nmap coments
33 vmap ++ <plug>NERDCommenterToggle
34 nmap ++ <plug>NERDCommenterToggle
38 "espera dos segundos para el completado de comandos
39 set timeout timeoutlen=2000
41 set tabstop=4 softtabstop=4
59 "executing any .vimrc that is in the current directory for project specific
60 "configurations that i might need:
62 "No highligt search plus incremental search:
65 "keep buffers arround while open:
69 "Extra space on the bottom
75 " j/k will move virtual lines (lines that wrap)
76 noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
77 noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
78 "Better look for messages
80 "300ms without activity to write to disk the swapfile
82 " don't give |ins-completion-menu| messages.
88 highlight CodiVirtualText guifg=cyan
89 "The indicator for codi
90 let g:codi#virtual_text_prefix = "❯ "
91 let g:codi#aliases = {
92 \ 'javascript.jsx': 'javascript',
97 let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
101 "let g:prettier#quickfix_enabled = 0
102 "let g:prettier#quickfix_auto_focus = 0
103 " prettier command for coc
104 command! -nargs=0 Prettier :CocCommand prettier.formatFile
105 " run prettier on save
106 "let g:prettier#autoformat = 0
107 "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
111 let g:NERDTreeGitStatusWithFlags = 1
112 let g:WebDevIconsUnicodeDecorateFolderNodes = 1
113 let g:NERDTreeGitStatusNodeColorization = 1
114 let g:NERDTreeColorMapCustom = {
115 \ "Staged" : "#0ee375",
116 \ "Modified" : "#d9bf91",
117 \ "Renamed" : "#51C9FC",
118 \ "Untracked" : "#FCE77C",
119 \ "Unmerged" : "#FC51E6",
120 \ "Dirty" : "#FFBD61",
121 \ "Clean" : "#87939A",
122 \ "Ignored" : "#808080"
124 let g:NERDTreeIgnore = ['^node_modules$']
125 " sync open file with NERDTree
126 " " Check if NERDTree is open or active
127 function! IsNERDTreeOpen()
128 return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
130 " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
131 " file, and we're not in vimdiff
133 if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
138 " Highlight currently open buffer in NERDTree
139 autocmd BufEnter * call SyncTree()
143 let g:coc_global_extensions = [
153 \ 'coc-markdownlint',
157 " Use tab for trigger completion with characters ahead and navigate.
158 " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
159 inoremap <silent><expr> <TAB>
160 \ pumvisible() ? "\<C-n>" :
161 \ <SID>check_back_space() ? "\<TAB>" :
163 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
165 function! s:check_back_space() abort
166 let col = col('.') - 1
167 return !col || getline('.')[col - 1] =~# '\s'
170 " Use <c-space> to trigger completion.
171 inoremap <silent><expr> <c-space> coc#refresh()
173 " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
174 " Coc only does snippet and additional edit on confirm.
175 inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
176 " Or use `complete_info` if your vim support it, like:
177 " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
179 " Use `[g` and `]g` to navigate diagnostics
180 nmap <silent> [g <Plug>(coc-diagnostic-prev)
181 nmap <silent> ]g <Plug>(coc-diagnostic-next)
183 " Remap keys for gotos
184 nmap <silent> gd <Plug>(coc-definition)
185 nmap <silent> gy <Plug>(coc-type-definition)
186 nmap <silent> gi <Plug>(coc-implementation)
187 nmap <silent> gr <Plug>(coc-references)
189 " Use K to show documentation in preview window
190 nnoremap <silent> K :call <SID>show_documentation()<CR>
192 function! s:show_documentation()
193 if (index(['vim','help'], &filetype) >= 0)
194 execute 'h '.expand('<cword>')
196 call CocAction('doHover')
200 " Highlight symbol under cursor on CursorHold
201 autocmd CursorHold * silent call CocActionAsync('highlight')
203 " Remap for rename current word
204 nmap <F2> <Plug>(coc-rename)
206 " Remap for format selected region
207 xmap <leader>f <Plug>(coc-format-selected)
208 nmap <leader>f <Plug>(coc-format-selected)
212 " Setup formatexpr specified filetype(s).
213 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
214 " Update signature help on jump placeholder
215 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
218 " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
219 xmap <leader>a <Plug>(coc-codeaction-selected)
220 nmap <leader>a <Plug>(coc-codeaction-selected)
222 " Remap for do codeAction of current line
223 nmap <leader>ac <Plug>(coc-codeaction)
224 " Fix autofix problem of current line
225 nmap <leader>qf <Plug>(coc-fix-current)
227 " Create mappings for function text object, requires document symbols feature of languageserver.
228 xmap if <Plug>(coc-funcobj-i)
229 xmap af <Plug>(coc-funcobj-a)
230 omap if <Plug>(coc-funcobj-i)
231 omap af <Plug>(coc-funcobj-a)
233 " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
234 nmap <silent> <C-d> <Plug>(coc-range-select)
235 xmap <silent> <C-d> <Plug>(coc-range-select)
237 " Use `:Format` to format current buffer
238 command! -nargs=0 Format :call CocAction('format')
240 " Use `:Fold` to fold current buffer
241 command! -nargs=? Fold :call CocAction('fold', <f-args>)
243 " use `:OR` for organize import of current buffer
244 command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
246 " Add status line support, for integration with other plugin, checkout `:h coc-status`
247 set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
250 " Show all diagnostics
251 nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
253 nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
255 nnoremap <silent> <space>c :<C-u>CocList commands<cr>
256 " Find symbol of current document
257 nnoremap <silent> <space>o :<C-u>CocList outline<cr>
258 " Search workspace symbols
259 nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
260 " Do default action for next item.
261 nnoremap <silent> <space>j :<C-u>CocNext<CR>
262 " Do default action for previous item.
263 nnoremap <silent> <space>k :<C-u>CocPrev<CR>
264 " Resume latest coc list
265 nnoremap <silent> <space>p :<C-u>CocListResume<CR>