File tree Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ if !exists('g:ghcmod_max_preview_size')
34
34
let g: ghcmod_max_preview_size = 10
35
35
endif
36
36
37
- command ! - buffer -nargs =0 GhcModType call s: echo ( ghcmod# type ()[ 1 ] )
38
- command ! - buffer -nargs =0 GhcModTypeInsert call ghcmod#type_insert ()
37
+ command ! - buffer -nargs =0 - bang GhcModType call s: type (<bang> 0 )
38
+ command ! - buffer -nargs =0 - bang GhcModTypeInsert call ghcmod#type_insert (<bang> 0 )
39
39
command ! - buffer -nargs =? GhcModInfo call s: echo (s: info (<q-args> ))
40
40
command ! - buffer -nargs =0 GhcModTypeClear call ghcmod#type_clear ()
41
41
command ! - buffer -nargs =? GhcModInfoPreview call ghcmod#preview (s: info (<q-args> ), g: ghcmod_max_preview_size )
@@ -69,6 +69,13 @@ function! s:echo(msg)
69
69
endif
70
70
endfunction
71
71
72
+ function ! s: type (force)
73
+ let l: type = ghcmod#type (a: force )[1 ]
74
+ if ! empty (l: type )
75
+ echo l: type
76
+ endif
77
+ endfunction
78
+
72
79
function ! s: make (type )
73
80
let l: qflist = ghcmod#make (a: type )
74
81
call setqflist (l: qflist )
Original file line number Diff line number Diff line change @@ -78,9 +78,15 @@ function! ghcmod#info(fexp)"{{{
78
78
return l: output
79
79
endfunction " }}}
80
80
81
- function ! ghcmod#type ()" {{{
81
+ function ! ghcmod#type (force )" {{{
82
82
if &l: modified
83
- call ghcmod#print_warning (' ghcmod#type: the buffer has been modified but not written' )
83
+ let l: msg = ' ghcmod#type: the buffer has been modified but not written'
84
+ if a: force
85
+ call ghcmod#print_warning (l: msg )
86
+ else
87
+ call ghcmod#print_error (l: msg )
88
+ return [' ' , ' ' ]
89
+ endif
84
90
endif
85
91
let l: line = line (' .' )
86
92
let l: col = col (' .' )
@@ -506,7 +512,7 @@ function! ghcmod#version()"{{{
506
512
return [0 , 3 , 0 ]
507
513
endfunction " }}}
508
514
509
- function ! ghcmod#type_insert () " {{{
515
+ function ! ghcmod#type_insert (force ) " {{{
510
516
let fexp = ghcmod#getHaskellIdentifier ()
511
517
if ! exists (' fexp' ) || fexp == ' '
512
518
call ghcmod#print_error (' Failed to determine identifier under cursor.' )
@@ -516,7 +522,7 @@ function! ghcmod#type_insert() "{{{
516
522
if exists (" b:ghcmod_type" )
517
523
unlet b: ghcmod_type " Make sure we aren't doing some weird persistence tricks
518
524
endif
519
- let [locsym, type ] = ghcmod#type ()
525
+ let [locsym, type ] = ghcmod#type (a: force )
520
526
call ghcmod#clear_highlight ()
521
527
if type == " " " Everything failed so let's just abort
522
528
return
Original file line number Diff line number Diff line change @@ -48,6 +48,21 @@ If you'd like to give GHC options, set |g:ghcmod_ghc_options|.
48
48
Sub-expressions are highlighted as | hl-Search | by default. You can
49
49
customize it by setting | g:ghcmod_type_highlight | .
50
50
51
+ If the current buffer is modified, this command is disabled.
52
+
53
+ :GhcModType! *:GhcModType!*
54
+ Same as | :GhcModType | , but this command is executed even if the
55
+ current buffer is modified.
56
+
57
+ :GhcModTypeInsert *:GhcModTypeInsert*
58
+ Insert a type signature under the cursor.
59
+
60
+ If the current buffer is modified, this command is disabled.
61
+
62
+ :GhcModTypeInsert! *:GhcModTypeInsert!*
63
+ Same as | :GhcModTypeInsert | , but this command is executed even if the
64
+ current buffer is modified.
65
+
51
66
:GhcModInfo *:GhcModInfo*
52
67
Information about the identifier under the cursor is echoed.
53
68
You can’t perform that action at this time.
0 commit comments