File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,29 @@ function! hdevtools#prepare_shutdown()
2424 endif
2525endfunction
2626
27+ function ! hdevtools#go_file (opencmd)
28+ " Get the import declaration under the cursor
29+ let l: module_name = matchstr (getline (" ." ), ' ^import\s\+\(qualified\s\+\)\=\zs\(\w\|\.\)\+\ze' )
30+ if l: module_name == # ' '
31+ call hdevtools#print_warning (" Cursor not on a Haskell import declaration" )
32+ return
33+ endif
34+
35+ let l: cmd = hdevtools#build_command (' modulefile' , shellescape (l: module_name ))
36+ let l: output = system (l: cmd )
37+
38+ let l: lines = split (l: output , ' \n' )
39+
40+ if v: shell_error != 0
41+ for l: line in l: lines
42+ call hdevtools#print_error (l: line )
43+ endfor
44+ return
45+ endif
46+
47+ exe a: opencmd fnameescape (l: lines [0 ])
48+ endfunction
49+
2750function ! hdevtools#info (identifier )
2851 let l: identifier = a: identifier
2952
Original file line number Diff line number Diff line change 2626 let b: undo_ftplugin = ' '
2727endif
2828
29+ nnoremap <buffer> <silent> gf :call hdevtools#go_file("e")<CR>
30+ nnoremap <buffer> <silent> <C-W><C-F> :call hdevtools#go_file("sp")<CR>
31+
2932command ! - buffer -nargs =0 HdevtoolsType echo hdevtools#type ()[1 ]
3033command ! - buffer -nargs =0 HdevtoolsClear call hdevtools#type_clear ()
3134command ! - buffer -nargs =? HdevtoolsInfo call hdevtools#info (<q-args> )
You can’t perform that action at this time.
0 commit comments