vim-erlang / vim-erlang-tags

Generate Vim tags for Erlang files
https://vim-erlang.github.io
Other
61 stars 23 forks source link

Suggest about jump to the definition which defined in current module #26

Closed haoxianhan closed 7 years ago

haoxianhan commented 7 years ago

If I write same function name foo in different modules(eg: module a, b), so plugin generates tags like: foo ./path/to/module/a /^foo\>;" f file; foo ./path/to/module/b /^foo\>;" f file; When I code in module a, using 'ctrl+]' to jump to foo without the prefix module reference ( just foo, not a:foo or b:foo) , it should jump to the definition in current module directly if existing instead of listing multi options for choosing?

hcs42 commented 7 years ago

it should jump to the definition in current module directly if existing instead of listing multi options for choosing?

Yes, that's how it works; vim-erlang-tags does generate "file" fields in the tags file, so when editing a.erl, foo + ctrl-]should jump to a:foo. Have you experienced a different behaviour?

The files in the tags option are checked in order (this ordering is stronger than the "file" field), so if there is another tags file before the tags file in question, that can cause a situation when you don't jump to a:foo.

haoxianhan commented 7 years ago

a.erl

-module(a).
-compile(export_all).
foo() ->
    a. 

b.erl

-module(b).
-compile(export_all).
foo() ->
    b.  

after run ErlangTags, generate tags following:

!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted/
a   ./src/a.erl 1;" M
a.erl   ./src/a.erl 1;" F
a:foo   ./src/a.erl /^foo\>/;"  f
b   ./src/b.erl 1;" M
b.erl   ./src/b.erl 1;" F
b:foo   ./src/b.erl /^foo\>/;"  f
foo ./src/a.erl /^foo\>/;"  f   file:
foo ./src/b.erl /^foo\>/;"  f   file:

and when editing a.erl, foo + ctrl-], it displays the options for choosing, like: image

hcs42 commented 7 years ago

What mapping do you have on CTRL-]? You can check it by typing ":map <c-]>". You should see this:

n  <C-]>       *@:call VimErlangTagsSelect(0)<CR><C-]>

You can even check where the mapping was set by typing ":verbose map <c-]>" (please do this as well and copy the result):

n  <C-]>       *@:call VimErlangTagsSelect(0)<CR><C-]>
    Last set from ~/d/cp/vim-erlang/vim-erlang-tags/plugin/vim-erlang-tags.vim

By default in Vim, CTRL-] should jump to the first tag; it doesn't show a list of tags. g CTRL-] does list tags. (See :help ctrl-] and :help g_ctrl-]). vim-erlang-tags has a mapping for CTRL-], but that still shouldn't show a list of tags.

haoxianhan commented 7 years ago

typing ":map <c-]>" image

typing ":verbose map <c-]>" image

I wonder if any plugin was depended by this vim-erlang-tags ??? So that your plugin got the right behavior, and mine got wrong due to not installing some plugin else??

hcs42 commented 7 years ago

No, vim-erlang-tags doesn't have any dependency.. What sometimes happens is that other plugins interfere with it, but in this case I can't see how.

What happens if you unmap this mapping?

:unmap <buffer> <c-]>

:map <c-]> should say "No mapping found".

Now please try c-]. What happens, do you get the tag list, or is there a simple jump?

haoxianhan commented 7 years ago

I've try :unmap <buffer> <c-]> and :map <c-]> got "No mapping found". try c-] just get the tag list.

hcs42 commented 7 years ago

What is your Vim version? What is the output of :version?

haoxianhan commented 7 years ago

output of :version show following: image

hcs42 commented 7 years ago

Could you try this with non-Erlang code? Let's say C code? It seems to me that this is unrelated to the vim-erlang-tags plugin, and for some reason your Vim doesn't behave properly when c-] is pressed. You could also compile your own Vim after downloading the source code and installing the dependencies. This way you could ensure that your Vim wasn't modified by Red Hat.

haoxianhan commented 7 years ago

ok, I'd try to uninstall the current vim version and install the origin version, I make this version due to the YouCompleteMe.

haoxianhan commented 7 years ago

Sadly,I try make vim by source, version 7.4 and version 8, in macos and centos, I got the same problem. Would you like to tell me what's your OS and vim version?

hcs42 commented 7 years ago

I have Debian Jessie:

$ uname -a
Linux dixon 4.7.0-0.bpo.1-amd64 #1 SMP Debian 4.7.8-1~bpo8+1 (2016-10-19) x86_64 GNU/Linux

I compiled Vim from the source:

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2016 15:48:16)
Included patches: 1-104
Compiled by hcs@dixon
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +conceal         +file_in_path    +libcall         +mouse_sgr       +profile         +tag_old_static  +viminfo
+arabic          +cryptv          +find_in_path    +linebreak       -mouse_sysmouse  +python/dyn      -tag_any_white   +vreplace
+autocmd         +cscope          +float           +lispindent      +mouse_urxvt     +python3/dyn     -tcl             +wildignore
+balloon_eval    +cursorbind      +folding         +listcmds        +mouse_xterm     +quickfix        +termguicolors   +wildmenu
+browse          +cursorshape     -footer          +localmap        +multi_byte      +reltime         +terminfo        +windows
++builtin_terms  +dialog_con_gui  +fork()          -lua             +multi_lang      +rightleft       +termresponse    +writebackup
+byte_offset     +diff            +gettext         +menu            -mzscheme        -ruby            +textobjects     +X11
+channel         +digraphs        -hangul_input    +mksession       +netbeans_intg   +scrollbind      +timers          -xfontset
+cindent         +dnd             +iconv           +modify_fname    +num64           +signs           +title           +xim
+clientserver    -ebcdic          +insert_expand   +mouse           +packages        +smartindent     +toolbar         +xpm
+clipboard       +emacs_tags      +job             +mouseshape      +path_extra      +startuptime     +user_commands   +xsmp_interact
+cmdline_compl   +eval            +jumplist        +mouse_dec       -perl            +statusline      +vertsplit       +xterm_clipboard
+cmdline_hist    +ex_extra        +keymap          +mouse_gpm       +persistent_undo -sun_workshop    +virtualedit     -xterm_save
+cmdline_info    +extra_search    +lambda          -mouse_jsbterm   +postscript      +syntax          +visual
+comments        +farsi           +langmap         +mouse_netterm   +printer         +tag_binary      +visualextra
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/incl
ude -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/includ
e/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuz
z -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2    -g -O2 -U_FO
RTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0
 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE
-lm -ltinfo -lnsl  -lselinux   -lacl -lattr -lgpm -ldl

Previously I used MacOS, and it worked fine there as well.

Do you have the same .vimrc file and .vim directory on the different systems? You might want to try without any .vimrc and .vim.

haoxianhan commented 7 years ago

It seem my config some thing unfix, I'd try to find and response if I found out, just close this issue.