cambios en la charla y codi
[dotfilesold/.git] / .config / nvim / init.vim
1
2 " Specify a directory for plugins
3 call plug#begin('~/.vim/plugged')
4 Plug 'ChristianChiarulli/codi.vim'
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 "Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
15
16 Plug 'christoomey/vim-tmux-navigator'
17
18 Plug 'morhetz/gruvbox'
19 Plug 'dracula/vim',{'as':'dracula'}
20 Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
21
22 " Initialize plugin system
23 call plug#end()
24
25 inoremap jk <ESC>
26 nmap <C-n> :NERDTreeToggle<CR>
27 nmap <C-s> :w<CR>
28 vmap ++ <plug>NERDCommenterToggle
29 nmap ++ <plug>NERDCommenterToggle
30 set timeout timeoutlen=2000
31
32 set termguicolors
33 set number
34 set ignorecase
35 set smartcase
36 set relativenumber
37 "colorscheme dracula
38 colorscheme gruvbox
39 "THIS IS FOR CODIIII DELTEMEEEEEEEEEEEE HEEEEEEY
40 " Change the color
41 highlight CodiVirtualText guifg=cyan
42
43 let g:codi#virtual_text_prefix = "❯ "
44
45
46 "
47 let g:codi#aliases = {
48                    \ 'javascript.jsx': 'javascript',
49                    \ }
50
51
52 " open NERDTree automatically
53 "autocmd StdinReadPre * let s:std_in=1
54 "autocmd VimEnter * NERDTree
55
56 let g:NERDTreeGitStatusWithFlags = 1
57 "let g:WebDevIconsUnicodeDecorateFolderNodes = 1
58 "let g:NERDTreeGitStatusNodeColorization = 1
59 "let g:NERDTreeColorMapCustom = {
60     "\ "Staged"    : "#0ee375",  
61     "\ "Modified"  : "#d9bf91",  
62     "\ "Renamed"   : "#51C9FC",  
63     "\ "Untracked" : "#FCE77C",  
64     "\ "Unmerged"  : "#FC51E6",  
65     "\ "Dirty"     : "#FFBD61",  
66     "\ "Clean"     : "#87939A",   
67     "\ "Ignored"   : "#808080"   
68     "\ }                         
69
70
71 let g:NERDTreeIgnore = ['^node_modules$']
72
73 " vim-prettier
74 "let g:prettier#quickfix_enabled = 0
75 "let g:prettier#quickfix_auto_focus = 0
76 " prettier command for coc
77 command! -nargs=0 Prettier :CocCommand prettier.formatFile
78 " run prettier on save
79 "let g:prettier#autoformat = 0
80 "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
81
82
83 " ctrlp
84 let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
85
86 " j/k will move virtual lines (lines that wrap)
87 noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
88 noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
89
90
91 set smarttab
92 set cindent
93 set tabstop=2
94 set shiftwidth=2
95 " always uses spaces instead of tab characters
96 set expandtab
97
98
99
100 " sync open file with NERDTree
101 " " Check if NERDTree is open or active
102 function! IsNERDTreeOpen()        
103   return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
104 endfunction
105
106 " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
107 " file, and we're not in vimdiff
108 function! SyncTree()
109   if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
110     NERDTreeFind
111     wincmd p
112   endif
113 endfunction
114
115 " Highlight currently open buffer in NERDTree
116 autocmd BufEnter * call SyncTree()
117
118 " coc config
119 let g:coc_global_extensions = [
120   \ 'coc-snippets',
121   \ 'coc-pairs',
122   \ 'coc-tsserver',
123   \ 'coc-eslint', 
124   \ 'coc-prettier', 
125   \ 'coc-json', 
126   \ 'coc-clangd', 
127   \ 'coc-css', 
128   \ 'coc-html', 
129   \ 'coc-markdownlint', 
130   \ 'coc-python', 
131   \ ]
132 " from readme
133 " if hidden is not set, TextEdit might fail.
134 set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000.
135 set updatetime=300
136
137 " don't give |ins-completion-menu| messages.
138 set shortmess+=c
139
140 " always show signcolumns
141 set signcolumn=yes
142
143 " Use tab for trigger completion with characters ahead and navigate.
144 " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
145 inoremap <silent><expr> <TAB>
146       \ pumvisible() ? "\<C-n>" :
147       \ <SID>check_back_space() ? "\<TAB>" :
148       \ coc#refresh()
149 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
150
151 function! s:check_back_space() abort
152   let col = col('.') - 1
153   return !col || getline('.')[col - 1]  =~# '\s'
154 endfunction
155
156 " Use <c-space> to trigger completion.
157 inoremap <silent><expr> <c-space> coc#refresh()
158
159 " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
160 " Coc only does snippet and additional edit on confirm.
161 inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
162 " Or use `complete_info` if your vim support it, like:
163 " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
164
165 " Use `[g` and `]g` to navigate diagnostics
166 nmap <silent> [g <Plug>(coc-diagnostic-prev)
167 nmap <silent> ]g <Plug>(coc-diagnostic-next)
168
169 " Remap keys for gotos
170 nmap <silent> gd <Plug>(coc-definition)
171 nmap <silent> gy <Plug>(coc-type-definition)
172 nmap <silent> gi <Plug>(coc-implementation)
173 nmap <silent> gr <Plug>(coc-references)
174
175 " Use K to show documentation in preview window
176 nnoremap <silent> K :call <SID>show_documentation()<CR>
177
178 function! s:show_documentation()
179   if (index(['vim','help'], &filetype) >= 0)
180     execute 'h '.expand('<cword>')
181   else
182     call CocAction('doHover')
183   endif
184 endfunction
185
186 " Highlight symbol under cursor on CursorHold
187 autocmd CursorHold * silent call CocActionAsync('highlight')
188
189 " Remap for rename current word
190 nmap <F2> <Plug>(coc-rename)
191
192 " Remap for format selected region
193 xmap <leader>f  <Plug>(coc-format-selected)
194 nmap <leader>f  <Plug>(coc-format-selected)
195
196 augroup mygroup
197   autocmd!
198   " Setup formatexpr specified filetype(s).
199   autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
200   " Update signature help on jump placeholder
201   autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
202 augroup end
203
204 " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
205 xmap <leader>a  <Plug>(coc-codeaction-selected)
206 nmap <leader>a  <Plug>(coc-codeaction-selected)
207
208 " Remap for do codeAction of current line
209 nmap <leader>ac  <Plug>(coc-codeaction)
210 " Fix autofix problem of current line
211 nmap <leader>qf  <Plug>(coc-fix-current)
212
213 " Create mappings for function text object, requires document symbols feature of languageserver.
214 xmap if <Plug>(coc-funcobj-i)
215 xmap af <Plug>(coc-funcobj-a)
216 omap if <Plug>(coc-funcobj-i)
217 omap af <Plug>(coc-funcobj-a)
218
219 " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
220 nmap <silent> <C-d> <Plug>(coc-range-select)
221 xmap <silent> <C-d> <Plug>(coc-range-select)
222
223 " Use `:Format` to format current buffer
224 command! -nargs=0 Format :call CocAction('format')
225
226 " Use `:Fold` to fold current buffer
227 command! -nargs=? Fold :call     CocAction('fold', <f-args>)
228
229 " use `:OR` for organize import of current buffer
230 command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
231
232 " Add status line support, for integration with other plugin, checkout `:h coc-status`
233 set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
234
235 " Using CocList
236 " Show all diagnostics
237 nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
238 " Manage extensions
239 nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
240 " Show commands
241 nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
242 " Find symbol of current document
243 nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
244 " Search workspace symbols
245 nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
246 " Do default action for next item.
247 nnoremap <silent> <space>j  :<C-u>CocNext<CR>
248 " Do default action for previous item.
249 nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
250 " Resume latest coc list
251 nnoremap <silent> <space>p  :<C-u>CocListResume<CR>