Languageclient-neovim: Tagbar-style outline/browser/navigation pane

Created on 26 Nov 2017  路  9Comments  路  Source: autozimu/LanguageClient-neovim

I can run tagbar plugin side by side with LanguageClient to get the outline, but it's double job as the same files are parsed 2 times independently.

  • Does the upstream LSP protocol support this feature? E.g. get the list of top-level definitions in a file.
  • Is there a "retargetable" version of tagbar which can use "internal" sources as opposed to starting processes? Just like deoplete is a retargetable completion engine.

Most helpful comment

https://github.com/majutsushi/tagbar/blob/master/autoload/tagbar.vim#2677

Here it uses the system() call to refresh the tags. So if you replace

silent let ctags_output = system(a:ctags_cmd)

with

silent let ctags_output = get_tags_as_string_from_LanguageClient()

it will probably work, although in a very dirty way.

All 9 comments

Yes the upstream LSP support this feature with textDocument/documentSymbol, it's already implemented in LamguageClient-neovim

I don't think there is a "retargetable" version of tagbar but we can try to create tags from LSP symbols

One of the avantages of tagbar is that "It only creates the tags it needs on-the-fly in-memory without creating any files". So maybe it's easier to patch the tagbar to be retargetable, as it already uses a non-file transport. And it's better to develop such a patch together with the LanguageClient part, so we know that the new mechanism in Tagbar fits LanguageClient's needs

I will try to look TagBar implementation tomorrow and see what can be the best to implement this feature

https://github.com/majutsushi/tagbar/blob/master/autoload/tagbar.vim#2677

Here it uses the system() call to refresh the tags. So if you replace

silent let ctags_output = system(a:ctags_cmd)

with

silent let ctags_output = get_tags_as_string_from_LanguageClient()

it will probably work, although in a very dirty way.

The output is then parsed here:

https://github.com/majutsushi/tagbar/blob/2261625e299e202fa2e2bf60ab4248212078310f/autoload/tagbar.vim#L1023-L1034

A significant part of tagbar's source is just to refresh tags using temporary files (for unsaved buffers, not for tags) and short-lived processes. There are too many corner-cases in this old-school approach. But tagbar has a polished UI. So in the long run we probably should split it into "clean gui" part and "dirty ctags exectuables and parsing" part.

Oh, and I found how to use our current poor man's tagbar:

:call LanguageClient_textDocument_documentSymbol()
:lopen

Real talk @nponeccop, it might be best making a separate plug-in that provides a tagbar-esque interface. I can't remember but there's a utility plugin that makes making interfaces like this straight forward.

It was this one: https://github.com/xolox/vim-misc#handling-of-special-buffers

I don't insist on patching tagbar. We could even add our proper tagbar gui as a feature of LanguageClient.
But then we should teach users to configure nvim so both panes are not displayed at the same time.

Closing this issue for no real progress.

I'm not going to implement this feature in the foreseeable future as it don't seem fit into scope of this project.

Plus, LanguageClient_textDocument_documentSymbol() has already good enough integration with fzf and denite, and is easily extensible when UI is in-place.

Was this page helpful?
0 / 5 - 0 ratings