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