Mercurial > dotfiles
annotate dot_config/nvim/init.vim @ 275:6eae07a6985f
Update urls for completion-nvim and diagnostic-nvim
author | zegervdv <zegervdv@me.com> |
---|---|
date | Thu, 06 Aug 2020 22:24:25 +0200 |
parents | b77b75c88ce6 |
children | ecc3074ac1fc |
rev | line source |
---|---|
273 | 1 " vim:fdm=marker:ts=2:sw=2 |
2 | |
3 let s:darwin = has('mac') | |
4 let s:windows = has('win32') | |
5 | |
6 " Include Vim-Plug {{{ | |
7 if !s:windows | |
8 if has('nvim') | |
9 if empty(glob('~/.config/nvim/autoload/plug.vim')) | |
10 silent !mkdir -p ~/.config/nvim/autoload | |
11 silent !curl -fLo ~/.config/nvim/autoload/plug.vim | |
12 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
13 autocmd VimEnter * PlugInstall | |
14 endif | |
15 else | |
16 if empty(glob('~/.vim/autoload/plug.vim')) | |
17 silent !mkdir -p ~/.vim/autoload | |
18 silent !curl -fLo ~/.vim/autoload/plug.vim | |
19 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
20 autocmd VimEnter * PlugInstall | |
21 endif | |
22 endif | |
23 endif | |
24 | |
25 " }}} | |
26 " Vim-Plug {{{ | |
27 let g:plug_window='topleft new' | |
28 | |
29 if has('nvim') | |
30 call plug#begin('~/.config/nvim/plugged') | |
31 else | |
32 call plug#begin('~/.vim/plugged') | |
33 endif | |
34 | |
35 " General Plugins | |
36 if !has("nvim") | |
37 Plug 'tpope/vim-sensible' | |
38 endif | |
39 | |
40 if s:darwin | |
41 Plug 'vim-scripts/gitignore' | |
42 endif | |
43 | |
44 Plug 'sjl/splice.vim' | |
45 | |
46 Plug 'tpope/vim-repeat' | |
47 Plug 'tpope/vim-rsi' | |
48 Plug 'einfachtoll/didyoumean' | |
49 | |
50 " Session Management | |
51 Plug 'tpope/vim-obsession' | |
52 | |
53 " Spelling | |
54 Plug 'tpope/vim-abolish' | |
55 | |
56 " Settings | |
57 Plug 'sgur/vim-editorconfig' | |
58 | |
59 " Brackets | |
60 Plug 'tpope/vim-surround' | |
61 Plug 'raimondi/delimitMate' | |
62 Plug 'tommcdo/vim-exchange' | |
63 | |
64 " Formatting | |
65 Plug 'junegunn/vim-easy-align', { 'on' : [] } | |
66 augroup load_easy_align | |
67 autocmd! | |
68 autocmd CursorHold,CursorHoldI * call plug#load('vim-easy-align') | autocmd! load_easy_align | |
69 augroup END | |
70 | |
71 " Comments | |
72 Plug 'tpope/vim-commentary' | |
73 | |
74 " Moving in files | |
75 Plug 'wellle/targets.vim', { 'on': [] } | |
76 augroup load_targets | |
77 autocmd! | |
78 autocmd InsertEnter * call plug#load('targets.vim') | autocmd! load_targets | |
79 augroup END | |
80 Plug 'mhinz/vim-grepper', { 'on' : 'Grepper' } | |
81 Plug 'wellle/context.vim' | |
82 | |
83 " Indentation | |
84 Plug 'nathanaelkane/vim-indent-guides' | |
85 | |
86 " Command line | |
87 Plug 'tpope/vim-eunuch', { 'on' : ['Remove', 'Unlink', 'Move', 'Rename', 'Mkdir', 'Chmod', 'Find', 'Locate', 'SudoEdit', 'SudoWrite']} | |
88 | |
89 " Undoing | |
90 Plug 'sjl/gundo.vim', { 'on': 'GundoToggle' } | |
91 | |
92 " Pasting | |
93 " Plug 'junegunn/vim-peekaboo' | |
94 | |
95 " Tabs | |
96 Plug 'gcmt/taboo.vim' | |
97 | |
98 " Other | |
99 Plug 'yuttie/comfortable-motion.vim' | |
100 Plug 'tpope/vim-apathy' | |
101 | |
102 " Tmux | |
103 Plug 'christoomey/vim-tmux-navigator' | |
104 Plug 'tmux-plugins/vim-tmux-focus-events' | |
105 " Plug 'roxma/vim-tmux-clipboard' | |
106 | |
107 " Background make | |
108 " Plug 'skywind3000/asyncrun.vim' | |
109 Plug 'tpope/vim-dispatch' | |
110 | |
111 " Completing and snippets | |
112 Plug 'sirver/ultisnips' | |
113 Plug 'honza/vim-snippets' | |
114 if has('nvim') | |
115 " Plug 'neoclide/coc.nvim', { 'branch': 'release' } | |
116 " Plug 'neoclide/coc-sources' | |
117 Plug 'neovim/nvim-lsp' | |
275
6eae07a6985f
Update urls for completion-nvim and diagnostic-nvim
zegervdv <zegervdv@me.com>
parents:
274
diff
changeset
|
118 Plug 'nvim-lua/completion-nvim' |
6eae07a6985f
Update urls for completion-nvim and diagnostic-nvim
zegervdv <zegervdv@me.com>
parents:
274
diff
changeset
|
119 Plug 'nvim-lua/diagnostic-nvim' |
273 | 120 endif |
121 | |
122 " Copying | |
123 Plug 'ShikChen/osc52.vim' | |
124 | |
125 " Vim file navigation | |
126 " Plug 'tpope/vim-vinegar' | |
127 Plug 'justinmk/vim-dirvish' | |
128 Plug 'tpope/vim-projectionist' | |
129 | |
130 " Theme | |
131 Plug 'NLKNguyen/papercolor-theme' | |
132 Plug 'joshdick/onedark.vim' | |
133 | |
134 "Tcl | |
135 Plug 'vim-scripts/tcl.vim--smithfield-indent', { 'for': 'tcl'} | |
136 | |
274
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
137 " Plug 'zegervdv/ale', { 'branch': 'add_verible' } |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
138 Plug 'dense-analysis/ale' |
273 | 139 Plug 'sbdchd/neoformat' |
140 | |
141 " Debugging | |
142 Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh \| UpdateRemotePlugins' } | |
143 | |
144 Plug 'Glench/Vim-Jinja2-Syntax' | |
145 | |
146 if s:darwin | |
147 " Ruby | |
148 Plug 'tpope/vim-rails', { 'for': 'ruby' } | |
149 Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' } | |
150 Plug 'tpope/vim-bundler', { 'for': 'ruby' } | |
151 Plug 'tpope/vim-rake', { 'for': 'ruby' } | |
152 Plug 'slim-template/vim-slim', { 'for': 'ruby' } | |
153 Plug 'duwanis/tomdoc.vim', { 'for': 'ruby' } | |
154 Plug 'keith/rspec.vim', { 'for': 'rspec' } | |
155 | |
156 " Markdown | |
157 Plug 'tpope/vim-markdown', { 'for': 'markdown' } | |
158 | |
159 " Jade | |
160 Plug 'digitaltoad/vim-jade', { 'for': 'jade' } | |
161 | |
162 " Latex | |
163 Plug 'lervag/vimtex', { 'for': 'tex' } | |
164 endif | |
165 | |
166 " Coffeescript | |
167 Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' } | |
168 | |
169 " C | |
170 Plug 'NLKNguyen/c-syntax.vim', { 'for': 'c' } | |
171 | |
172 " Python | |
173 Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' } | |
174 Plug 'vim-python/python-syntax', { 'for': 'python' } | |
175 | |
176 " Git | |
177 Plug 'tpope/vim-git' | |
178 call plug#end() | |
179 " }}} | |
180 | |
181 " Activate built in plugins {{{ | |
182 if !has('nvim') | |
183 if has('packages') | |
184 packadd! matchit | |
185 packadd! shellmenu | |
186 endif | |
187 endif | |
188 source $VIMRUNTIME/ftplugin/man.vim | |
189 | |
190 if has('packages') | |
191 silent! packadd! log_file | |
192 silent! packadd! browsify | |
193 silent! packadd! snippets | |
194 silent! packadd! chipscoper | |
195 endif | |
196 | |
197 if has("nvim") | |
198 let g:python3_host_prog=expand('$HOME/.config/virtualenvs/python3/bin/python') | |
199 let g:python_host_prog=expand('$HOME/.config/virtualenvs/python2/bin/python') | |
200 endif | |
201 " }}} | |
202 | |
203 " General Settings and options {{{ | |
204 | |
205 " Backspace over everything, like normal | |
206 set backspace=2 | |
207 | |
208 " Buffers | |
209 set autoread " Read external changes | |
210 set hidden " Change between buffers without saving | |
211 set autowriteall " Write changes when losing focus | |
212 | |
213 " Visuals | |
214 set number | |
215 set relativenumber | |
216 set ruler | |
217 syntax on | |
218 set title | |
219 set scrolloff=4 " Stay 4 lines from top/bottom | |
220 set showcmd | |
221 | |
222 " Theme and style | |
223 " Override needs to be defined before calling colorscheme | |
224 function! IndentGuidesColor() abort | |
225 highlight IndentGuidesOdd ctermbg=254 | |
226 highlight IndentGuidesEven ctermbg=254 | |
227 endfunction | |
228 | |
229 augroup IndentColors | |
230 autocmd! | |
231 autocmd ColorScheme * call IndentGuidesColor() | |
232 augroup END | |
233 | |
234 " function! ColorOverrides() abort | |
235 " highlight Special ctermfg=31 | |
236 " endfunction | |
237 | |
238 " augroup ColorOverrides | |
239 " autocmd! | |
240 " autocmd ColorScheme * call ColorOverrides() | |
241 " augroup END | |
242 | |
243 | |
244 if !has("nvim") | |
245 set t_Co=256 | |
246 end | |
247 let g:PaperColor_Theme_Options = { | |
248 \ 'theme': { | |
249 \ 'default': { | |
250 \ 'allow_bold': 0 | |
251 \ } | |
252 \ } | |
253 \} | |
254 let g:onedark_color_overrides = { | |
255 \ "yellow": {"cterm": "3", "gui": "#ffc24b"} | |
256 \} | |
257 set background=dark | |
258 colorscheme onedark | |
259 if s:darwin | |
260 set background=dark | |
261 colorscheme tomorrow-night | |
262 set guifont=inconsolata:h13 | |
263 elseif s:windows | |
264 set background=light | |
265 colorscheme PaperColor | |
266 set guifont=consolas:h10 | |
267 endif | |
268 | |
269 if has('nvim') | |
270 set notermguicolors | |
271 endif | |
272 | |
273 set showmatch " Highlight matching brackets | |
274 | |
275 set wrap " Wrap lines | |
276 set wrapmargin=2 " Stay 2 chars from side | |
277 set textwidth=79 | |
278 set colorcolumn=81 | |
279 set linebreak " Smarter wrapping | |
280 if v:version > 703 | |
281 set breakindent " Indent wrapped lines to same level | |
282 endif | |
283 | |
284 set fixendofline | |
285 | |
286 set expandtab " Expand tabs to spaces | |
287 if s:darwin | |
288 set tabstop=2 shiftwidth=2 " Tab is 2 spaces | |
289 else | |
290 set tabstop=3 shiftwidth=3 | |
291 endif | |
292 | |
293 set shiftround " Round shift indents to nearest value | |
294 | |
295 " Searching | |
296 set magic " Use magic regexes | |
297 set hlsearch " Highlight all matches | |
298 set incsearch " Show matches while typing | |
299 set ignorecase " Ignore case when searching | |
300 set smartcase " Be case sensitive if at least one uppercase char is used | |
301 set gdefault " Default substitute all matches on a line | |
302 if has('nvim') | |
303 set inccommand=nosplit | |
304 endif | |
305 | |
306 set autoindent " Automatically indent | |
307 set cindent " Indent based on C syntax | |
308 set cinwords+=foreach | |
309 | |
310 set updatetime=300 | |
311 | |
312 if s:darwin | |
313 set vb | |
314 endif | |
315 set noerrorbells " Don't beep | |
316 | |
317 set guioptions-=r | |
318 set guioptions-=l | |
319 set guioptions-=R | |
320 set guioptions-=L | |
321 set guioptions-=a | |
322 set guioptions-=m | |
323 set guioptions-=T | |
324 set guioptions+=c | |
325 | |
326 set history=100 " Set history 100 | |
327 set wildmenu " Command completion | |
328 set wildmode=longest:full,full " Complete to fullest match | |
329 set ttyfast " Use a fast terminal | |
330 set lazyredraw " No need to redraw constantly | |
331 set shortmess+=c | |
332 | |
333 set ttimeoutlen=-1 " Set the timeout to a minimum | |
334 set diffopt+=iwhite " Ignore spaces in diffs" | |
335 | |
336 set tags=.git/tags,tags,/project/asic_fpga/tools/vim/share/vim/vimfiles/tags | |
337 | |
338 " Have find look through all folders | |
339 set path+=** | |
340 " Add PRJROOT and subdirs to path if it is set | |
341 if exists('$PRJROOT') | |
342 set path+=$PRJROOT/** | |
343 endif | |
344 | |
345 set formatoptions= | |
346 set formatoptions+=c " Format comments | |
347 set formatoptions+=r " Continue comments by default | |
348 set formatoptions+=o " Make comment when using o or O from comment line | |
349 set formatoptions+=q " Format comments with gq | |
350 set formatoptions+=n " Recognize numbered lists | |
351 set formatoptions+=2 " Use indent from 2nd line of a paragraph | |
352 " set formatoptions+=l " Don't break lines that are already long | |
353 set formatoptions+=1 " Break before 1-letter words | |
354 | |
355 set signcolumn=yes | |
356 | |
357 " Enable cursorline | |
358 set cursorline | |
359 augroup cline | |
360 au! | |
361 autocmd WinEnter * setlocal cursorline | |
362 autocmd WinLeave * setlocal nocursorline | |
363 augroup END | |
364 | |
365 if !s:windows | |
366 set list | |
367 set listchars=tab:»\ ,trail:·,extends:>,precedes:<,nbsp:+ | |
368 endif | |
369 | |
370 set sessionoptions-=options | |
371 | |
372 " Scan files for completion | |
373 set complete=.,w,b,u,k,kspell,t,i,d | |
374 " set completeopt=menuone,longest,preview,noinsert,noselect | |
375 set completeopt=noinsert,menuone,noselect | |
376 | |
377 set splitright | |
378 set virtualedit=block | |
379 | |
380 if v:version > 703 | |
381 set conceallevel=0 | |
382 if !has('nvim') | |
383 set cryptmethod=blowfish2 | |
384 endif | |
385 endif | |
386 | |
387 filetype plugin indent on | |
388 | |
389 set pastetoggle=<F2> " Toggle to paste mode | |
390 | |
391 if v:version >= 703 | |
392 set undofile | |
393 endif | |
394 set undolevels=1000 | |
395 set backup | |
396 set noswapfile | |
397 if has('nvim') | |
398 " set viminfo+=n~/.config/nvim/.viminfo | |
399 set backupdir=~/.config/nvim/tmp/backup/,. | |
400 set directory=~/.config/nvim/tmp/swap//,. | |
401 else | |
402 set viminfo+=n~/.vim/.viminfo | |
403 set backupdir=~/.vim/tmp/backup/,. | |
404 set directory=~/.vim/tmp/swap//,. | |
405 endif | |
406 if !isdirectory(expand(&backupdir)) | |
407 call mkdir(expand(&backupdir), "p") | |
408 endif | |
409 if !isdirectory(expand(&directory)) | |
410 call mkdir(expand(&directory), "p") | |
411 endif | |
412 | |
413 if v:version >= 703 | |
414 if has('nvim') | |
415 set undodir=~/.config/nvim/tmp/undo//,. | |
416 else | |
417 set undodir=~/.vim/tmp/undo//,. | |
418 endif | |
419 if !isdirectory(expand(&undodir)) | |
420 call mkdir(expand(&undodir), "p") | |
421 endif | |
422 endif | |
423 | |
424 | |
425 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex,*.eps,.git/**,*.dup,.hg/**,*.orig,*.*~ | |
426 | |
427 " No selecting via mouse (stops visual selection when scrolling) | |
428 set mouse=nic | |
429 | |
430 " }}} | |
431 " Status line {{{ | |
432 hi StatusLine ctermfg=0 ctermbg=3 cterm=NONE | |
433 hi StatusLineNC ctermfg=8 ctermbg=7 cterm=NONE | |
434 hi User1 ctermfg=0 ctermbg=7 | |
435 hi User2 ctermfg=NONE ctermbg=NONE | |
436 hi User3 ctermfg=0 ctermbg=3 | |
437 hi User4 ctermfg=0 ctermbg=5 | |
438 function! Status() | |
439 let l:statusline='' | |
440 let l:statusline.=' %t' | |
441 let l:statusline.=' %1*' | |
442 let l:statusline.=' %Y' | |
443 let l:statusline.=' %2*' | |
444 let l:statusline.='%=' | |
445 let l:statusline.=' %1*' | |
446 let l:statusline.=' line ' | |
447 let l:statusline.='' | |
448 let l:statusline.='%l' | |
449 let l:statusline.=' %3*' | |
450 let l:statusline.=' of ' | |
451 let l:statusline.='' | |
452 let l:statusline.='%L ' | |
453 let l:statusline.='' | |
454 return l:statusline | |
455 endfunction | |
456 set laststatus=2 | |
457 set statusline=%!Status() | |
458 " }}} | |
459 " Fix Colors in colorscheme {{{ | |
460 function! SpellHighlights() abort | |
461 highlight SpellBad ctermbg=256 ctermfg=210 | |
462 highlight SpellLocal ctermbg=240 ctermfg=010 | |
463 highlight SpellCap ctermbg=256 ctermfg=211 | |
464 endfunction | |
465 augroup SpellColors | |
466 autocmd! | |
467 autocmd ColorScheme * call SpellHighlights() | |
468 augroup END | |
469 "}}} | |
470 | |
471 " Mappings {{{ | |
472 " Set leader to spacebar | |
473 map <space> <leader> | |
474 | |
475 " See long lines as line breaks | |
476 noremap <expr> j (v:count? 'j' : 'gj') | |
477 noremap <expr> k (v:count? 'k' : 'gk') | |
478 | |
479 " Remap tag-search to better place | |
480 nnoremap <C-$> g<C-]> | |
481 nnoremap <C-y> g<C-]> | |
482 nnoremap <C-w>y <C-w>g<C-]> | |
483 | |
484 nnoremap <C-s> <C-e> | |
485 | |
486 " Move while in insert mode | |
487 inoremap <C-f> <right> | |
488 | |
489 " Switch between the last two files | |
490 " nnoremap <space><space> <C-^> | |
491 | |
492 " " Very Magic search patterns | |
493 nnoremap / /\v | |
494 vnoremap / /\v | |
495 | |
496 " Keep search matches in the middle of the window. | |
497 nnoremap n nzzzv | |
498 nnoremap N Nzzzv | |
499 | |
500 " Search for beginning of command | |
501 cnoremap <c-n> <down> | |
502 cnoremap <c-p> <up> | |
503 | |
504 " Move whole lines | |
505 nnoremap [e :<c-u>execute 'move -1-'. v:count1<cr> | |
506 nnoremap ]e :<c-u>execute 'move +'. v:count1<cr> | |
507 | |
508 " Insert empty lines | |
509 nnoremap [<space> :<c-u>put! =repeat(nr2char(10), v:count1)<cr>'[ | |
510 nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr> | |
511 | |
512 " Clear highlight | |
513 nnoremap <silent><leader>l :noh<CR> | |
514 | |
515 inoremap £ \ | |
516 | |
517 " Highlight last inserted text | |
518 nnoremap gV `[v`] | |
519 | |
520 " Highlight VCS conflict markers | |
521 match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' | |
522 | |
523 " Use backspace as delete in visual mode | |
524 vmap <BS> x | |
525 | |
526 " Redraw screen | |
527 nnoremap <F3> :redraw!<CR> | |
528 | |
529 " Keep selection when shifting | |
530 vmap <expr> > KeepVisualSelection(">") | |
531 vmap <expr> < KeepVisualSelection("<") | |
532 | |
533 function! KeepVisualSelection(cmd) | |
534 set nosmartindent | |
535 if mode() ==# "V" | |
536 return a:cmd . ":set smartindent\<CR>gv" | |
537 else | |
538 return a:cmd . ":set smartindent\<CR>" | |
539 endif | |
540 endfunction | |
541 | |
542 " Swap backticks and quotes | |
543 nnoremap ` ' | |
544 nnoremap ' ` | |
545 | |
546 " Open vimrc | |
547 nnoremap <leader>ve :e $MYVIMRC<CR> | |
548 nnoremap <leader>vs :so $MYVIMRC<CR> | |
549 | |
550 " Open dup in diffmode | |
551 nnoremap <leader>d :call OpenDup(@%)<CR> | |
552 | |
553 function! OpenDup(file) | |
554 let l:filename = a:file . ".dup" | |
555 execute 'vsplit' l:filename | |
556 windo diffthis | |
557 endfunction | |
558 | |
559 " Do not move on * | |
560 nnoremap <silent> * :let stay_star_view = winsaveview()<cr>*:call winrestview(stay_star_view)<cr> | |
561 | |
562 " Search for selected text, forwards or backwards. | |
563 vnoremap <silent> * :<C-U> | |
564 \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
565 \gvy/<C-R><C-R>=substitute( | |
566 \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
567 \gV:call setreg('"', old_reg, old_regtype)<CR> | |
568 vnoremap <silent> # :<C-U> | |
569 \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
570 \gvy?<C-R><C-R>=substitute( | |
571 \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
572 \gV:call setreg('"', old_reg, old_regtype)<CR> | |
573 | |
574 " nnoremap <F10> :botright copen<CR> | |
575 | |
576 xnoremap <silent> p p:if v:register == '"'<Bar>let @@=@0<Bar>endif<CR> | |
577 | |
578 " Error navigation | |
579 nnoremap <UP> :cprev<CR> | |
580 nnoremap <DOWN> :cnext<CR> | |
581 nnoremap <RIGHT> :cnf<CR> | |
582 nnoremap <LEFT> :cpf<CR> | |
583 | |
584 nnoremap <leader>y :ptjump <c-r><c-w><CR> | |
585 | |
586 function! ToggleDiff() | |
587 if &diff == 1 | |
588 windo diffoff | |
589 else | |
590 windo diffthis | |
591 endif | |
592 endfunction | |
593 nnoremap <leader>g :call ToggleDiff()<CR> | |
594 | |
595 if has('nvim') | |
596 tnoremap <space><esc> <C-\><C-n> | |
597 tnoremap <C-h> <C-\><C-n><C-w>h | |
598 tnoremap <C-j> <C-\><C-n><C-w>j | |
599 tnoremap <C-k> <C-\><C-n><C-w>k | |
600 tnoremap <C-l> <C-\><C-n><C-w>l | |
601 augroup enter_term | |
602 au! | |
603 au BufEnter * if &buftype == 'terminal' | :startinsert | endif | |
604 augroup END | |
605 endif | |
606 | |
607 " Open buffers, tags... in vertical splits | |
608 nnoremap <leader>b :vert sbuffer | |
609 nnoremap <leader>t :vert stjump | |
610 nnoremap <leader>f :vert sfind | |
611 | |
612 | |
613 " }}} | |
614 | |
615 " Functions {{{ | |
616 " When editing a file, always jump to the last known cursor position. | |
617 " Don't do it for commit messages, when the position is invalid, or when | |
618 " inside an event handler (happens when dropping a file on gvim). | |
619 autocmd BufReadPost * | |
620 \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | | |
621 \ exe "normal g`\"" | | |
622 \ endif | |
623 | |
624 " Thg mappings | |
625 function! s:HGhist(file) | |
626 if !empty(a:file) | |
627 let path = a:file | |
628 else | |
629 let path = expand('%') | |
630 endif | |
631 exec 'silent! !thg filelog ' . path . ' &' | |
632 endfunction | |
633 | |
634 command! -nargs=? -complete=file HGhist call s:HGhist(<q-args>) | |
635 | |
636 augroup focus_lost | |
637 au! | |
638 au FocusLost * if !&readonly | :wa | endif | |
639 augroup END | |
640 | |
641 augroup LuaHighlight | |
642 autocmd! | |
643 autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank() | |
644 augroup END | |
645 | |
646 " Resize splits after window resize {{{ | |
647 augroup vim_resize | |
648 au! | |
649 au VimResized * exe "normal! \<c-w>=" | |
650 augroup END | |
651 " }}} | |
652 | |
653 " Automatically reload vimrc when saving {{{ | |
654 augroup reload_vim | |
655 autocmd! | |
656 autocmd BufWritePost $MYVIMRC nested source $MYVIMRC | |
657 augroup END | |
658 " }}} | |
659 | |
660 " Reload diffs {{{ | |
661 augroup diff_files | |
662 au! | |
663 au BufWritePost * if &diff == 1 | diffupdate | endif | |
664 augroup END | |
665 " }}} | |
666 | |
667 " Custom folding by Steve Losh | |
668 function! MyFoldText() " {{{ | |
669 let line = getline(v:foldstart) | |
670 | |
671 let nucolwidth = &fdc + &number * &numberwidth | |
672 let windowwidth = winwidth(0) - nucolwidth - 3 | |
673 let foldedlinecount = v:foldend - v:foldstart | |
674 | |
675 " expand tabs into spaces | |
676 let onetab = strpart(' ', 0, &tabstop) | |
677 let line = substitute(line, '\t', onetab, 'g') | |
678 | |
679 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) | |
680 let fillcharcount = windowwidth - len(line) - len(foldedlinecount) | |
681 return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' | |
682 endfunction " }}} | |
683 set foldtext=MyFoldText() | |
684 set foldopen+=jump | |
685 | |
686 " Detect Filetype from content if file has no extension {{{ | |
687 augroup newFileDetection | |
688 au! | |
689 autocmd CursorMovedI * call CheckFileType() | |
690 augroup END | |
691 | |
692 function! CheckFileType() | |
693 if exists("b:countCheck") == 0 | |
694 let b:countCheck = 0 | |
695 endif | |
696 let b:countCheck += 1 | |
697 if &filetype == "" && b:countCheck > 20 && b:countCheck < 200 | |
698 filetype detect | |
699 " Delete the function if no filetype can be established, or the type has | |
700 " been found | |
701 elseif b:countCheck >= 200 || &filetype != "" | |
702 autocmd! newFileDetection | |
703 endif | |
704 endfunction | |
705 " }}} | |
706 | |
707 " Convert hex <-> decimal {{{ | |
708 command! -nargs=? -range Dec2hex call s:Dec2hex(<line1>, <line2>, '<args>') | |
709 function! s:Dec2hex(line1, line2, arg) range | |
710 if empty(a:arg) | |
711 if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' | |
712 let cmd = 's/\%V\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' | |
713 else | |
714 let cmd = 's/\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' | |
715 endif | |
716 try | |
717 execute a:line1 . ',' . a:line2 . cmd | |
718 catch | |
719 echo 'Error: No decimal number found' | |
720 endtry | |
721 else | |
722 echo printf('%x', a:arg + 0) | |
723 endif | |
724 endfunction | |
725 | |
726 command! -nargs=? -range Hex2dec call s:Hex2dec(<line1>, <line2>, '<args>') | |
727 function! s:Hex2dec(line1, line2, arg) range | |
728 if empty(a:arg) | |
729 if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' | |
730 let cmd = 's/\%V0x\x\+/\=submatch(0)+0/g' | |
731 else | |
732 let cmd = 's/0x\x\+/\=submatch(0)+0/g' | |
733 endif | |
734 try | |
735 execute a:line1 . ',' . a:line2 . cmd | |
736 catch | |
737 echo 'Error: No hex number starting "0x" found' | |
738 endtry | |
739 else | |
740 echo (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0 | |
741 endif | |
742 endfunction | |
743 " }}} | |
744 | |
745 " Recognize filetype for dup files {{{ | |
746 autocmd! BufRead *.dup call DupSetSyntax(@%) | |
747 | |
748 function! DupSetSyntax(name) | |
749 let extension = matchlist(a:name, '\v.+.\.([^\.]+).dup')[1] | |
750 if extension == "vhd" | |
751 setlocal filetype=vhdl | |
752 elseif extension == "v" | |
753 setlocal filetype=verilog | |
754 elseif extension == "sv" | |
755 setlocal filetype=verilog | |
756 else | |
757 echo "Unknown filetype" | |
758 endif | |
759 endfunction | |
760 " }}} | |
761 | |
762 " Create arguments list from files in quickfix list | |
763 " Allows to Grep for a pattern and apply an argdo command on each of the | |
764 " matching files {{{ | |
765 command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames() | |
766 function! QuickfixFilenames() | |
767 " Building a hash ensures we get each buffer only once | |
768 let buffer_numbers = {} | |
769 for quickfix_item in getqflist() | |
770 let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr']) | |
771 endfor | |
772 return join(map(values(buffer_numbers), 'fnameescape(v:val)')) | |
773 endfunction | |
774 "}}} | |
775 | |
776 augroup mark_files | |
777 au! | |
778 au BufLeave test.tcl mark T | |
779 au BufLeave case.do mark C | |
780 au BufLeave drv_*.tcl mark D | |
781 au BufLeave *.rtl.vhd mark R | |
782 augroup END | |
783 | |
784 | |
785 " Toggle between opening/closing the quickfix window {{{ | |
786 function! GetBufferList() | |
787 redir =>buflist | |
788 silent! ls! | |
789 redir END | |
790 return buflist | |
791 endfunction | |
792 | |
793 function! ToggleList(bufname, pfx) | |
794 let buflist = GetBufferList() | |
795 for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))') | |
796 if bufwinnr(bufnum) != -1 | |
797 exec(a:pfx.'close') | |
798 return | |
799 endif | |
800 endfor | |
801 if a:pfx == 'l' && len(getloclist(0)) == 0 | |
802 echohl ErrorMsg | |
803 echo "Location List is Empty." | |
804 return | |
805 endif | |
806 let winnr = winnr() | |
807 exec('botright '.a:pfx.'open') | |
808 if winnr() != winnr | |
809 wincmd p | |
810 endif | |
811 endfunction | |
812 | |
813 nnoremap <silent> <F10> :call ToggleList("Quickfix List", 'c')<CR> | |
814 " }}} | |
815 | |
816 | |
817 " Make list-like commands more intuitive {{{ | |
818 " Copied from https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86 | |
819 function! CCR() | |
820 let cmdline = getcmdline() | |
821 if cmdline =~ '\v\C^(ls|files|buffers)' | |
822 " like :ls but prompts for a buffer command | |
823 return "\<CR>:b" | |
824 elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$' | |
825 " like :g//# but prompts for a command | |
826 return "\<CR>:" | |
827 elseif cmdline =~ '\v\C^(dli|il)' | |
828 " like :dlist or :ilist but prompts for a count for :djump or :ijump | |
829 return "\<CR>:" . cmdline[0] . "j " . split(cmdline, " ")[1] . "\<S-Left>\<Left>" | |
830 elseif cmdline =~ '\v\C^(cli|lli)' | |
831 " like :clist or :llist but prompts for an error/location number | |
832 return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>" | |
833 elseif cmdline =~ '\C^old' | |
834 " like :oldfiles but prompts for an old file to edit | |
835 set nomore | |
836 return "\<CR>:sil se more|e #<" | |
837 elseif cmdline =~ '\C^changes' | |
838 " like :changes but prompts for a change to jump to | |
839 set nomore | |
840 return "\<CR>:sil se more|norm! g;\<S-Left>" | |
841 elseif cmdline =~ '\C^ju' | |
842 " like :jumps but prompts for a position to jump to | |
843 set nomore | |
844 return "\<CR>:sil se more|norm! \<C-o>\<S-Left>" | |
845 elseif cmdline =~ '\C^marks' | |
846 " like :marks but prompts for a mark to jump to | |
847 return "\<CR>:norm! `" | |
848 elseif cmdline =~ '\C^undol' | |
849 " like :undolist but prompts for a change to undo | |
850 return "\<CR>:u " | |
851 else | |
852 return "\<CR>" | |
853 endif | |
854 endfunction | |
855 cnoremap <expr> <CR> CCR() | |
856 " }}} | |
857 | |
858 " Text objects {{{ | |
859 function! s:inIndentation() | |
860 " select all text in current indentation level excluding any empty lines | |
861 " that precede or follow the current indentationt level; | |
862 " | |
863 " the current implementation is pretty fast, even for many lines since it | |
864 " uses "search()" with "\%v" to find the unindented levels | |
865 " | |
866 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
867 " then the entire buffer will be selected | |
868 " | |
869 " WARNING: python devs have been known to become addicted to this | |
870 " magic is needed for this | |
871 let l:magic = &magic | |
872 set magic | |
873 | |
874 " move to beginning of line and get virtcol (current indentation level) | |
875 " BRAM: there is no searchpairvirtpos() ;) | |
876 normal! ^ | |
877 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
878 | |
879 " pattern matching anything except empty lines and lines with recorded | |
880 " indentation level | |
881 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
882 | |
883 " find first match (backwards & don't wrap or move cursor) | |
884 let l:start = search(l:pat, 'bWn') + 1 | |
885 | |
886 " next, find first match (forwards & don't wrap or move cursor) | |
887 let l:end = search(l:pat, 'Wn') | |
888 | |
889 if (l:end !=# 0) | |
890 " if search succeeded, it went too far, so subtract 1 | |
891 let l:end -= 1 | |
892 endif | |
893 | |
894 " go to start (this includes empty lines) and--importantly--column 0 | |
895 execute 'normal! '.l:start.'G0' | |
896 | |
897 " skip empty lines (unless already on one .. need to be in column 0) | |
898 call search('^[^\n\r]', 'Wc') | |
899 | |
900 " go to end (this includes empty lines) | |
901 execute 'normal! Vo'.l:end.'G' | |
902 | |
903 " skip backwards to last selected non-empty line | |
904 call search('^[^\n\r]', 'bWc') | |
905 | |
906 " go to end-of-line 'cause why not | |
907 normal! $o | |
908 | |
909 " restore magic | |
910 let &magic = l:magic | |
911 endfunction | |
912 | |
913 " "in indentation" (indentation level sans any surrounding empty lines) | |
914 xnoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
915 onoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
916 | |
917 function! s:aroundIndentation() | |
918 " select all text in the current indentation level including any emtpy | |
919 " lines that precede or follow the current indentation level; | |
920 " | |
921 " the current implementation is pretty fast, even for many lines since it | |
922 " uses "search()" with "\%v" to find the unindented levels | |
923 " | |
924 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
925 " then the entire buffer will be selected | |
926 " | |
927 " WARNING: python devs have been known to become addicted to this | |
928 | |
929 " magic is needed for this (/\v doesn't seem work) | |
930 let l:magic = &magic | |
931 set magic | |
932 | |
933 " move to beginning of line and get virtcol (current indentation level) | |
934 " BRAM: there is no searchpairvirtpos() ;) | |
935 normal! ^ | |
936 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
937 | |
938 " pattern matching anything except empty lines and lines with recorded | |
939 " indentation level | |
940 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
941 | |
942 " find first match (backwards & don't wrap or move cursor) | |
943 let l:start = search(l:pat, 'bWn') + 1 | |
944 | |
945 " NOTE: if l:start is 0, then search() failed; otherwise search() succeeded | |
946 " and l:start does not equal line('.') | |
947 " FORMER: l:start is 0; so, if we add 1 to l:start, then it will match | |
948 " everything from beginning of the buffer (if you don't like | |
949 " this, then you can modify the code) since this will be the | |
950 " equivalent of "norm! 1G" below | |
951 " LATTER: l:start is not 0 but is also not equal to line('.'); therefore, | |
952 " we want to add one to l:start since it will always match one | |
953 " line too high if search() succeeds | |
954 | |
955 " next, find first match (forwards & don't wrap or move cursor) | |
956 let l:end = search(l:pat, 'Wn') | |
957 | |
958 " NOTE: if l:end is 0, then search() failed; otherwise, if l:end is not | |
959 " equal to line('.'), then the search succeeded. | |
960 " FORMER: l:end is 0; we want this to match until the end-of-buffer if it | |
961 " fails to find a match for same reason as mentioned above; | |
962 " again, modify code if you do not like this); therefore, keep | |
963 " 0--see "NOTE:" below inside the if block comment | |
964 " LATTER: l:end is not 0, so the search() must have succeeded, which means | |
965 " that l:end will match a different line than line('.') | |
966 | |
967 if (l:end !=# 0) | |
968 " if l:end is 0, then the search() failed; if we subtract 1, then it | |
969 " will effectively do "norm! -1G" which is definitely not what is | |
970 " desired for probably every circumstance; therefore, only subtract one | |
971 " if the search() succeeded since this means that it will match at least | |
972 " one line too far down | |
973 " NOTE: exec "norm! 0G" still goes to end-of-buffer just like "norm! G", | |
974 " so it's ok if l:end is kept as 0. As mentioned above, this means | |
975 " that it will match until end of buffer, but that is what I want | |
976 " anyway (change code if you don't want) | |
977 let l:end -= 1 | |
978 endif | |
979 | |
980 " finally, select from l:start to l:end | |
981 execute 'normal! '.l:start.'G0V'.l:end.'G$o' | |
982 | |
983 " restore magic | |
984 let &magic = l:magic | |
985 endfunction | |
986 | |
987 " "around indentation" (indentation level and any surrounding empty lines) | |
988 xnoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
989 onoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
990 " }}} | |
991 " }}} | |
992 | |
993 " Filetype specific settings {{{ | |
994 " Latex {{{ | |
995 " Open pdf | |
996 | |
997 function! Latexprog() | |
998 if !filereadable("./Makefile") | |
999 setlocal makeprg=latexmk\ -interaction=nonstopmode\ -synctex=1\ -file-line-error\ -pdf\ %:r | |
1000 endif | |
1001 endfunction | |
1002 | |
1003 augroup latex | |
1004 autocmd! | |
1005 autocmd FileType tex call Latexprog() | |
1006 au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb | |
1007 au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0 | |
1008 augroup END | |
1009 " }}} | |
1010 " Markdown {{{ | |
1011 let g:vim_markdown_folding_disabled=1 | |
1012 " }}} | |
1013 " Text {{{ | |
1014 augroup ft_text | |
1015 au! | |
1016 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb | |
1017 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 | |
1018 augroup END | |
1019 augroup ft_report | |
1020 au! | |
1021 au BufNewFile,BufRead,BufEnter *.rpt setlocal nowrap | |
1022 au BufNewFile,BufRead,BufEnter *.rpt call ColorRpt() | |
1023 au BufNewFile,BufRead,BufEnter *.log call ColorRpt() | |
1024 augroup END | |
1025 | |
1026 function! ColorRpt() | |
1027 " Color numbers based on length | |
1028 syn match String "\v<\d{1,3}>" | |
1029 syn match Number "\v<\d{4,6}>" | |
1030 syn match Statement "\v<\d{7,9}>" | |
1031 | |
1032 " Color errors | |
1033 syn match Error "\v^ERROR:.*$" | |
1034 endfunction | |
1035 " }}} | |
1036 " Git commit messages {{{ | |
1037 augroup ft_git | |
1038 au! | |
1039 au FileType gitcommit setlocal spell spelllang=en_gb | |
1040 augroup END | |
1041 " }}} | |
1042 " Ruby {{{ | |
1043 augroup ft_ruby | |
1044 au! | |
1045 autocmd BufRead *_spec.rb set filetype=rspec | |
1046 augroup END | |
1047 " }}} | |
1048 " Matlab {{{ | |
1049 augroup ft_matlab | |
1050 au! | |
1051 autocmd FileType matlab setlocal commentstring=\%\ %s | |
1052 augroup END | |
1053 " }}} | |
1054 " C {{{ | |
1055 augroup ft_c | |
1056 au! | |
1057 au FileType c setlocal foldmethod=syntax | |
1058 augroup END | |
1059 " }}} | |
1060 " VHDL {{{ | |
1061 " VHDL ctags | |
1062 let g:tlist_vhdl_settings = 'vhdl;d:package declarations;b:package bodies;e:entities;a:architecture specifications;t:type declarations;p:processes;f:functions;r:procedures' | |
1063 let g:vhdl_indent_genportmap =0 | |
1064 let g:vhdl_indent_rhassign = 1 | |
1065 | |
1066 augroup ft_vhdl | |
1067 au! | |
1068 autocmd FileType vhdl call VHDLColonAlign() | |
1069 augroup END | |
1070 | |
1071 function! SetAutoAlign() | |
1072 inoremap <silent> => =><ESC>mzvip:EasyAlign/=>/<CR>`z$a | |
1073 endfunction | |
1074 | |
1075 function! VHDLChipScopeMacro() | |
1076 let @c = "mtyiw'Sosignal \"_cs : std_logic;'Coattribute mark_debug of \"_cs : signal is \"true\"; | |
1077 attribute dont_touch of \"_cs : signal is \"true\";'Do\"_cs <= \";=='t" | |
1078 endfunction | |
1079 | |
1080 function! VHDLColonAlign() | |
1081 let g:easy_align_delimiters = { | |
1082 \ ':': { 'pattern': ':', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0} | |
1083 \} | |
1084 endfunction | |
1085 " }}} | |
1086 " TCL {{{ | |
1087 | |
1088 augroup ft_tcl | |
1089 au! | |
1090 autocmd FileType tcl setlocal commentstring=#\ %s | |
1091 " autocmd FileType tcl compiler nagelfar | |
1092 autocmd BufRead *.do set filetype=tcl | |
1093 autocmd BufRead *.hal set filetype=tcl | |
1094 autocmd FileType tcl setlocal iskeyword+=: | |
1095 autocmd FileType tcl setlocal breakat-=: | |
1096 autocmd FileType tcl setlocal suffixesadd+=.tcl,.do | |
1097 augroup END | |
1098 " shortcuts | |
1099 iabbrev procargs array set arg [::argument_processing::proces_arguments $args]; | |
1100 " }}} | |
1101 " GPG {{{ | |
1102 " Don't save backups of gpg asc files | |
1103 set backupskip+=*.asc | |
1104 | |
1105 " Convenient editing of ascii-armoured encrypted files | |
1106 augroup GPGASCII | |
1107 au! | |
1108 au BufReadPost *.asc :%!gpg -q -d | |
1109 au BufReadPost *.asc |redraw | |
1110 au BufWritePre *.asc :%!gpg -q -e -a | |
1111 au BufWritePost *.asc u | |
1112 au VimLeave *.asc :!clear | |
1113 augroup END | |
1114 " }}} | |
1115 " System Verilog {{{ | |
1116 augroup ft_systemverilog | |
1117 au! | |
1118 au FileType systemverilog setlocal suffixesadd+=.sv,.v | |
1119 au FileType systemverilog setlocal foldmethod=marker | |
1120 au FileType systemverilog,verilog call SVAlign() | |
1121 au FileType systemverilog,verilog let b:delimitMate_quotes = "\" '" | |
1122 augroup END | |
1123 | |
1124 function! SVAlign() | |
1125 let g:easy_align_delimiters = { | |
1126 \ ')': { 'pattern': '[()]', 'left_margin': 0, 'right_margin': 0, 'stick_to_left': 0} | |
1127 \} | |
1128 endfunction | |
1129 " }}} | |
1130 " Make {{{ | |
1131 augroup ft_make | |
1132 autocmd! | |
1133 autocmd BufEnter *.make setlocal filetype=make | |
1134 autocmd FileType make setlocal noexpandtab | |
1135 augroup END | |
1136 " JSON {{{ | |
1137 augroup ft_json | |
1138 autocmd! | |
1139 autocmd FileType json setlocal equalprg=jq | |
1140 augroup END | |
1141 " }}} | |
1142 " }}} | |
1143 " Python {{{ | |
1144 augroup f_python | |
1145 autocmd! | |
1146 autocmd FileType python setlocal shiftwidth=4 | |
1147 au FileType python setlocal formatprg=autopep8\ - | |
1148 autocmd FileType python setlocal path-=** | |
1149 augroup END | |
1150 lua << EOF | |
1151 vim.lsp.set_log_level("debug") | |
1152 EOF | |
1153 lua << EOF | |
1154 require'nvim_lsp'.pyls.setup{ | |
1155 cmd = {"pyls"}, | |
1156 on_attach = require'on_attach'.on_attach | |
1157 } | |
1158 EOF | |
1159 | |
1160 let g:python_highlight_all=1 | |
1161 " }}} | |
1162 " }}} | |
1163 | |
1164 " Plugin settings {{{ | |
1165 " Easy-align {{{ | |
1166 " Start interactive EasyAlign in visual mode (e.g. vip<Enter>) | |
1167 vmap <Enter> <Plug>(EasyAlign) | |
1168 | |
1169 " Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
1170 nmap ga <Plug>(EasyAlign) | |
1171 " }}} | |
1172 " Gundo tree {{{ | |
1173 nnoremap <leader>u :GundoToggle<CR> | |
1174 " }}} | |
1175 " Projectionist {{{ | |
1176 let g:projectionist_heuristics = { | |
1177 \ "*.c": { | |
1178 \ "*.c": { | |
1179 \ "alternate": "{}.h", | |
1180 \ "type": "source", | |
1181 \ "template": ["#include \"{}.h\""], | |
1182 \ "make": "make -wC {project}" | |
1183 \ }, | |
1184 \ "*.h": { | |
1185 \ "alternate": "{}.c", | |
1186 \ "type": "header", | |
1187 \ "template": ["#ifndef {uppercase}_H", "#define {uppercase}_H", "", "#endif"] | |
1188 \ }, | |
1189 \ "Makefile": {"type": "makefile"}, | |
1190 \ }, | |
1191 \ "*.py": { | |
1192 \ "*.py": { "make": "ipython {}" } | |
1193 \ }, | |
1194 \ } | |
1195 " }}} | |
1196 " Grep {{{ | |
1197 let g:grepper = { | |
1198 \ 'tools': ['ag', 'hg'], | |
1199 \ 'highlight': 1, | |
1200 \ 'ag': { | |
1201 \ 'grepprg': 'rg --vimgrep', | |
1202 \ }} | |
1203 | |
1204 nnoremap gs <plug>(GrepperOperator) | |
1205 xnoremap gs <plug>(GrepperOperator) | |
1206 | |
1207 | |
1208 command! -nargs=* -complete=file Ag Grepper -noprompt -tool ag -grepprg rg --vimgrep <args> | |
1209 " }}} | |
1210 " Vinegar/NetRW {{{ | |
1211 autocmd FileType netrw setl bufhidden=delete | |
1212 " }}} | |
1213 " NCM {{{ | |
1214 function! s:check_back_space() abort | |
1215 let col = col('.') - 1 | |
1216 return !col || getline('.')[col - 1] =~# '\s' | |
1217 endfunction | |
1218 | |
1219 " inoremap <silent><expr> <TAB> | |
1220 " \ pumvisible() ? "\<C-n>" : | |
1221 " \ <SID>check_back_space() ? "\<TAB>" : | |
1222 " \ coc#refresh() | |
1223 " inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
1224 " " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
1225 " " Coc only does snippet and additional edit on confirm. | |
1226 " inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
1227 " " Or use `complete_info` if your vim support it, like: | |
1228 " " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
1229 " autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif | |
1230 " Use <Tab> and <S-Tab> to navigate through popup menu | |
1231 " inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
1232 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
1233 | |
1234 " Auto close popup menu when finish completion | |
1235 autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif | |
1236 inoremap <silent><expr> <TAB> | |
1237 \ pumvisible() ? "\<C-n>" : | |
1238 \ <SID>check_back_space() ? "\<TAB>" : | |
1239 \ completion#trigger_completion() | |
1240 | |
1241 let g:completion_enable_snippet = 'UltiSnips' | |
1242 "Fallback for https://github.com/Raimondi/delimitMate expanding on enter | |
1243 let g:completion_confirm_key_rhs = "\<Plug>delimitMateCR" | |
1244 let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
1245 let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
1246 " }}} | |
1247 " Background make {{{ | |
1248 nnoremap <F9> :PMake<CR> | |
1249 " }}} | |
1250 " LanguageClient {{{ | |
1251 nmap <silent> gd <Plug>(coc-definition) | |
1252 nmap <silent> gy <Plug>(coc-type-definition) | |
1253 nmap <silent> gi <Plug>(coc-implementation) | |
1254 nmap <silent> gr <Plug>(coc-references) | |
1255 | |
1256 " Use K to show documentation in preview window | |
1257 nnoremap <silent> K :call <SID>show_documentation()<CR> | |
1258 | |
1259 function! s:show_documentation() | |
1260 if (index(['vim','help'], &filetype) >= 0) | |
1261 execute 'h '.expand('<cword>') | |
1262 else | |
1263 call CocAction('doHover') | |
1264 endif | |
1265 endfunction | |
1266 " }}} | |
1267 " Splice {{{ | |
1268 let g:splice_initial_diff_grid=1 | |
1269 let g:splice_initial_diff_compare=1 | |
1270 let g:splice_initial_diff_path=0 | |
1271 let g:splice_initial_scrollbind_grid=1 | |
1272 let g:splice_initial_scrollbind_compare=1 | |
1273 let g:splice_initial_scrollbind_path=1 | |
1274 let g:splice_wrap="nowrap" | |
1275 " }}} | |
1276 " Chipscoper {{{ | |
1277 nnoremap <leader>cm :call ChipScoperMark()<CR> | |
1278 nnoremap <leader>ci :call ChipScoperInsert()<CR> | |
1279 nnoremap <leader>cd :call ChipScoperUnMark()<CR> | |
1280 augroup cs_vhdl | |
1281 autocmd! | |
1282 autocmd FileType vhdl packadd chipscoper | |
1283 autocmd FileType vhdl silent! call ChipScoperSetup() | |
1284 augroup END | |
1285 " }}} | |
1286 " GDB {{{ | |
1287 let g:nvimgdb_disable_start_keymaps = 1 | |
1288 " }}} | |
1289 " context {{{ | |
1290 let g:context_enabled = 0 | |
1291 " }}} | |
1292 " ALE {{{ | |
1293 let g:ale_virtualtext_cursor=1 | |
274
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1294 " augroup fmt |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1295 " autocmd! |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1296 " autocmd BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1297 " augroup END |
273 | 1298 " }}} |
1299 " }}} | |
1300 | |
1301 function! SendOSCClipboard(lines, regtype) | |
1302 call SendViaOSC52(join(a:lines, "\n")) | |
1303 endfunction | |
1304 | |
1305 let g:clipboard = { | |
1306 \ 'name': 'TMUX', | |
1307 \ 'copy': { | |
1308 \ '+': function('SendOSCClipboard'), | |
1309 \ '*': 'tmux load-buffer -', | |
1310 \ }, | |
1311 \ 'paste': { | |
1312 \ '+': 'tmux save-buffer -', | |
1313 \ '*': 'tmux save-buffer -', | |
1314 \ }, | |
1315 \ 'cache_enabled': 1, | |
1316 \ } | |
1317 | |
1318 " Load local vimrc | |
1319 if filereadable($HOME . '/.vimrc.local') | |
1320 source ~/.vimrc.local | |
1321 endif | |
1322 | |
1323 " Load project local vimrc | |
1324 if filereadable('.vimrc.local') | |
1325 source .vimrc.local | |
1326 endif |