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