Skip to content

Commit d5ea794

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 d5ea794

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

plugin/vim-erlang-tags.vim

+18-16
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,27 @@ 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+
execute a:cmd expand('<cword>')
6359
let &isk = orig_isk
6460
endfunction
6561

6662
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-]>
63+
nnoremap <buffer> <c-]> :<C-U>call <SID>GoToErlangTag('tag')<cr>
64+
nnoremap <buffer> g<LeftMouse> :<C-U>call <SID>GoToErlangTag('tag')<cr>
65+
nnoremap <buffer> <c-LeftMouse> :<C-U>call <SID>GoToErlangTag('tag')<cr>
66+
nnoremap <buffer> g] :<C-U>call <SID>GoToErlangTag('tselect')<cr>
67+
nnoremap <buffer> g<c-]> :<C-U>call <SID>GoToErlangTag('tjump')<cr>
68+
nnoremap <buffer> <c-w><c-]> :<C-U>call <SID>GoToErlangTag('stag')<cr>
69+
nnoremap <buffer> <c-w>] :<C-U>call <SID>GoToErlangTag('stag')<cr>
70+
nnoremap <buffer> <c-w>g] :<C-U>call <SID>GoToErlangTag('stselect')<cr>
71+
nnoremap <buffer> <c-w>g<c-]> :<C-U>call <SID>GoToErlangTag('stjump')<cr>
72+
nnoremap <buffer> <c-w>} :<C-U>call <SID>GoToErlangTag('ptag')<cr>
73+
nnoremap <buffer> <c-w>g} :<C-U>call <SID>GoToErlangTag('ptjump')<cr>
7474
endfunction
75+
76+
" vim:set expandtab sw=4 ts=4:

0 commit comments

Comments
 (0)