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