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