From 49697a751fb865a7b877f1f31768b30312afe06b Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Wed, 4 Feb 2015 05:10:33 +0700 Subject: [PATCH] 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. --- plugin/vim-erlang-tags.vim | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/plugin/vim-erlang-tags.vim b/plugin/vim-erlang-tags.vim index 839b699..6fcf96b 100644 --- a/plugin/vim-erlang-tags.vim +++ b/plugin/vim-erlang-tags.vim @@ -50,25 +50,29 @@ endfunction command! ErlangTags call VimErlangTags() -function! VimErlangTagsSelect(split) - if a:split - split - endif +" Execute the given tag lookup for current word, where 'iskeyword' is +" temporarily set such that modules, records, and macros are included. +function! s:GoToErlangTag(cmd) let orig_isk = &isk - set isk+=: - normal "_vawo - if getline('.')[col('.') - 2] =~# '[#?]' - normal h - endif + set isk+=:,#,? + let ident = expand('') let &isk = orig_isk + + execute a:cmd ident endfunction function! VimErlangTagsDefineMappings() - nnoremap :call VimErlangTagsSelect(0) - nnoremap g :call VimErlangTagsSelect(0) - nnoremap :call VimErlangTagsSelect(0) - nnoremap g] :call VimErlangTagsSelect(0)g] - nnoremap g :call VimErlangTagsSelect(0)g - nnoremap :call VimErlangTagsSelect(1) - nnoremap ] :call VimErlangTagsSelect(1) + nnoremap :call GoToErlangTag('tag') + nnoremap g :call GoToErlangTag('tag') + nnoremap :call GoToErlangTag('tag') + nnoremap g] :call GoToErlangTag('tselect') + nnoremap g :call GoToErlangTag('tjump') + nnoremap :call GoToErlangTag('stag') + nnoremap ] :call GoToErlangTag('stag') + nnoremap g] :call GoToErlangTag('stselect') + nnoremap g :call GoToErlangTag('stjump') + nnoremap } :call GoToErlangTag('ptag') + nnoremap g} :call GoToErlangTag('ptjump') endfunction + +" vim:set expandtab sw=4 ts=4: