Feat/lsp symbols#9
Merged
Merged
Conversation
cachebag
requested changes
May 20, 2026
cachebag
left a comment
Owner
There was a problem hiding this comment.
Generally speaking as well, I noticed that on reprompts, @lsp is just treated as literal text because we didn't update build_reprompt_messages.
You should either strip it entirely or support it in this PR.
Thanks so much for your contribution :D
fix: formatting fix: replace buf_request_sync with buf_request
45bf03a to
bd3eff2
Compare
Contributor
Author
|
just fixed the linting error, could you re-run the GitHub Actions workflow? |
- Replace vim.tbl_any (Neovim 0.10+) with a plain loop so the plugin works on older nvim and in configs that override vim.* helpers. - Filter workspace/symbol results to files under cwd, dropping LSP stdlib/meta files that otherwise crowd out real project symbols (e.g. lua_ls dumps Lua stdlib meta into the response). - Keep only structural SymbolKinds (Function, Method, Class, Field, Struct, etc.) so locals/vars don't blow the 200-entry cap. - Thread context.symbols into build_reprompt_messages, mirroring build_messages. Previously @Lsp on a reprompt computed and then silently discarded the workspace context.
- Split insert-mode <CR>: accept pumenu selection if visible, otherwise submit. Previously <CR> always submitted, so hitting Enter on the @Lsp popup item just sent the prompt without inserting the mention. - Disable nvim-cmp inside the prompt buffer so it doesn't fight with vim.fn.complete or intercept <CR>. - Highlight confirmed @Lsp tokens via a JumpyMention extmark group (linked to Special) so users can see when the mention will actually be picked up by _submit. Partial typing like '@l'/'@ls' does not highlight; only the standalone, word-bounded token does — matching the frontier-pattern gsub used by _submit.
cachebag
approved these changes
May 21, 2026
cachebag
left a comment
Owner
There was a problem hiding this comment.
LGTM. I went ahead and pushed a few follow-ups- happy to discuss them with you:
- vim.tbl_any -> plain loop, so this doesn't break on older nvim / shimmed vim.*.
- Filter symbols to files under cwd and to structural SymbolKinds — without this, lua_ls floods the response with stdlib meta and the 200-cap eats real project symbols.
- Threaded context.symbols through build_reprompt_messages so @Lsp actually reaches the LLM on reprompts.
- Prompt UX: insert-mode now accepts the pumenu before submitting, disabled cmp inside the prompt buf, and added a JumpyMention highlight that only fires on the standalone @Lsp token so you can see when it'll be picked up.
Thanks for the contribution @HimanshuSardana ! I really love this feature.
cachebag
added a commit
that referenced
this pull request
May 21, 2026
* chore: move get_workspace_symbols to context-tools.lua fix: formatting fix: replace buf_request_sync with buf_request * fix: make buf_request async * chore: pass workspace symbols via context * fix: notify user if LSP doesnt support workspace_symbols * fix: enable @Lsp completion in reprompts * style: fix lint error * fix(context-tools): broaden compatibility and reduce symbol noise - Replace vim.tbl_any (Neovim 0.10+) with a plain loop so the plugin works on older nvim and in configs that override vim.* helpers. - Filter workspace/symbol results to files under cwd, dropping LSP stdlib/meta files that otherwise crowd out real project symbols (e.g. lua_ls dumps Lua stdlib meta into the response). - Keep only structural SymbolKinds (Function, Method, Class, Field, Struct, etc.) so locals/vars don't blow the 200-entry cap. - Thread context.symbols into build_reprompt_messages, mirroring build_messages. Previously @Lsp on a reprompt computed and then silently discarded the workspace context. * fix(prompt): make @Lsp completion usable in prompt float - Split insert-mode <CR>: accept pumenu selection if visible, otherwise submit. Previously <CR> always submitted, so hitting Enter on the @Lsp popup item just sent the prompt without inserting the mention. - Disable nvim-cmp inside the prompt buffer so it doesn't fight with vim.fn.complete or intercept <CR>. - Highlight confirmed @Lsp tokens via a JumpyMention extmark group (linked to Special) so users can see when the mention will actually be picked up by _submit. Partial typing like '@l'/'@ls' does not highlight; only the standalone, word-bounded token does — matching the frontier-pattern gsub used by _submit. --------- Co-authored-by: Himanshu Sandana <himanshusardana2005@gmail.com>
cachebag
added a commit
that referenced
this pull request
May 21, 2026
* chore: move get_workspace_symbols to context-tools.lua fix: formatting fix: replace buf_request_sync with buf_request * fix: make buf_request async * chore: pass workspace symbols via context * fix: notify user if LSP doesnt support workspace_symbols * fix: enable @Lsp completion in reprompts * style: fix lint error * fix(context-tools): broaden compatibility and reduce symbol noise - Replace vim.tbl_any (Neovim 0.10+) with a plain loop so the plugin works on older nvim and in configs that override vim.* helpers. - Filter workspace/symbol results to files under cwd, dropping LSP stdlib/meta files that otherwise crowd out real project symbols (e.g. lua_ls dumps Lua stdlib meta into the response). - Keep only structural SymbolKinds (Function, Method, Class, Field, Struct, etc.) so locals/vars don't blow the 200-entry cap. - Thread context.symbols into build_reprompt_messages, mirroring build_messages. Previously @Lsp on a reprompt computed and then silently discarded the workspace context. * fix(prompt): make @Lsp completion usable in prompt float - Split insert-mode <CR>: accept pumenu selection if visible, otherwise submit. Previously <CR> always submitted, so hitting Enter on the @Lsp popup item just sent the prompt without inserting the mention. - Disable nvim-cmp inside the prompt buffer so it doesn't fight with vim.fn.complete or intercept <CR>. - Highlight confirmed @Lsp tokens via a JumpyMention extmark group (linked to Special) so users can see when the mention will actually be picked up by _submit. Partial typing like '@l'/'@ls' does not highlight; only the standalone, word-bounded token does — matching the frontier-pattern gsub used by _submit. --------- Co-authored-by: Himanshu Sandana <himanshusardana2005@gmail.com>
cachebag
added a commit
that referenced
this pull request
May 21, 2026
* chore: move get_workspace_symbols to context-tools.lua fix: formatting fix: replace buf_request_sync with buf_request * fix: make buf_request async * chore: pass workspace symbols via context * fix: notify user if LSP doesnt support workspace_symbols * fix: enable @Lsp completion in reprompts * style: fix lint error * fix(context-tools): broaden compatibility and reduce symbol noise - Replace vim.tbl_any (Neovim 0.10+) with a plain loop so the plugin works on older nvim and in configs that override vim.* helpers. - Filter workspace/symbol results to files under cwd, dropping LSP stdlib/meta files that otherwise crowd out real project symbols (e.g. lua_ls dumps Lua stdlib meta into the response). - Keep only structural SymbolKinds (Function, Method, Class, Field, Struct, etc.) so locals/vars don't blow the 200-entry cap. - Thread context.symbols into build_reprompt_messages, mirroring build_messages. Previously @Lsp on a reprompt computed and then silently discarded the workspace context. * fix(prompt): make @Lsp completion usable in prompt float - Split insert-mode <CR>: accept pumenu selection if visible, otherwise submit. Previously <CR> always submitted, so hitting Enter on the @Lsp popup item just sent the prompt without inserting the mention. - Disable nvim-cmp inside the prompt buffer so it doesn't fight with vim.fn.complete or intercept <CR>. - Highlight confirmed @Lsp tokens via a JumpyMention extmark group (linked to Special) so users can see when the mention will actually be picked up by _submit. Partial typing like '@l'/'@ls' does not highlight; only the standalone, word-bounded token does — matching the frontier-pattern gsub used by _submit. --------- Co-authored-by: Akrm Al-Hakimi <akrm@cachebag.sh>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added support for
@lspcompletions in the prompt buffer. When used, the plugin now callsvim.lsp.buf.workspace_symbol, formats the returned symbols, and prepends the resulting workspace context to the prompt sent to the LLM.Notes
workspace_symbolbehavior appears to vary across LSP servers:basedpyrightandgoplsreturn no results when provided with an empty query ("")lua_lsreturns all project symbols for the same request (intended behaviour)I also tried an alternative implementation that called
textDocument/documentSymbolfor every file in the workspace and merged the results manually. While this produced better results across servers, it often resulted in severe lag (3-4s) even in relatively small projects. So, I decided not to use that approach and just rely on the LSP's workspace_symbol implementation