Symbol search


#1

I’m working on new version of fzf.kak and I’m thinking about adding proper symbol search to my plugin, and by it I mean dynamically generate symbol list for every opened file.

Rightnow I’m thinking about using ctags for this, so a temporary file will be generated for every buffer in background. However I know that there’s also LSP and it can browse symbols. I’d like to use LSP if it is available and fallback to ctags if not, so I’d like to ask, @ulis can I somehow use your kak-lsp plugin to obtain list of symbols. I know that you have incremental search over symbols in your kak-lsp already, but since fzf is general purpose tool, I want to integrate it with your plugin.

Since discuss.kakoune.com is generally for discussions I’ve decided to open this topic here first, and maybe later we could move to GitHub if necessary.


#2

Could it also use an existing ctags file? On large projects you often have ctags generation synced with other events (build, checkin, etc) rather than integrated deeply with your editor.


#3

Most of language servers should return list of all project symbols in response to lsp-workspace-symbol '' (empty string as an argument). Response is handled by lsp-show-workspace-symbol command which takes project root and a list of symbols as arguments (list of symbols is just a filetype=grep compatible newline-separated string, not a Kakoune list). You can dynamically override lsp-show-workspace-symbol to handle symbols with fzf instead of opening them in a buffer. Does it make sense for your case?


#4

Yes. However that will override your plugin function, isn’t it? If user will try to use it without fzf, as it normally works it won’t work at all. I’d like not to break anything. Maybe I don’t understand it right but I think that maybe kak-lsp could provide both function for just getting a list of symbols, and a wrapper for filtering with kakoune buffer?


#5

That’s already supported.


#6

We can add a callback name as an optional parameter to lsp-workspace-symbol, so it would call it instead of lsp-show-workspace-symbol when provided.