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 'scrooloose/nerdcommenter'
13 "This is a linter for python
14 Plug 'metakirby5/codi.vim'
15 Plug 'christoomey/vim-tmux-navigator'
16 Plug 'morhetz/gruvbox'
17 Plug 'dracula/vim',{'as':'dracula'}
18 Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
19 " Initialize plugin system
24 "remap the leader to space
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',
99 "let g:prettier#quickfix_enabled = 0
100 "let g:prettier#quickfix_auto_focus = 0
101 " prettier command for coc
102 command! -nargs=0 Prettier :CocCommand prettier.formatFile
103 " run prettier on save
104 "let g:prettier#autoformat = 0
105 "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
109 let g:NERDTreeGitStatusWithFlags = 1
110 let g:WebDevIconsUnicodeDecorateFolderNodes = 1
111 let g:NERDTreeGitStatusNodeColorization = 1
112 let g:NERDTreeColorMapCustom = {
113 \ "Staged" : "#0ee375",
114 \ "Modified" : "#d9bf91",
115 \ "Renamed" : "#51C9FC",
116 \ "Untracked" : "#FCE77C",
117 \ "Unmerged" : "#FC51E6",
118 \ "Dirty" : "#FFBD61",
119 \ "Clean" : "#87939A",
120 \ "Ignored" : "#808080"
122 let g:NERDTreeIgnore = ['^node_modules$']
123 " sync open file with NERDTree
124 " " Check if NERDTree is open or active
125 function! IsNERDTreeOpen()
126 return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
128 " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
129 " file, and we're not in vimdiff
131 if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
136 " Highlight currently open buffer in NERDTree
137 autocmd BufEnter * call SyncTree()
141 let g:coc_global_extensions = [
151 \ 'coc-markdownlint',
155 " Use tab for trigger completion with characters ahead and navigate.
156 " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
157 inoremap <silent><expr> <TAB>
158 \ pumvisible() ? "\<C-n>" :
159 \ <SID>check_back_space() ? "\<TAB>" :
161 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
163 function! s:check_back_space() abort
164 let col = col('.') - 1
165 return !col || getline('.')[col - 1] =~# '\s'
168 " Use <c-space> to trigger completion.
169 inoremap <silent><expr> <c-space> coc#refresh()
171 " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
172 " Coc only does snippet and additional edit on confirm.
173 inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
174 " Or use `complete_info` if your vim support it, like:
175 " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
177 " Use `[g` and `]g` to navigate diagnostics
178 nmap <silent> [g <Plug>(coc-diagnostic-prev)
179 nmap <silent> ]g <Plug>(coc-diagnostic-next)
181 " Remap keys for gotos
182 nmap <silent> gd <Plug>(coc-definition)
183 nmap <silent> gy <Plug>(coc-type-definition)
184 nmap <silent> gi <Plug>(coc-implementation)
185 nmap <silent> gr <Plug>(coc-references)
187 " Use K to show documentation in preview window
188 nnoremap <silent> K :call <SID>show_documentation()<CR>
190 function! s:show_documentation()
191 if (index(['vim','help'], &filetype) >= 0)
192 execute 'h '.expand('<cword>')
194 call CocAction('doHover')
198 " Highlight symbol under cursor on CursorHold
199 autocmd CursorHold * silent call CocActionAsync('highlight')
201 " Remap for rename current word
202 nmap <F2> <Plug>(coc-rename)
204 " Remap for format selected region
205 xmap <leader>f <Plug>(coc-format-selected)
206 nmap <leader>f <Plug>(coc-format-selected)
210 " Setup formatexpr specified filetype(s).
211 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
212 " Update signature help on jump placeholder
213 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
216 " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
217 xmap <leader>a <Plug>(coc-codeaction-selected)
218 nmap <leader>a <Plug>(coc-codeaction-selected)
220 " Remap for do codeAction of current line
221 nmap <leader>ac <Plug>(coc-codeaction)
222 " Fix autofix problem of current line
223 nmap <leader>qf <Plug>(coc-fix-current)
225 " Create mappings for function text object, requires document symbols feature of languageserver.
226 xmap if <Plug>(coc-funcobj-i)
227 xmap af <Plug>(coc-funcobj-a)
228 omap if <Plug>(coc-funcobj-i)
229 omap af <Plug>(coc-funcobj-a)
231 " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
232 nmap <silent> <C-d> <Plug>(coc-range-select)
233 xmap <silent> <C-d> <Plug>(coc-range-select)
235 " Use `:Format` to format current buffer
236 command! -nargs=0 Format :call CocAction('format')
238 " Use `:Fold` to fold current buffer
239 command! -nargs=? Fold :call CocAction('fold', <f-args>)
241 " use `:OR` for organize import of current buffer
242 command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
244 " Add status line support, for integration with other plugin, checkout `:h coc-status`
245 set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
248 " Show all diagnostics
249 nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
251 nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
253 nnoremap <silent> <space>c :<C-u>CocList commands<cr>
254 " Find symbol of current document
255 nnoremap <silent> <space>o :<C-u>CocList outline<cr>
256 " Search workspace symbols
257 nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
258 " Do default action for next item.
259 nnoremap <silent> <space>j :<C-u>CocNext<CR>
260 " Do default action for previous item.
261 nnoremap <silent> <space>k :<C-u>CocPrev<CR>
262 " Resume latest coc list
263 nnoremap <silent> <space>p :<C-u>CocListResume<CR>
269 fun! TrimWhitespace()
270 let l:save = winsaveview()
271 keeppatterns %s/\s\+$//e
272 call winrestview(l:save)
275 augroup JOSUERODRIGUEZ
277 autocmd BufWritePre * :call TrimWhitespace()