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