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