-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathide.vim
More file actions
473 lines (398 loc) · 13.5 KB
/
ide.vim
File metadata and controls
473 lines (398 loc) · 13.5 KB
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
let g:coc_global_extensions = [ 'coc-json', 'coc-pyright', 'coc-vimlsp', '@yaegassy/coc-tailwindcss3', '@yaegassy/coc-volar', 'coc-css', 'coc-tsserver', 'coc-go' ]
" For yaegassy/coc-tailwindcss3
au FileType html let b:coc_root_patterns = ['.git', '.env', 'tailwind.config.js', 'tailwind.config.cjs']
" [disabled] Insert Mode Completions {{{
" if (executable('pyls'))
" augroup VimrcLsp
" au!
" au User lsp_setup call lsp#register_server({
" \ 'name': 'pyls',
" \ 'cmd': {server_info->['pyls']},
" \ 'allowlist': ['python'],
" \ 'config': { 'hover_coneal' : 1},
" \ 'workspace_config': {'pyls': { 'plugins': {'pydocstyle': {'enabled': v:false} } } }
" \ })
" augroup END
" endif
"
"
" let g:lsp_log_file = expand('~/Desktop/neovim/lsp.log')
"
" function! s:on_lsp_buffer_enabled() abort
" setlocal omnifunc=lsp#complete
" " nmap <buffer> gd <plug>(lsp-definition)
" nmap <buffer> <f2> <plug>(lsp-rename)
" endfunction
" augroup lsp_install
" au!
" autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
" augroup END
" let g:lsp_diagnostics_enabled = 0
" let g:asyncomplete_auto_completeopt = 0
" let g:asyncomplete_popup_delay = 0
" let g:asyncomplete_enable_for_all = 0
"
"
" let g:SuperTabDefaultCompletionType="context"
" let g:SuperTabCrMapping=1
" let g:SuperTabCompleteCase="match"
"
"
"
" let g:UltiSnipsExpandTrigger='<c-j>'
" let g:UltiSnipsJumpForwardTrigger='<c-j>'
" }}}
" PyflakesRefinedCallback(buffer, lines) {{{
function! PyflakesRefinedCallback(buffer, lines) abort
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let g:ale_debug = l:match[3]
" CUSTOMIZATION - Start
if stridx(l:match[3], "assigned to but never used") > -1
continue
endif
if stridx(l:match[3], "imported but unused") > -1
continue
endif
" CUSTOMIZATION - End
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
function! s:VintRefinedCallback(buffer, lines) abort
" ~/vimfiles/plugged/ale/ale_linters/vim/vint.vim
" ~/vimfiles/temp/220812.ale_vint_loclist.json
let l:loclist = ale_linters#vim#vint#Handle(a:buffer, a:lines)
let l:loclist_filtered = []
for l:loclist_D in l:loclist
let text = l:loclist_D['text']
let should_continue = v:false
for error_name in [ 'ProhibitMissingScriptEncoding', 'ProhibitUnnecessaryDoubleQuote', 'ProhibitCommandWithUnintendedSideEffect', 'ProhibitCommandRelyOnUser' ]
if stridx(text, error_name) == 0
let should_continue = v:true
break
endif
endfor
if should_continue
continue
endif
call add(l:loclist_filtered, l:loclist_D)
endfor
" return l:loclist
return l:loclist_filtered
endfunction
" }}}
" DefineCustomAleLinters() {{{
function! s:DefineCustomAleLinters()
if exists("g:loaded_ale")
call ale#linter#Define('python', {
\ 'name': 'pyflakes_refined',
\ 'executable': function('ale_linters#python#pyflakes#GetExecutable'),
\ 'command': function('ale_linters#python#pyflakes#GetCommand'),
\ 'callback': 'PyflakesRefinedCallback',
\ 'output_stream': 'both',
\})
call ale#linter#Define('vim', {
\ 'name': 'vint_refined',
\ 'executable': {buffer -> ale#Var(buffer, 'vim_vint_executable')},
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale#Var(buffer, 'vim_vint_executable'),
\ '%e --version',
\ function('ale_linters#vim#vint#GetCommand'),
\ )},
\ 'callback': 's:VintRefinedCallback',
\})
endif
endfunction
" }}}
" Ale au, g: {{{
augroup VimrcAle
au!
au VimEnter * call s:DefineCustomAleLinters()
augroup END
let g:ale_linters = {
\ 'python' : [ 'pyflakes_refined' ],
\ 'javascript' : ['quick-lint-js'],
\ 'php' : ["php"],
\ 'vim': ['vint_refined' ],
\ 'go' : [ 'gobuild' ]
\ }
let g:ale_fixers = {
\ 'go' : [ 'gofmt', 'goimports' ],
\ 'python' : [ 'autoimport' ],
\ 'sql' : [ 'sqlfluff' ],
\}
" let g:ale_lint_on_enter = 0
" let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 1 " Default: 1
let g:ale_lint_on_save = 1 " Default: 1
let g:ale_lint_on_filetype_changed = 0 " Default: 1
let g:ale_lint_on_insert_leave = 0 " Default: 1
let g:ale_lint_on_text_changed = 0 " Default: 'normal'
let g:ale_lint_delay = 0 " Default: 200
let g:ale_html_tidy_options = '-q -e -language en --escape-scripts 0'
let g:ale_sql_sqlfluff_options = ''
" Put this in ~/.eslintrc.json
" {
" "extends": [
" "plugin:vue/base"
" ]
" }
" let g:ale_javascript_eslint_options='--resolve-plugins-relative-to=C:\Users\vivek\AppData\Roaming\npm'
if has('win32')
let g:ale_javascript_eslint_options='--config ~/vimfiles/lint/eslint_config.json --resolve-plugins-relative-to=C:\Users\vivek\AppData\Roaming\npm'
" let g:ale_javascript_eslint_options=''
else
let g:ale_javascript_eslint_options='--config ~/.vim/lint/eslint_config.json'
" let g:ale_javascript_eslint_options=''
endif
" }}}
" Jedi g:{{{
let g:jedi#popup_on_dot = 0
let g:jedi#added_sys_path = [ '/Users/vivek/Documents/Python' ]
let g:jedi#completions_enabled = 0
let g:jedi#show_call_signatures = 1
let g:jedi#auto_vim_configuration = 0 " to prevent jedi from overriding 'completeopt'
" }}}
" Disable file with size > 1MB
function! s:ConfigureCoc()
let ONE_KB = 1024
if getfsize(expand('<afile>')) > 100*ONE_KB
let b:coc_suggest_disable = 1
endif
endfunction
augroup CocJediChooser
au!
autocmd BufReadPre * call s:ConfigureCoc()
augroup END
" TODO: Integrate UltiSnips expansion + jumping
" TODO: Make SHIFT-TAB invert behaviour
function! s:Nothing_before_cursor()
let line_part = strcharpart(getline("."), 0, col('.')-1)
if len(trim(line_part)) == 0
return v:true
else
return v:false
endif
endfunction
function! s:Space_before_cursor()
let line_part = strcharpart(getline("."), 0, col('.')-1)
if match(line_part, ' $') == -1
return v:false
else
return v:true
endif
endfunction
function! s:Period_before_cursor()
let line_part = strcharpart(getline("."), 0, col('.')-1)
if match(line_part, '\.\w*$') == -1
return v:false
else
return v:true
endif
endfunction
function! s:TabCompletion()
" Handle intelligent file completion here or offload to `coc`?
" ============================================================
"
" If you handle here, you'll need a File_separator_before_cursor() function
"
" You will also need to get directories in cwd to intelligently complete
" directories and files that don’t start with a slash. This can be updated
" via DirChanged and BufEnter autocommands.
"
" TODO: Make native keyword completion that naturally returns <C-p>
" results for <C-n>. Simplify this switch b/w <C-n> and <C-p>
" REMOVE 1:
" let message = printf("pumvisible: %s, mode: %s", string(pumvisible()), string(complete_info()["mode"]))
" REMOVE 2:
" let pum_is_visible = pumvisible()
"
" if pum_is_visible && complete_info()["mode"] !=# "keyword"
" return "\<C-n>"
" endif
" if pum_is_visible && complete_info()["mode"] ==# "keyword"
" return "\<C-p>"
" endif
" Not available on 'coc v0.0.81'
if coc#pum#visible()
return coc#pum#next(1)
endif
if pumvisible()
return "\<C-n>"
endif
" REMOVE 6:
if s:Nothing_before_cursor()
return "\<TAB>"
endif
" REMOVE 5:
if s:Space_before_cursor()
return "\<TAB>"
endif
" REMOVE 3:
" if exists('b:coc_suggest_disable') && b:coc_suggest_disable == 1
" if s:Period_before_cursor()
" return "\<C-x>\<C-o>" " Start omni-completion
" else
" return "\<C-p>" " Start keyword completion
" " return "\<C-n>"
" endif
" endif
" REMOVE 4:
" if !exists("*coc#refresh")
" return "\<C-p>" " Start keyword completion
" " return "\<C-n>"
" endif
call coc#refresh() " Start Coc Completion
endfunction
inoremap <silent> <expr> <C-u> coc#refresh()
function! s:ShowDocumentationVim()
let NewLineCount = { str -> count(trim(substitute(str, '```\(help\)\?', '', 'g')), "\n") }
if exists("*CocHasProvider") && CocHasProvider('hover') && CocAction('getHover') != [] && NewLineCount(CocAction('getHover')[0]) != 0
call CocAction('doHover')
else
normal! K
endif
endfunction
function! s:ShowDocumentation()
if exists("*CocHasProvider") && CocHasProvider('hover')
return ":call CocAction('doHover')\<CR>"
else
return "K"
endif
endfunction
set completeopt=menuone,popup
set complete=.,w
inoremap <silent> <expr> <c-space> coc#refresh()
" h coc-locations-api
nnoremap <silent> <expr> K <SID>ShowDocumentation()
augroup IDEShowDoc
au!
au BufRead *.vim nnoremap <buffer> K :call <SID>ShowDocumentationVim()<CR>
augroup END
" check if tab mapping exists, so that we don’t override copilot as copilot
" already respects our tab mapping if no suggestion is available
if mapcheck("<TAB>", "i") == ""
inoremap <silent> <expr> <TAB> <SID>TabCompletion()
endif
" inoremap <silent> <expr> <TAB> <SID>TabCompletion()
" inoremap <silent> <expr> <S-Tab> pumvisible() ? '<C-p>' : '<Tab>'
function! s:ShiftTab()
if coc#pum#visible()
return coc#pum#prev(1)
endif
if pumvisible()
return "\<C-p>"
endif
return "\<C-h>"
endfunction
" inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent> <expr> <S-TAB> <SID>ShiftTab()
" <<<<<<<<<< VIMSPECTOR
" nnoremap <Leader>dT :call vimspector#ClearBreakpoints()<CR>
"
" nmap <Leader>dc <Plug>VimspectorContinue
" nmap <Leader>dl <Plug>VimspectorRestart
" windows:
" expression
" variable
" breakpoints
" frames
" console
" code
"
" [home] dh - [free]
"
" [wide] de - [free] never used because we have d;
" [wide] do - [free]
" [wide] dm - [free]
" [wide] dn - [free]
" [wide] dp - [free]
" [wide] du - [free]
" [wide] dy - [free]
"
" [narr] dc - [free]
" [narr] dq - [free]
" [narr] dr - [free]
" [narr] dx - [free]
" [narr] dz - [free]
"
" da - delete around
" db - delete back
" dd - delete line
" df - delete f inclusive
" dg - delete next match via dgn
" di - delete inside
" dj - delete back
" dk - delete line below
" dl - delete line above
" ds - vim-surround
" dt - delete f exclusive
" dv - delete visual
" dw - delete from cursor to end
" <Plug>VimspectorContinue vimspector#Continue()
" <Plug>VimspectorStop vimspector#Stop()
" <Plug>VimpectorRestart vimspector#Restart()
" <Plug>VimspectorPause vimspector#Pause()
" <Plug>VimspectorBreakpoints vimspector#ListBreakpoints()
" <Plug>VimspectorToggleConditionalBreakpoint vimspector#ToggleBreakpoint( { trigger expr, hit count expr } )
" <Plug>VimspectorAddFunctionBreakpoint vimspector#AddFunctionBreakpoint( <cexpr> )
" <Plug>VimspectorGoToCurrentLine vimspector#GoToCurrentLine()
" <Plug>VimspectorJumpToNextBreakpoint vimspector#JumpToNextBreakpoint()
" <Plug>VimspectorJumpToPreviousBreakpoint vimspector#JumpToPreviousBreakpoint()
" <Plug>VimspectorJumpToProgramCounter vimspector#JumpToProgramCounter()
" <Plug>VimspectorBalloonEval _internal_
function! s:VimspectorIsEnabled()
if !exists("g:vimspector_session_windows")
return v:false
endif
if g:vimspector_session_windows == { 'breakpoints': v:none }
return v:false
endif
if g:vimspector_session_windows == {}
return v:false
endif
return v:true
endfunction
if !exists("s:left_save")
let s:left_save = maparg("<Left>", "n")
let s:right_save = maparg("<Right>", "n")
endif
nmap <silent> <expr> <Left> <SID>VimspectorIsEnabled() ? '<Plug>VimspectorStepOut' : '<Plug>SidewaysLeftExtended'
nmap <silent> <expr> <Right> <SID>VimspectorIsEnabled() ? '<Plug>VimspectorStepInto' : '<Plug>SidewaysRightExtended'
nmap <Up> <Plug>VimspectorUpFrame
nmap <Down> <Plug>VimspectorDownFrame
" nnoremap <Leader>dt :call vimspector#ToggleBreakpoint()<CR>
nmap dp <Plug>VimspectorToggleBreakpoint
nmap dh <Plug>VimspectorRunToCursor
nmap dy <Plug>VimspectorBalloonEval
nnoremap dq :call vimspector#Reset()<CR>
" ~/vimfiles/vimspector/configurations/windows/_all/global.json
nnoremap do :call vimspector#Launch()<CR>
" VIMSPECTOR >>>>>>>>>>
function! s:StartInsert(...)
call feedkeys("i", "n")
endfunction
function! s:PC()
call timer_start(10, function("s:StartInsert"))
return "\<CR>"
endfunction
augroup ConsoleMaps
au!
au BufEnter Vimspector.Console inoremap <buffer> <expr> <CR> <SID>PC()
augroup END
nmap <expr> <CR> <SID>VimspectorIsEnabled() ? "<Plug>VimspectorStepOver" : "<CR>"
" let console_bufnr = getwininfo(g:vimspector_session_windows.output)[0]['bufnr']
let g:vimspector_install_gadgets = [ 'debugpy' ]
if has('win32')
let g:vimspector_base_dir = expand('~/vimfiles/vimspector')
else
let g:vimspector_base_dir = expand('~/.vim/vimspector')
endif
command! Usages call CocActionAsync('jumpUsed')