]> Git — Sourcephile - julm/julm-nix.git/blob - homes/softwares/vim/vimrc
dnscrypt-proxy2: fix SystemCallFilter
[julm/julm-nix.git] / homes / softwares / vim / vimrc
1 " vim: ft=vim
2 if has("nvim")
3 autocmd! BufWritePost,BufEnter * Neomake
4 endif
5
6 hi Comment ctermfg=black ctermbg=NONE cterm=bold
7 "hi Comment ctermfg=darkgray cterm=bold
8 hi Conceal ctermfg=black ctermbg=NONE cterm=bold
9 hi CursorLine cterm=none guibg=NONE
10 hi CursorLineNr ctermfg=white cterm=NONE
11 hi FoldColumn ctermfg=black ctermbg=none cterm=bold
12 hi Folded ctermfg=black ctermbg=NONE cterm=bold
13 hi LineNr ctermfg=black ctermbg=none cterm=bold
14 hi Pmenu ctermbg=magenta ctermfg=black
15 hi PmenuSel ctermbg=darkmagenta ctermfg=black
16 hi PmenuSbar ctermfg=gray ctermbg=black
17 hi PmenuThumb ctermfg=white
18 hi Search ctermfg=black ctermbg=yellow
19 hi SignColumn ctermbg=black
20 hi SpecialKey ctermfg=black cterm=bold
21 hi StatusLine term=bold,reverse ctermfg=white ctermbg=blue cterm=none
22 hi StatusLineNC term=reverse ctermfg=blue ctermbg=none cterm=underline
23 hi Visual ctermfg=black ctermbg=yellow cterm=none
24 hi WarningMsg ctermbg=darkyellow ctermfg=white
25 au FileType xml hi xmlAttrib ctermfg=green
26 au FileType xslt hi xmlNamespace ctermfg=red
27 au FileType xslt hi xmlAttrib ctermfg=green
28 au FileType * hi Special ctermfg=red
29 "au FileType haskell hi Comment ctermfg=DarkGreen
30 au FileType haskell hi Identifier ctermfg=LightGray
31
32 " Search term under cursor
33 nmap <silent> * :set hls<CR>:let @/="\\<<C-r><C-w>\\>"<CR>/<BS>
34 nmap <silent> <C-n> :set hls<CR>:call Vimgrepbuffers('\<' . expand('<cword>') . '\>')<CR>
35 " Search subterm under cursor
36 nmap <silent> µ :set hls<CR>:let @/="<C-r><C-w>"<CR>/<BS>
37 nmap <silent> <C-m> :set hls<CR>:call Vimgrepbuffers(expand('<cword>'))<CR>
38
39 fun! Vimgrepbuffers(pattern)
40 exe 'vimgrep /' . a:pattern . '/g ' . getbufinfo({'buflisted': 1})->map({_,b -> fnameescape(b.name)})->join(' ')
41 let @/ = a:pattern
42 let l:winnr = winnr()
43 cwindow 3
44 " If focus changed, restore it (jump to the last window).
45 if l:winnr isnot# winnr()
46 wincmd p
47 endif
48 endfun
49 command! -nargs=1 G set hls | call Vimgrepbuffers(<f-args>)
50
51 " Navigation
52 nmap i gk
53 nmap k gj
54 nmap j <Left>
55 nmap l <Right>
56 xmap i gk
57 xmap k gj
58 xmap j <Left>
59 xmap l <Right>
60
61 nmap K :join<CR>
62 nmap J <Home>
63 nmap L <End>
64 nmap m :buffer
65
66 " Maintain Visual Mode after shifting > and <
67 vmap < <gv
68 vmap > >gv
69
70 " Move visual block
71 vmap I :m '<-2<CR>gv=gv
72 vmap K :m '>+1<CR>gv=gv
73
74 if &term =~ '^screen'
75 " Fix <Home>, <End>, <C-Left>, etc. when vim is in tmux;
76 " tmux will send xterm-style keys when xterm-keys is on
77 execute "set <xHome>=\e[7~"
78 execute "set <xEnd>=\e[8~"
79 execute "set <xRight>=\e[1;*C"
80 execute "set <xLeft>=\e[1;*D"
81 execute "set <xUp>=\e[1;*A"
82 execute "set <xDown>=\e[1;*B"
83 endif
84
85 set autoindent
86 set background=dark
87 set breakindent
88 set cmdheight=1
89 set completeopt=menu,menuone,popup,longest
90 set conceallevel=0
91 set cpoptions+=M " ignore backslashes in % matching
92 set cursorline
93 silent !mkdir -p ~/.cache/vim/swap
94 set directory=$HOME/.cache/vim/swap
95 set diffopt=internal,filler,closeoff,algorithm:histogram,indent-heuristic
96 set encoding=utf-8
97 set expandtab
98 set foldcolumn=0
99 set foldenable
100 function! GetFoldExprFromIndent()
101 " Calcule l'indentation en fonction des tabulations
102 " et espaces au début des lignes
103 let line = getline(v:lnum)
104 let tabs = matchend(line,"^\t*")
105 let spaces = matchend(line,"^[ \t]*") - tabs
106 return tabs + ((spaces + 3) / 4)
107 endfunction
108 set foldexpr=GetFoldExprFromIndent()
109 set foldignore=
110 set foldlevelstart=99
111 set foldmethod=indent
112 set foldminlines=0
113 set hidden
114 set history=1042
115 set hlsearch
116 set incsearch
117 set laststatus=2
118 set lazyredraw
119 set linebreak
120 set list
121 set path=.,/usr/include,/usr/local/include,,
122 set scroll=0
123 set scrolloff=10
124 set sidescroll=0
125 set sidescrolloff=0
126 set signcolumn=yes
127 set shortmess+=A
128 set swapfile
129 let mapleader = ","
130 set matchpairs+=<:>
131 set maxmempattern=2000
132 set noautochdir
133 set nocompatible
134 set noerrorbells
135 set noignorecase
136 "set noloadplugins
137 set nosmartindent
138 set nowrapscan
139 set number
140 set ruler
141 "set runtimepath=$HOME/.vim,$VIMRUNTIME,$VIM
142 set sessionoptions=curdir,folds
143 set shiftwidth=2
144 set showcmd
145 set statusline=%f
146 "set statusline+=\ %l:%c
147 "set statusline=\ %{get(b:,'coc_current_function','')}
148 set statusline+=%=
149 "set statusline+=%#ErrorMsg#%{CocStatusDiagnosticError()}%*
150 "set statusline+=\ %{CocStatus()}
151 set statusline+=%{LinterStatus()}
152 set statusline+=\ %m%R\ %Y
153 set tabstop=2
154 set ttyfast
155 set undolevels=542
156 set updatetime=300
157 set verbose=0
158 silent !mkdir -p ~/.cache/vim/view
159 set viewdir=$HOME/.cache/vim/view
160 set viminfo+=n$HOME/.cache/vim/info
161 set visualbell
162 set visualbell t_vb=
163 set whichwrap+=<,>,[,]
164 set wildignore=*.a,*.d,*.o,*.so,*~,*.cmo,*.cmi,*.cmx,*.cmxs,*.cma,*.cmxa,*.byte,*.native,*.hi
165 set wildmenu
166 set wildmode=list:longest,full
167 set wrap
168 syntax on
169 " When editing a file, always jump to the last known cursor position.
170 " Don't do it when the position is invalid or when inside an event handler
171 " (happens when dropping a file on gvim).
172 autocmd BufReadPost *
173 \ if line("'\"") > 0 && line("'\"") <= line("$") |
174 \ exe "normal g`\"" |
175 \ endif
176 " Set screen title
177 if (&term == "screen" || &term == "screen.linux")
178 "set t_ts=\ek
179 "set t_fs=\e\
180 endif
181 if has("gui_running")
182 set title
183 set titlelen=0
184 set titlestring=VIM:\ %F\ %a%r%m
185 else
186 " Italic
187 set t_ZH=\e[3m
188 set t_ZR=\e[23m
189 " Underline
190 set t_us=\e[4m
191 set t_ue=\e[m
192 " Set window title
193 set t_ts=\e]0;
194 set t_fs=\a
195 "set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
196 auto BufEnter * :set title | let &titlestring = 'VIM: ' . expand('%:p')
197 "auto VimLeave * :set t_ts=\ek\e\
198 endif
199 let space = &shiftwidth == 0 ? &tabstop : &shiftwidth
200 if (&term == "linux" || &term == "screen.linux")
201 "set foldtext=substitute(getline(v\:foldstart),'^\\(\\s*\\)',{m->substitute(m[1],'\\('.repeat('\ ',&shiftwidth).'\\\|\\t\\)','\|'.repeat('.',&shiftwidth-1),'g')},'').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ '
202 "set fillchars=fold:_
203 set list listchars=nbsp:+,tab:\|.,trail:_,extends:>,precedes:<
204 set foldtext=getline(v\:foldstart).'\ \ ('.(v\:foldend-v\:foldstart+1).')\ '
205 else
206 "set foldtext=substitute(getline(v\:foldstart),'^\\(\\s*\\)',{m->substitute(m[1],'\\('.repeat('\ ',&shiftwidth).'\\\|\\t\\)','⎢'.repeat('·',&shiftwidth-1),'g')},'').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ '
207 "set fillchars=fold:·
208 set foldtext=getline(v\:foldstart).'\ \ ('.(v\:foldend-v\:foldstart+1).')\ '
209 set list listchars=nbsp:¬,tab:⎢·,trail:·,extends:>,precedes:<
210 endif
211
212 "let g:indentLine_char_list = ['⎢']
213 "" Concealed text is not highlighted by the visual mode, this is annoying.
214 ""let g:indentLine_concealcursor = 'incv'
215 "let g:indentLine_faster = 1
216 "let g:indentLine_first_char = '⎢'
217 "let g:indentLine_leadingSpaceChar = '·'
218 "let g:indentLine_leadingSpaceEnabled = 1
219 "let g:indentLine_showFirstIndentLevel = 1
220 "let g:indentLine_bgcolor_term = 'NONE'
221 "let g:indentLine_defaultGroup = 'Folded'
222
223 if (v:version >= 700)
224 hi TabLine term=bold,reverse ctermfg=white ctermbg=blue cterm=none
225 hi TabLineFill term=bold,reverse ctermfg=none ctermbg=blue cterm=none
226 hi TabLineSel term=reverse ctermfg=white ctermbg=none cterm=bold
227 imap <C-S-tab> <Esc>:tabprevious<CR>i
228 imap <C-t> <Esc>:tabnew<CR>
229 imap <C-tab> <Esc>:tabnext<CR>i
230 nmap <C-S-tab> :tabprevious<CR>
231 nmap <Esc><tab> :bnext<CR>
232 nmap <C-t> :tabnew<CR>
233 "nmap <C-tab> :tabprevious<CR>
234 "nmap <tab> :tabnext<CR>
235 nmap <C-tab> :bprevious!<CR>
236 nmap <tab> :bnext!<CR>
237 nmap td :tabclose<CR>
238 nmap ti :tabfirst<CR>
239 nmap tj :tabprev<CR>
240 nmap tk :tablast<CR>
241 nmap tl :tabnext<CR>
242 nmap tm :tabm<Space>
243 nmap tn :tabnew<Space>
244 nmap tt :tabedit<Space>
245 nmap <C-i> :bprevious!<CR>
246 nmap <C-k> :bnext!<CR>
247 nmap <C-j> :lprevious<CR>
248 nmap <C-l> :lnext<CR>
249 nmap <C-u> :cprevious<CR>
250 nmap <C-o> :cnext<CR>
251 nmap <C-w>k :wincmd j<CR>
252 nmap <C-w>i :wincmd k<CR>
253 nmap <C-w>j :wincmd h<CR>
254 nmap <C-w>l :wincmd l<CR>
255 set tabpagemax=1000
256 set sessionoptions+=tabpages
257 endif
258 if (v:version >= 704)
259 silent !mkdir -p ~/.cache/vim/undo
260 set undodir=~/.cache/vim/undo/
261 set undofile
262 autocmd BufWritePre /tmp/* setlocal noundofile
263 autocmd BufWritePre */sec/* setlocal noundofile
264 endif
265 fun! TrimWhitespace()
266 let l:save = winsaveview()
267 keeppatterns %s/\s\+$//e
268 call winrestview(l:save)
269 endfun
270 autocmd BufRead .envrc setfiletype sh
271 "autocmd BufRead *.hamlet setfiletype html
272 "autocmd BufRead *.julius setfiletype javascript
273 "autocmd BufRead *.lucius setfiletype css
274 autocmd BufRead *.ledger setfiletype ledger
275 autocmd BufRead *.lhs setfiletype haskell
276 autocmd BufRead HLint.hs setfiletype txt
277 autocmd BufRead *.purs
278 \ setfiletype purescript |
279 \ set syntax=haskell
280 "autocmd BufRead *.nix set syntax=zsh | set expandtab
281 autocmd BufNewFile,BufRead *.nix
282 \ hi nixAntiquotation ctermfg=cyan |
283 \ set expandtab |
284 \ set isk+=- |
285 \ set foldmethod=indent
286 autocmd BufWritePre *.nix :call TrimWhitespace()
287 autocmd BufNewFile,BufRead *.py
288 \ set noexpandtab |
289 \ set tabstop=2 |
290 \ set softtabstop=0
291 autocmd BufNewFile,BufRead *.hs set expandtab
292 autocmd BufNewFile,BufRead *.tct set filetype=tct | set expandtab
293 autocmd BufWritePost * if &diff == 1 | diffupdate | endif
294 augroup quickfix
295 autocmd!
296 autocmd FileType qf setlocal wrap
297 augroup END
298 " If doing a diff. Upon writing changes to file, automatically update the differences
299 """
300 """ plugins
301 """
302 " matchit
303 let b:match_words = '«:»,“:”'
304 " easy_align
305 nmap <Leader>a <Plug>(EasyAlign)
306 vmap <Enter> <Plug>(EasyAlign)
307 let g:easy_align_ignore_groups = ['Comment', 'String', 'ledgerTransaction', 'ledgerTag', 'jccComment', 'jccTransaction']
308 " netrw
309 let g:netrw_liststyle = 3
310 "let g:netrw_cursorline = 0
311 let s:netrw_usercul = 0
312 " NERD_tree
313 " buffergator
314 let g:buffergator_display_regime = "bufname"
315 let g:buffergator_show_full_directory_path = 0
316 let g:buffergator_viewport_split_policy = 'R'
317 let g:buffergator_autoupdate = 1
318 let g:buffergator_autodismiss_on_select = 0
319 let g:buffergator_suppress_keymaps = 1
320 nmap <leader>bq :bp <BAR> bd #<CR>
321 "let g:buffergator_mru_cycle_loop = 1
322 nmap <leader>i :BuffergatorMruCyclePrev<cr>
323 nmap <leader>k :BuffergatorMruCycleNext<cr>
324 nmap <leader>bl :BuffergatorOpen<cr>
325 nmap <leader>T :enew<cr>
326 set cpoptions+=M " ignore backslashes in % matching
327 " TOHtml
328 let g:html_expand_tabs = 0
329 let g:html_ignore_conceal = 0
330 let g:html_ignore_folding = 1
331 let g:html_number_lines = 0
332 let g:html_use_xhtml = 0
333 " CtrlP
334 "map <C-p> :CtrlPBuffer<CR>
335 "let g:ctrlp_working_path_mode = 'c'
336 "let g:ctrlp_map = '<Leader>t'
337 "let g:ctrlp_match_window_bottom = 0
338 "let g:ctrlp_match_window_reversed = 0
339 "let g:ctrlp_custom_ignore = '\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py'
340 "let g:ctrlp_working_path_mode = 0
341 "let g:ctrlp_dotfiles = 0
342 "let g:ctrlp_switch_buffer = 0
343 " vimproc
344 " ghc-mod
345 "map <silent> tu :call GHC_BrowseAll()<CR>
346 "map <silent> tw :call GhcModType<CR>
347 map <silent> hc :GhcModTypeClear<CR>
348 map <silent> he :GhcModExpand<CR>
349 map <silent> hi :GhcModTypeInsert<CR>
350 map <silent> hs :GhcModSigCodegen<CR>
351 map <silent> hs :GhcModSplitFunCase<CR>
352 map <silent> ht :GhcModType<CR>
353 " vimBall
354 " AnsiEsc
355 " Hoogle
356 nmap <F5> :Hoogle <C-R><C-W><CR>
357 " TimeKeeper
358 "let g:TimeKeeperUpdateFileTimeSec = 5
359 ""let g:TimeKeeperStartOnLoad = 1
360 "let g:TimeKeeperUseFlatFile = 0
361 "nmap <silent> <F8> :call TimeKeeper_ToggleTaskWindow()<cr>
362 "call TimeKeeper_StartTracking()
363 " Recover
364 let g:RecoverPlugin_Delete_Unmodified_Swapfile = 1
365 " calendar-vim
366 let g:calendar_number_of_months = 1
367 let g:calendar_wruler = 'di lu ma me je ve sa'
368 let g:calendar_monday = 1
369 function MyCalAction(day,month,year,week,dir)
370 " day : day you actioned
371 " month : month you actioned
372 " year : year you actioned
373 " week : day of week (Mo=1 ... Su=7)
374 " dir : direction of calendar
375 endfunction
376 "let calendar_action = 'MyCalAction'
377 "hi link ALEError Error
378 "hi Warning term=underline cterm=underline ctermfg=Yellow gui=undercurl guisp=Gold
379 "hi link ALEWarning Warning
380 "hi link ALEInfo SpellCap
381 " echodoc
382 "let g:echodoc#enable_at_startup = 1
383 "let g:echodoc#type = 'signature'
384 " vim-gitgutter
385 "let g:gitgutter_grep = 'rg'
386 let g:gitgutter_grep = 'grep'
387 let g:gitgutter_diff_args = '--diff-algorithm=histogram'
388 let g:gitgutter_map_keys = 0
389 let g:gitgutter_sign_added = '+'
390 let g:gitgutter_sign_modified = '±'
391 let g:gitgutter_sign_modified_removed = '-'
392 let g:gitgutter_sign_removed = '_'
393 let g:gitgutter_sign_removed_first_line = '▔'
394 let g:gitgutter_sign_priority = 9
395 hi GitGutterAdd ctermfg=green
396 hi GitGutterDelete ctermfg=red
397 hi GitGutterChange ctermfg=yellow
398 hi GitGutterChangeDelete ctermfg=red
399 nmap [c <Plug>(GitGutterPrevHunk)
400 nmap ]c <Plug>(GitGutterNextHunk)
401 nmap <Leader>p <Plug>(GitGutterPreviewHunk)
402 nmap <Leader>+ <Plug>(GitGutterStageHunk)
403 nmap <Leader>- <Plug>(GitGutterUndoHunk)
404 " deoplete
405 "let g:deoplete#enable_at_startup = 1
406 "call deoplete#custom#option('sources', {
407 "\ '_': ['ale', 'buffer', 'around'],
408 "\})