]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/vim/syntastic.vim
courge: update to nixos-24.05
[julm/julm-nix.git] / home-manager / profiles / vim / syntastic.vim
1 let g:syntastic_haskell_checkers = ['hdevtools', 'hlint']
2 let g:syntastic_aggregate_errors = 0
3 let g:syntastic_warning_symbol = "⚠"
4 let g:syntastic_error_symbol = "✗"
5 let g:syntastic_enable_signs = 1
6 let g:syntastic_enable_balloons = 1
7 let g:syntastic_enable_highlighting = 1
8 let g:syntastic_auto_jump = 3
9 let g:syntastic_auto_loc_list = 1
10 "let g:syntastic_haskell_ghc_mod_exec = $HOME.'/bin/ghc-mod.sh'
11 let g:syntastic_xml_checkers = ['xml_model']
12 let g:syntastic_xml_xml_model_exec = $HOME.'/bin/check-xml-model'
13 "set statusline+=%#warningmsg#
14 "set statusline+=%{SyntasticStatuslineFlag()}
15 "set statusline^=%{LanguageClient_statusLine()}
16 "set statusline+=%*
17 hi SyntasticWarning ctermbg=5 ctermfg=0
18 hi SyntasticWarningSign ctermbg=5 ctermfg=0
19 " Toggle off Syntastic if there is a single Haskell file,
20 " since using ghci is quicker when tests must also be run.
21 " Note that the filetype is not already set at this point,
22 " hence the match on the buffer's name.
23 autocmd VimEnter * if match(map(getbufinfo(), "v:val.name"), '\.hs$') != -1
24 \ | silent SyntasticToggleMode
25 \ | endif
26
27 let g:syntastic_always_populate_loc_list = 1
28 let g:syntastic_auto_loc_list = 1
29 let g:syntastic_check_on_open = 0
30 let g:syntastic_check_on_wq = 0
31 let g:syntastic_debug = 0
32 let g:syntastic_enable_highlighting = 1
33
34 function! CabalCargs(args)
35 let l:output = system('cabal-cargs ' . a:args)
36 if v:shell_error != 0
37 let l:lines = split(l:output, '\n')
38 echohl ErrorMsg
39 echomsg 'args: ' . a:args
40 for l:line in l:lines
41 echomsg l:line
42 endfor
43 echohl None
44 return ''
45 else
46 endif
47 return l:output
48 endfunction
49 let g:cabalcargs_options = ''
50 function! HdevtoolsOptions()
51 let l:args = CabalCargs('--format=hdevtools --sourcefile=' . shellescape(expand('%')) . ' ' . get(g:, 'cabalcargs_options', ''))
52 if l:args != ''
53 return l:args
54 else
55 let l:output = system('stack path --snapshot-pkg-db')
56 if v:shell_error == 0
57 " NOTE: when the "stack script" header is used
58 " there is no often associated .cabal file,
59 " passing a -g-package-db to stack's --snapshot-pkg-db
60 " may help hdevtools to find required packages.
61 return ' -g-package-db='.split(l:output, '\n')[0]
62 else return ''
63 endif
64 endif
65 endfunction
66 function! s:HlintOptions()
67 return CabalCargs('--format=ghc --only=default_extensions --sourcefile=' . shellescape(expand('%')))
68 endfunction
69 function! InitHaskellVars()
70 if filereadable(expand('%')) && expand('%:t') != 'HLint.hs'
71 let g:syntastic_haskell_hdevtools_args = HdevtoolsOptions() . ' -g-fno-warn-tabs'
72 let g:hdevtools_options = '-g-XDatatypeContexts' . ' ' . get(g:, 'syntastic_haskell_hdevtools_args', '')
73 " NOTE: DatatypeContexts is deprecated,
74 " but running "hdevtools type" may fail by saying it requires it.
75 let g:syntastic_haskell_hlint_args = s:HlintOptions() . '-i"Use camelCase"'
76 let g:hlint_options = get(g:, 'syntastic_haskell_hlint_args', '')
77 endif
78 endfunction
79 au FileType haskell :call InitHaskellVars()
80 " hdevtools
81 "au FileType haskell nmap <buffer> <F1> :HdevtoolsType<CR>
82 "au FileType haskell nmap <buffer> <silent> <F2> :HdevtoolsClear<CR>
83 "au FileType haskell nmap <buffer> <silent> <F3> :HdevtoolsInfo<CR>