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