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