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