-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
executable file
·328 lines (270 loc) · 8.83 KB
/
init.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" snippets
Plug 'ncm2/ncm2-ultisnips'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Project
Plug 'scrooloose/nerdtree'
" Plug 'vimlab/split-term.vim'
" UI
Plug 'joshdick/onedark.vim'
Plug 'jonathanfilip/vim-lucius'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'sarahlim/wild-cherry-vim'
" Better Visual Guide
Plug 'Yggdroot/indentLine'
Plug 'luochen1990/rainbow'
" Plug 'ryanoasis/vim-devicons'
" syntax check
Plug 'w0rp/ale'
" show git changes
Plug 'airblade/vim-gitgutter'
Plug 'ctrlpvim/ctrlp.vim'
" Autocomplete framework
Plug 'ncm2/ncm2'
" Python auto completion
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-jedi'
" Words in buffer completion
Plug 'ncm2/ncm2-bufword'
" Filepath completion
Plug 'ncm2/ncm2-path'
" Formater
Plug 'Chiel92/vim-autoformat'
Plug 'samoshkin/vim-mergetool'
" finder
"Plug '/usr/local/bin/fzf'
" Plug 'junegunn/fzf.vim'
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" Lang supports
Plug 'posva/vim-vue'
" Plug 'maxmellon/vim-jsx-pretty'
Plug 'mxw/vim-jsx'
Plug 'pangloss/vim-javascript'
" Plug 'janko/vim-test'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/gv.vim'
Plug 'ludovicchabant/vim-gutentags'
" Plug 'kassio/neoterm'
" Plug 'alfredodeza/pytest.vim'
Plug 'APZelos/blamer.nvim'
" Initialize plugin system
call plug#end()
" jsx
let g:jsx_ext_required = 1
" Disable Jedi-vim autocompletion and enable call-signatures options
let g:jedi#auto_initialization = 1
let g:jedi#completions_enabled = 0
let g:jedi#auto_vim_configuration = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#popup_on_dot = 0
let g:jedi#completions_command = ""
let g:jedi#show_call_signatures = "1"
" Mostrar mejor mensajes de error
" let g:ale_echo_msg_error_str = 'E'
" let g:ale_echo_msg_warning_str = 'W'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_linters = {
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\ 'vue': ['eslint']
\}
let b:ale_python_flake8_options = '--max-line-length=120'
" Run both javascript and vue linters for vue files.
" let b:ale_linter_aliases = ['javascript', 'vue']
" Select the eslint and vls linters.
" let b:ale_linters = ['eslint', 'vls']
" Airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_powerline_fonts = 1
let g:airline_theme="base16color"
let g:airline#extensions#ale#enabled = 1
let airline#extensions#ale#error_symbol = 'E:'
let airline#extensions#ale#warning_symbol = 'W:'
function! AirlineInit()
let g:airline_section_a = airline#section#create(['mode', ' ', 'branch'])
let g:airline_section_b = airline#section#create_left(['ffenc', 'hunks', '%f'])
let g:airline_section_c = airline#section#create(['filetype'])
let g:airline_section_x = airline#section#create(['%P'])
let g:airline_section_y = airline#section#create(['%B'])
let g:airline_section_z = airline#section#create_right(['%l', '%c'])
endfunction
autocmd VimEnter * call AirlineInit()
" NCM2
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
set shortmess+=c
inoremap <c-c> <ESC>
" make it fast
let ncm2#popup_delay = 5
let ncm2#complete_length = [[1, 1]]
" Use new fuzzy based matches
let g:ncm2#matcher = 'substrfuzzy'
" ctrlP
set runtimepath^=~/.vim/plugged/ctrlp.vim
let g:ctrlp_custom_ignore = '\v\.(npy|jpg|pyc|so|dll)$'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
\ }
" UI configuration
syntax on
syntax enable
set showmatch " Show matching brackets.
set number " Show the line numbers on the left side.
set relativenumber
set expandtab " Insert spaces when TAB is pressed.
set tabstop=4 " Render TABs using this many spaces.
set shiftwidth=4 " Indentation amount for < and > commands.
set ignorecase
set smartcase
set noshowmode
set cursorline
" colorscheme
set termguicolors " Activa true colors en la terminal
colorscheme wildcherry " Activa tema onedark
set background=dark
" Vertical Rule
highlight ColorColumn ctermbg=darkgray
set colorcolumn=120
" gitgutter
let g:gitgutter_map_keys = 0
set updatetime=100
" Use system wide clipboard by default
set clipboard=unnamedplus,unnamed
" change tabs
" nnoremap <C-l> :tabprevious<CR>
" inoremap <C-l> <Esc>:tabprevious<CR>i
" nnoremap <C-n> :tabnext<CR>
" inoremap <C-n> <Esc>:tabnext<CR>i
"
"
" Insert mode Movements
inoremap <C-h> <C-o>h
inoremap <C-l> <C-o>l
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
" filetype support
autocmd FileType vue syntax sync fromstart
autocmd FileType vue setlocal ts=2 sts=2 sw=2
autocmd FileType javascript setlocal ts=2 sts=2 sw=2
autocmd FileType yaml setlocal ts=2 sts=2 sw=2
" update files for external modifications
" autocmd FocusGained * silent! checktime
" au FocusGained * :checktime
au FocusGained,BufEnter * :silent! checktime
" split term
" set splitbelow
" nnoremap <Leader>` :10Term<CR>
" inoremap <Leader>` <Esc>:10Term<CR>i
" NERDTree
" Change Leader
" let mapleader=','
" let maplocalleader='\'
map <Leader>n :NERDTreeToggle<CR> " Show/Hide NerdTree
noremap <Leader>r :NERDTreeFind<CR> " Find current buffer in nerdtree
let g:NERDTreeMapOpenVSplit='v' " keep mappings between ctrlp and nerdtree concise
let NERDTreeIgnore=['\.pyc$', '\~$'] " Ignore irrelevant files like pyc and swap files
" snippets
" inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n')
" let g:UltiSnipsRemoveSelectModeMappings = 0
" set rtp+=/usr/bin/fzf
"
"
" The Silver Searcher
" if executable('ag')
" set grepprg=ag\ --nogroup\ --nocolor
" let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" let g:ctrlp_use_caching = 0
" endif
" bind K to grep word under cursor
" nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
" command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
" open cTags on a new tag
map <C-]> :TabExpand 1<CR>
command! -nargs=1 TabExpand call HandleTabTagExpand( <f-args> )
let s:commentchar = """
function HandleTabTagExpand(tagnumber)
let tagident = expand("<cword>")
redir @a
try
sil exe "tselect ".tagident
catch /^Vim(\a\+):E433:/ " no tag file
echom "No tag file found."
return
catch /^Vim(\a\+):E426:/ " tag not found
echom "Tag not found."
return
endtry
redir END
let tagresults = split(@a, "\n")
let tagmatches = []
let linenum = 0
for line in tagresults
if linenum % 3 != 1
" every third line contains the file names
let linenum = linenum + 1
continue
endif
" figure out where the filename actually starts
" (it's usually column 32, but it might be farther)
" one before 32 is 31, but index is 30 since arrays begin at zero
let filestart = 30
let c = line[filestart]
while (filestart < strlen(line))
let filestart = filestart + 1
if c == " "
break
endif
let c = line[filestart]
endwhile
" store the parsed match in an array
call add(tagmatches, strpart(line, filestart))
let linenum = linenum + 1
endfor
" navigate to the match specified by tagnumber
try
exe "tab drop ".tagmatches[a:tagnumber-1]
catch /^Vim(\a\+):E471:/ " argument required (means no tag found)
echom "Tag not found."
endtry
let done = 0
let matchcount = 0
let f_line = ""
while done < 1 && matchcount < 1000
sil exe "/".tagident
let f_line = getline(".")
let matchcount = matchcount + 1
if match(f_line, "^\s+".s:commentchar) < 0
let done = 1
endif
endwhile
let f_index = stridx( f_line, tagident )
sil exe "normal 0"
sil exe "normal ".f_index."l"
endfunction
let g:rainbow_active = 1
autocmd Filetype json :IndentLinesDisable
" mergetool
let g:mergetool_layout = 'bmr'
let g:mergetool_prefer_revision = 'local'
nmap <expr> <C-Left> &diff? '<Plug>(MergetoolDiffExchangeLeft)' : '<C-Left>'
nmap <expr> <C-Right> &diff? '<Plug>(MergetoolDiffExchangeRight)' : '<C-Right>'
nmap <expr> <C-Down> &diff? '<Plug>(MergetoolDiffExchangeDown)' : '<C-Down>'
nmap <expr> <C-Up> &diff? '<Plug>(MergetoolDiffExchangeUp)' : '<C-Up>'
let g:blamer_enabled = 1
let g:blamer_delay = 500
let g:blamer_show_in_insert_modes = 0
let g:blamer_show_in_visual_modes = 0