Skip to content
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

unable to hide non-public tags using the "v" key #860

Open
XSven opened this issue Sep 5, 2023 · 10 comments
Open

unable to hide non-public tags using the "v" key #860

XSven opened this issue Sep 5, 2023 · 10 comments

Comments

@XSven
Copy link

XSven commented Sep 5, 2023

I have a .go file that has a private variable

var writeClosersZerolog []io.WriteCloser

In the tagbar "variables" section I see an entry that is marked as private

-writeClosersZerolog : []io.WriteCloser

If I press the "v" key nothing happens?! This

n  v           &@:call <SNR>93_ToggleHideNonPublicTags()<CR>

is the map of the "v" key. Please let me know if I understand something wrong or if I should provide further information.

@raven42
Copy link
Collaborator

raven42 commented Sep 5, 2023

This may be a limitation of ctags. Can you confirm the output of running ctags on the file to see if it has the "access" flag?

ctags --extras=+F -f - --format=2 --excmd=pattern --fields=nksSafet --sort=no --append=no -V --language-force=go --go-kinds=picsmtfv <file>

@XSven
Copy link
Author

XSven commented Sep 6, 2023

This is the output:

ctags --extras=+F -f - --format=2 --excmd=pattern --fields=nksSafet --sort=no --append=no -V --language-force=go --go-kinds=picsmtfv pkg/knib-lib-gologger.go
  Option: --language-force=go
  Option: --go-kinds=picsmtfv
Initialize parser: Go
enable field "name": yes
enable field "input": yes
enable field "pattern": yes
Reading command line arguments
OPENING pkg/knib-lib-gologger.go as Go language file [new]
kniblog pkg/knib-lib-gologger.go        /^package kniblog$/;"   p       line:1
Logger  pkg/knib-lib-gologger.go        /^var Logger *zerolog.Logger$/;"        v       line:10 package:kniblog typeref:typename:*zerolog.Logger
writeClosersZerolog     pkg/knib-lib-gologger.go        /^var writeClosersZerolog []io.WriteCloser$/;"  v       line:11 package:kniblog typeref:typename:[]io.WriteCloser
LogSetupZerolog pkg/knib-lib-gologger.go        /^func LogSetupZerolog(logLevel int8, writers []io.Writer, writeClosers []io.WriteCloser) error {$/;"   f       line:13 package:kniblog typeref:typename:error  signature:(logLevel int8, writers []io.Writer, writeClosers []io.WriteCloser)   end:23
LogStopZerolog  pkg/knib-lib-gologger.go        /^func LogStopZerolog() []error {$/;"   f       line:25 package:kniblog typeref:typename:[]error        signature:()    end:35

@raven42
Copy link
Collaborator

raven42 commented Sep 6, 2023

Ok this looks to be an issue with ctags itself then. Tagbar keys off the field "access:public" to help determine public/private status. Without that, it can't make the determination and avoids making an assumption that it is private. Here is an example from a C++ file that correctly labels the access mode:

fun     test.cpp        /^              void fun();$/;" p       line:6  class:A typeref:typename:void   file:   access:public   signature:()    end:6

You can open an issue on the universal-ctags github page. Once ctags supports it, we can confirm the correct behavior within tagbar. If you do open an issue on universal-ctags, feel free to link this issue to that one so we can help track it.

@XSven
Copy link
Author

XSven commented Sep 6, 2023

Ok I will do but I do not understand why tagbar is able to mark ("-" minus sign) the variable

-writeClosersZerolog : []io.WriteCloser

as private and afterwards tagbar is not able to hide it using the "v" key?!

From what you have written it is not clear to me if we are talking about a universal-ctags bug or a missing feature for the Go programming language (maybe it is only a matter of taste).

@raven42
Copy link
Collaborator

raven42 commented Sep 6, 2023

That is actually a good question. When I try to repro I don't see the access modifier in front. I just see writeClosersZerolog : []io.WriteCloser in my tagbar window without the - symbol.

I can confirm that when I open a C++ file that has the access modifiers in the ctags output, I see the - symbol in the tagbar window, and when I hit the v key it does hide these private variables. I wouldn't say it is an issue with the Go language itself, but just how ctags is presenting the data to tagbar.

Can you provide the file you are using as well as your vim version information?

@XSven
Copy link
Author

XSven commented Sep 7, 2023

This
knib-lib-gologger.go.txt
is the file. Note that I had to add the additional extension .txt because github doesn't allow to attach .go files. My vim belongs to the package vim-enhanced-8.1.2424-1.ppc. The detailed version information is

vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun  2 2020 02:10:57)
Included patches: 1-2424
Compiled by <ayappap2@in.ibm.com>
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       -tcl
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
-balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
-browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     -perl              +title
+cindent           +job               +persistent_undo   -toolbar
-clientserver      +jumplist          +popupwin          +user_commands
-clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           +python/dyn        +visual
+comments          +linebreak         -python3           +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        -lua               -ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con        +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/freeware/share/vim"
Compilation: /opt/freeware/bin/gcc -O2 -maix64 -D_LINUX_SOURCE_COMPAT -D_GNU_SOURCE -I/opt/freeware/include -I/usr/include -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /opt/freeware/bin/gcc -O2 -maix64 -D_LINUX_SOURCE_COMPAT -D_GNU_SOURCE -I/opt/freeware/include -I/usr/include   -L/opt/freeware/lib64 -L/opt/freeware/lib -L/usr/lib -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/vac/lib:/usr/lib:/lib -L/usr/local/lib -o vim        -lm -lncurses -liconv -lintl

@raven42
Copy link
Collaborator

raven42 commented Sep 7, 2023

Hmm. When I open this file, I don't see any access symbol in front of any of the variables.
image

Do you have a custom config for ctags / vim / tagbar that is adding this? Or maybe another extension that adds this somehow? I'm just running out of ideas myself. I do know that with tagbar, if it sees the "access" flag from ctags output, then it will use that to give the symbol in the display, but also will add the expected behavior for hiding / unhiding via the v keymap.

@XSven
Copy link
Author

XSven commented Sep 8, 2023

These are my tagbar related configurations

nn <silent> <unique> <Leader>tb :TagbarToggle<CR>
let g:tagbar_position = 'topleft vertical'
let g:tagbar_autofocus = 1
let g:tagbar_zoomwidth = 0
let g:tagbar_foldlevel = 0
let g:tagbar_sort = 1
let g:tagbar_compact = 1

I have the vim-go plugin installed but it is not loaded. This is my runtimepath

/home/micsw/.vim
/home/micsw/.vim/plugged/molokai
/home/micsw/.vim/plugged/vcscommand.vim
/home/micsw/.vim/plugged/vim-fugitive
/home/micsw/.vim/plugged/vim-numbertoggle
/home/micsw/.vim/plugged/tagbar
/home/micsw/.vim/plugged/vim-airline
/home/micsw/.vim/plugged/TaskList.vim
/home/micsw/.vim/plugged/vim-unimpaired
/home/micsw/.vim/plugged/vim-eunuch
/home/micsw/.vim/plugged/syntastic
/home/micsw/.vim/plugged/vim-yaml-folds
/opt/freeware/share/vim/vimfiles
/opt/freeware/share/vim/vim81
/opt/freeware/share/vim/vimfiles/after
/home/micsw/.vim/plugged/vim-yaml-folds/after
/home/micsw/.vim/after

@raven42
Copy link
Collaborator

raven42 commented Sep 8, 2023

I took a look through the plugins and nothing jumps out that I can see that would impact how tagbar sees the tags. Sorry I can't be of more help on this. If you figure it out, I'd be curious how you are seeing the access modifier in your setup. Otherwise we can wait to see if the ctags enhancement gets implemented, and check to ensure the correct behavior here in tagbar.

@XSven
Copy link
Author

XSven commented Sep 8, 2023

I have not yet raised a universal-ctags issue, but I have just detected that the "v" toggling seems to work for "struct"s instead of "funtion"s. I have opened the tagbar for test suite file knib-lib-gologger_test.go. asserter is a private field of the LogSetupZerologSuite struct and I can toggle its visibility with "v"

▾+LogSetupZerologSuite : struct
    [fields]
   -asserter : *require.Assertions

This is the corresponding ctags output

ctags --extras=+F -f - --format=2 --excmd=pattern --fields=nksSafet --sort=no --append=no -V --language-force=go --go-kinds=picsmtfv pkg/knib-lib-gologger_test.go
  Option: --language-force=go
  Option: --go-kinds=picsmtfv
Initialize parser: Go
enable field "name": yes
enable field "input": yes
enable field "pattern": yes
Reading command line arguments
OPENING pkg/knib-lib-gologger_test.go as Go language file [new]
symtbl[:=] *root*<-byteSliceWriter/20084e98 (line: 13)
symtbl[<>] byteSliceWriter->20084e98
symtbl[>|] byteSliceWriter->20084e98
symtbl[< ] byteSliceWriter->20084e98
symtbl[:=] *root*<-byteSliceWriterCloser/20085808 (line: 24)
symtbl[<>] byteSliceWriterCloser->20085808
symtbl[>|] byteSliceWriterCloser->20085808
symtbl[< ] byteSliceWriterCloser->20085808
symtbl[<>] byteSliceWriterCloser->20085808
symtbl[>|] byteSliceWriterCloser->20085808
symtbl[< ] byteSliceWriterCloser->20085808
symtbl[:=] *root*<-LogSetupZerologSuite/20086528 (line: 41)
symtbl[<>] LogSetupZerologSuite->20086528
symtbl[>|] LogSetupZerologSuite->20086528
symtbl[< ] LogSetupZerologSuite->20086528
symtbl[<>] LogSetupZerologSuite->20086528
symtbl[>|] LogSetupZerologSuite->20086528
symtbl[< ] LogSetupZerologSuite->20086528
symtbl[<>] LogSetupZerologSuite->20086528
symtbl[>|] LogSetupZerologSuite->20086528
symtbl[< ] LogSetupZerologSuite->20086528
symtbl[<>] LogSetupZerologSuite->20086528
symtbl[>|] LogSetupZerologSuite->20086528
symtbl[< ] LogSetupZerologSuite->20086528
symtbl[<>] LogSetupZerologSuite->20086528
symtbl[>|] LogSetupZerologSuite->20086528
symtbl[< ] LogSetupZerologSuite->20086528
kniblog_test    pkg/knib-lib-gologger_test.go   /^package kniblog_test$/;"      p       line:1
byteSliceWriter pkg/knib-lib-gologger_test.go   /^type byteSliceWriter struct {$/;"     s       line:13 package:kniblog_test    end:16
logContent      pkg/knib-lib-gologger_test.go   /^      logContent []string$/;" m       line:15 struct:kniblog_test.byteSliceWriter     typeref:typename:[]string
Write   pkg/knib-lib-gologger_test.go   /^func (writer *byteSliceWriter) Write(p []byte) (n int, err error) {$/;"       f       line:18 struct:kniblog_test.byteSliceWriter     typeref:typename:(n int, err error)     signature:(p []byte)    end:22
byteSliceWriterCloser   pkg/knib-lib-gologger_test.go   /^type byteSliceWriterCloser struct {$/;"       s       line:24 package:kniblog_test    end:28
logContent      pkg/knib-lib-gologger_test.go   /^      logContent []string$/;" m       line:26 struct:kniblog_test.byteSliceWriterCloser       typeref:typename:[]string
isClosed        pkg/knib-lib-gologger_test.go   /^      isClosed   bool$/;"     m       line:27 struct:kniblog_test.byteSliceWriterCloser       typeref:typename:bool
Write   pkg/knib-lib-gologger_test.go   /^func (writer *byteSliceWriterCloser) Write(p []byte) (n int, err error) {$/;" f       line:30 struct:kniblog_test.byteSliceWriterCloser       typeref:typename:(n int, err error)     signature:(p []byte)    end:34
Close   pkg/knib-lib-gologger_test.go   /^func (writer *byteSliceWriterCloser) Close() error {$/;"      f       line:36 struct:kniblog_test.byteSliceWriterCloser       typeref:typename:error  signature:()    end:39
LogSetupZerologSuite    pkg/knib-lib-gologger_test.go   /^type LogSetupZerologSuite struct {$/;"        s       line:41 package:kniblog_test    end:48
asserter        pkg/knib-lib-gologger_test.go   /^      asserter         *require.Assertions$/;"        m       line:43 struct:kniblog_test.LogSetupZerologSuite        typeref:typename:*require.Assertions
writers pkg/knib-lib-gologger_test.go   /^      writers          []io.Writer$/;"        m       line:44 struct:kniblog_test.LogSetupZerologSuite        typeref:typename:[]io.Writer
byteWriters     pkg/knib-lib-gologger_test.go   /^      byteWriters      []*byteSliceWriter$/;" m       line:45 struct:kniblog_test.LogSetupZerologSuite        typeref:typename:[]*byteSliceWriter
writeClosers    pkg/knib-lib-gologger_test.go   /^      writeClosers     []io.WriteCloser$/;"   m       line:46 struct:kniblog_test.LogSetupZerologSuite        typeref:typename:[]io.WriteCloser
byteWriteClosers        pkg/knib-lib-gologger_test.go   /^      byteWriteClosers []*byteSliceWriterCloser$/;"   m       line:47 struct:kniblog_test.LogSetupZerologSuite        typeref:typename:[]*byteSliceWriterCloser
SetupTest       pkg/knib-lib-gologger_test.go   /^func (suite *LogSetupZerologSuite) SetupTest() {$/;"  f       line:50 struct:kniblog_test.LogSetupZerologSuite        signature:()    end:63
TestLogSetupZerologSuite        pkg/knib-lib-gologger_test.go   /^func TestLogSetupZerologSuite(t *testing.T) {$/;"     f       line:65 package:kniblog_test    signature:(t *testing.T)        end:67
TestSetupAcceptsWritersAndWriteClosers  pkg/knib-lib-gologger_test.go   /^func (suite *LogSetupZerologSuite) TestSetupAcceptsWritersAndWriteClosers() {$/;"     f       line:69 struct:kniblog_test.LogSetupZerologSuite        signature:()    end:74
logInAllLoglevels       pkg/knib-lib-gologger_test.go   /^func logInAllLoglevels() {$/;"        f       line:76 package:kniblog_test    signature:()    end:82
TestAllWritersAreRegistered     pkg/knib-lib-gologger_test.go   /^func (suite *LogSetupZerologSuite) TestAllWritersAreRegistered() {$/;"        f       line:84 struct:kniblog_test.LogSetupZerologSuite        signature:()    end:97
TestLogLevelIsPassedToLogger    pkg/knib-lib-gologger_test.go   /^func (suite *LogSetupZerologSuite) TestLogLevelIsPassedToLogger() {$/;"       f       line:99 struct:kniblog_test.LogSetupZerologSuite        signature:()    end:111
TestWriteClosersCloseOnLogStop  pkg/knib-lib-gologger_test.go   /^func (suite *LogSetupZerologSuite) TestWriteClosersCloseOnLogStop() {$/;"     f       line:113        struct:kniblog_test.LogSetupZerologSuite        signature:()    end:122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants