New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number of the Tag #490

Open
sunnypp opened this Issue May 17, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@sunnypp

sunnypp commented May 17, 2018

TL;DR; Can we show the line number of the tag in the Tag Window?

Say if the tag is on line 131 of the file, that way I may navigate to a tag by :131 without shifting the focus to the Tag Window.

Long Story:

I have the following settings in my ~/.vimrc:

let g:tagbar_compact = 1
let g:tagbar_show_linenumbers = 1
let g:tagbar_type_javascript = {
  \ 'ctagsbin' : 'ctags',
  \ 'ctagsargs' : '-f - --fields=+n',
  \ }

When I am working on an .js file, from set ft? I can see filetype=javascript and the functions (though being shown as "namespace" and all the if and function are there..), but not the line numbers.

Then I figured out that the "line numbers in Tag Window" refers to .. the tag window itself, not the tags.
Is there a setting which we can see something like (line ##) function_name : function ?

@nicolaiskogheim

This comment has been minimized.

Show comment
Hide comment
@nicolaiskogheim

nicolaiskogheim Jun 7, 2018

Say if the tag is on line 131 of the file, that way I may navigate to a tag by :131 without shifting the focus to the Tag Window.

This is may be a shot in the dark, but I am guessing that you meant to write "without shifting the focus from the Tag Window", in which case, you can hit p when you have the cursor on a tag to jump to the tag in the file without moving the cursor away from the tag window.

nicolaiskogheim commented Jun 7, 2018

Say if the tag is on line 131 of the file, that way I may navigate to a tag by :131 without shifting the focus to the Tag Window.

This is may be a shot in the dark, but I am guessing that you meant to write "without shifting the focus from the Tag Window", in which case, you can hit p when you have the cursor on a tag to jump to the tag in the file without moving the cursor away from the tag window.

@sunnypp

This comment has been minimized.

Show comment
Hide comment
@sunnypp

sunnypp Jun 11, 2018

Hello @nicolaiskogheim . Please let me elaborate a little bit to see if my request will be clearer...

I always have my Tag window open, and with the editor focusing on the script that I am editing.
Say if I wanna edit a particular function named hello(), currently Tagbar cannot help me much..

However, if it can be written as (line 131) hello : function in the Tag Window, then "without shifting the focus to the Tag Window" (i.e. maintaining the focus in the script), I can use :131 to jump to the hello() function.

In short, I would like to have a convenient way to jump to another tag in the same file. I wonder if this is possible with the current implementation of Tagbar.

sunnypp commented Jun 11, 2018

Hello @nicolaiskogheim . Please let me elaborate a little bit to see if my request will be clearer...

I always have my Tag window open, and with the editor focusing on the script that I am editing.
Say if I wanna edit a particular function named hello(), currently Tagbar cannot help me much..

However, if it can be written as (line 131) hello : function in the Tag Window, then "without shifting the focus to the Tag Window" (i.e. maintaining the focus in the script), I can use :131 to jump to the hello() function.

In short, I would like to have a convenient way to jump to another tag in the same file. I wonder if this is possible with the current implementation of Tagbar.

@nicolaiskogheim

This comment has been minimized.

Show comment
Hide comment
@nicolaiskogheim

nicolaiskogheim Jun 11, 2018

Thank you, that cleared it up :)

ctags can provide can information, as I'm sure you know. The help pages for Tagbar mentions running ctags for finding out whether issues lies with Tagbar or Ctags, and there the flag --excmd=pattern is supplied, which means that tagfiles use regex patterns and not line numbers to find tags. My version of ctags completely ignores that flag and gives both pattern and line number, but I guess Tagbar has to change the flag to --excmd=mixed to be sure. I don't understand vim script well, and I wasn't able to figure out what flags Tagbar actually sends to ctags.

Anyways, Tagbar supports reading line number information from tagfiles, so it should be possible to add that information to the Tagbar window. I guess we just have to wait for someone who knows how to do this kind of modification to the plugin :)

nicolaiskogheim commented Jun 11, 2018

Thank you, that cleared it up :)

ctags can provide can information, as I'm sure you know. The help pages for Tagbar mentions running ctags for finding out whether issues lies with Tagbar or Ctags, and there the flag --excmd=pattern is supplied, which means that tagfiles use regex patterns and not line numbers to find tags. My version of ctags completely ignores that flag and gives both pattern and line number, but I guess Tagbar has to change the flag to --excmd=mixed to be sure. I don't understand vim script well, and I wasn't able to figure out what flags Tagbar actually sends to ctags.

Anyways, Tagbar supports reading line number information from tagfiles, so it should be possible to add that information to the Tagbar window. I guess we just have to wait for someone who knows how to do this kind of modification to the plugin :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment