File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 3131endif
3232
3333command ! - buffer -nargs =0 GhcModType echo ghcmod#type ()[1 ]
34+ command ! - buffer -nargs =0 GhcModInfo echo ghcmod#info ()
3435command ! - buffer -nargs =0 GhcModTypeClear call ghcmod#type_clear ()
3536command ! - buffer -nargs =0 GhcModCheck call s: make (' check' )
3637command ! - buffer -nargs =0 GhcModLint call s: make (' lint' )
@@ -40,6 +41,7 @@ command! -buffer -nargs=0 GhcModCheckAndLintAsync call s:check_and_lint_async()
4041command ! - buffer -nargs =0 GhcModExpand call setqflist (ghcmod#expand ()) | cwindow
4142let b: undo_ftplugin .= join (map ([
4243 \ ' GhcModType' ,
44+ \ ' GhcModInfo' ,
4345 \ ' GhcModTypeClear' ,
4446 \ ' GhcModCheck' ,
4547 \ ' GhcModLint' ,
Original file line number Diff line number Diff line change @@ -48,6 +48,35 @@ function! ghcmod#clear_highlight()"{{{
4848 endif
4949endfunction " }}}
5050
51+ " Return the current haskell identifier
52+ function ! ghcmod#getHaskellIdentifier ()" {{{
53+ let c = col (' .' )-1
54+ let l = line (' .' )
55+ let ll = getline (l )
56+ let ll1 = strpart (ll ,0 ,c )
57+ let ll1 = matchstr (ll1," [a-zA-Z0-9_'.]*$" )
58+ let ll2 = strpart (ll ,c ,strlen (ll )- c + 1 )
59+ let ll2 = matchstr (ll2," ^[a-zA-Z0-9_'.]*" )
60+ return ll1.ll2
61+ endfunction " }}}
62+
63+ function ! ghcmod#info ()" {{{
64+ if &l: modified
65+ call ghcmod#print_warning (' ghcmod#info: the buffer has been modified but not written' )
66+ endif
67+ let l: fexp = ghcmod#getHaskellIdentifier ()
68+ let l: file = expand (' %:p' )
69+ if l: file == # ' '
70+ call ghcmod#print_warning (" current version of ghcmod.vim doesn't support running on an unnamed buffer." )
71+ return ' '
72+ endif
73+ let l: mod = ghcmod#detect_module ()
74+ let l: cmd = ghcmod#build_command ([' info' , l: file , l: mod , l: fexp ])
75+ let l: output = s: system (l: cmd )
76+
77+ return l: output
78+ endfunction " }}}
79+
5180function ! ghcmod#type ()" {{{
5281 if &l: modified
5382 call ghcmod#print_warning (' ghcmod#type: the buffer has been modified but not written' )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ License |ghcmod-license|
1616FEATURES *ghcmod-features*
1717
1818- Displaying the type of sub-expressions (ghc-mod type)
19+ - Displaying the info for identifiers (ghc-mod info)
1920- Displaying error/warning messages and their locations (ghc-mod check and
2021 ghc-mod lint)
2122- Displaying the expansion of splices (ghc-mod expand)
@@ -47,6 +48,9 @@ If you'd like to give GHC options, set |g:ghcmod_ghc_options|.
4748 Sub-expressions are highlighted as | hl-Search | by default. You can
4849 customize it by setting | g:ghcmod_type_highlight | .
4950
51+ :GhcModInfo *:GhcModInfo*
52+ Information about the identifier under the cursor is echoed.
53+
5054:GhcModTypeClear *:GhcModTypeClear*
5155 Clear the highlight created by | :GhcModType | .
5256
You can’t perform that action at this time.
0 commit comments