Skip to content

Commit 49697a7

Browse files
committed
Add preview window support
Generalizes the approach so that the function doesn't need logic to handle split, preview, etc. Also no longer results in the cursor being moved to beginning of the function call (or record/macro after #15) in the original buffer.
1 parent f3983f4 commit 49697a7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

plugin/vim-erlang-tags.vim

+20-16
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,29 @@ endfunction
5050

5151
command! ErlangTags call VimErlangTags()
5252

53-
function! VimErlangTagsSelect(split)
54-
if a:split
55-
split
56-
endif
53+
" Execute the given tag lookup for current word, where 'iskeyword' is
54+
" temporarily set such that modules, records, and macros are included.
55+
function! s:GoToErlangTag(cmd)
5756
let orig_isk = &isk
58-
set isk+=:
59-
normal "_vawo
60-
if getline('.')[col('.') - 2] =~# '[#?]'
61-
normal h
62-
endif
57+
set isk+=:,#,?
58+
let ident = expand('<cword>')
6359
let &isk = orig_isk
60+
61+
execute a:cmd ident
6462
endfunction
6563

6664
function! VimErlangTagsDefineMappings()
67-
nnoremap <buffer> <c-]> :call VimErlangTagsSelect(0)<cr><c-]>
68-
nnoremap <buffer> g<LeftMouse> :call VimErlangTagsSelect(0)<cr><c-]>
69-
nnoremap <buffer> <c-LeftMouse> :call VimErlangTagsSelect(0)<cr><c-]>
70-
nnoremap <buffer> g] :call VimErlangTagsSelect(0)<cr>g]
71-
nnoremap <buffer> g<c-]> :call VimErlangTagsSelect(0)<cr>g<c-]>
72-
nnoremap <buffer> <c-w><c-]> :call VimErlangTagsSelect(1)<cr><c-]>
73-
nnoremap <buffer> <c-w>] :call VimErlangTagsSelect(1)<cr><c-]>
65+
nnoremap <buffer> <c-]> :<C-U>call <SID>GoToErlangTag('tag')<cr>
66+
nnoremap <buffer> g<LeftMouse> :<C-U>call <SID>GoToErlangTag('tag')<cr>
67+
nnoremap <buffer> <c-LeftMouse> :<C-U>call <SID>GoToErlangTag('tag')<cr>
68+
nnoremap <buffer> g] :<C-U>call <SID>GoToErlangTag('tselect')<cr>
69+
nnoremap <buffer> g<c-]> :<C-U>call <SID>GoToErlangTag('tjump')<cr>
70+
nnoremap <buffer> <c-w><c-]> :<C-U>call <SID>GoToErlangTag('stag')<cr>
71+
nnoremap <buffer> <c-w>] :<C-U>call <SID>GoToErlangTag('stag')<cr>
72+
nnoremap <buffer> <c-w>g] :<C-U>call <SID>GoToErlangTag('stselect')<cr>
73+
nnoremap <buffer> <c-w>g<c-]> :<C-U>call <SID>GoToErlangTag('stjump')<cr>
74+
nnoremap <buffer> <c-w>} :<C-U>call <SID>GoToErlangTag('ptag')<cr>
75+
nnoremap <buffer> <c-w>g} :<C-U>call <SID>GoToErlangTag('ptjump')<cr>
7476
endfunction
77+
78+
" vim:set expandtab sw=4 ts=4:

0 commit comments

Comments
 (0)