/
ghcmod.vim
78 lines (67 loc) · 2.4 KB
/
ghcmod.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
if exists('b:did_ftplugin_ghcmod') && b:did_ftplugin_ghcmod
finish
endif
let b:did_ftplugin_ghcmod = 1
if !exists('s:has_vimproc')
try
call vimproc#version()
let s:has_vimproc = 1
catch /^Vim\%((\a\+)\)\=:E117/
let s:has_vimproc = 0
endtry
endif
if !s:has_vimproc
echohl ErrorMsg
echomsg 'ghcmod: vimproc.vim is not installed!'
echohl None
finish
endif
if !exists('s:has_ghc_mod')
let s:has_ghc_mod = 0
if !executable('ghc-mod')
call ghcmod#util#print_error('ghcmod: ghc-mod is not executable!')
finish
endif
let s:required_version = [2, 1, 2]
if !ghcmod#util#check_version(s:required_version)
call ghcmod#util#print_error(printf('ghcmod: requires ghc-mod %s or higher', join(s:required_version, '.')))
finish
endif
let s:has_ghc_mod = 1
endif
if !s:has_ghc_mod
finish
endif
if exists('b:undo_ftplugin')
let b:undo_ftplugin .= ' | '
else
let b:undo_ftplugin = ''
endif
command! -buffer -nargs=0 -bang GhcModType call ghcmod#command#type(<bang>0)
command! -buffer -nargs=0 -bang GhcModTypeInsert call ghcmod#command#type_insert(<bang>0)
command! -buffer -nargs=? -bang GhcModInfo call ghcmod#command#info(<q-args>, <bang>0)
command! -buffer -nargs=0 GhcModTypeClear call ghcmod#command#type_clear()
command! -buffer -nargs=? -bang GhcModInfoPreview call ghcmod#command#info_preview(<q-args>, <bang>0)
command! -buffer -nargs=0 -bang GhcModCheck call ghcmod#command#make('check', <bang>0)
command! -buffer -nargs=0 -bang GhcModLint call ghcmod#command#make('lint', <bang>0)
command! -buffer -nargs=0 -bang GhcModCheckAsync call ghcmod#command#async_make('check', <bang>0)
command! -buffer -nargs=0 -bang GhcModLintAsync call ghcmod#command#async_make('lint', <bang>0)
command! -buffer -nargs=0 -bang GhcModCheckAndLintAsync call ghcmod#command#check_and_lint_async(<bang>0)
command! -buffer -nargs=0 -bang GhcModExpand call ghcmod#command#expand(<bang>0)
let b:undo_ftplugin .= join(map([
\ 'GhcModType',
\ 'GhcModTypeInsert',
\ 'GhcModInfo',
\ 'GhcModInfoPreview',
\ 'GhcModTypeClear',
\ 'GhcModCheck',
\ 'GhcModLint',
\ 'GhcModCheckAsync',
\ 'GhcModLintAsync',
\ 'GhcModCheckAndLintAsync',
\ 'GhcModExpand'
\ ], '"delcommand " . v:val'), ' | ')
let b:undo_ftplugin .= ' | unlet b:did_ftplugin_ghcmod'
" Ensure syntax highlighting for ghcmod#detect_module()
syntax sync fromstart
" vim: set ts=2 sw=2 et fdm=marker: