refactor(lsp-util): Update LSP client and jump utility calls#120
Open
niexin-dev wants to merge 2 commits intoldelossa:mainfrom
Open
refactor(lsp-util): Update LSP client and jump utility calls#120niexin-dev wants to merge 2 commits intoldelossa:mainfrom
niexin-dev wants to merge 2 commits intoldelossa:mainfrom
Conversation
Problem Origin: LSP client methods used inconsistent calling syntax internally, potentially leading to inaccurate `self` passing. The jump functionality utilized `vim.lsp.util.jump_to_location`, which is not the latest or recommended interface for the Neovim LSP API. Solution: Standardize all LSP client method calls in `litee.lib.lsp` to Lua's colon syntax (`client:method(...)`) to ensure correct `self` propagation. In `litee.lib.jumps`, replace `vim.lsp.util.jump_to_location` with `vim.lsp.util.show_document` to adopt Neovim LSP's more modern and flexible document display interface. Impact: • For users: No apparent direct functional behavior changes. • For developers: Improves internal code consistency and maintainability, adhering to Neovim LSP API best practices. • Potential risks: Limited risk, mainly internal API call adjustments; should have no functional regression after testing. Key Changes: • Replaced `jump_to_location` with `show_document` in the `jump_invoking` function in `lua/litee/lib/jumps/init.lua`. • Changed `client.supports_method` and `client.request` calls to colon syntax in `M.multi_client_request` in `lua/litee/lib/lsp/init.lua`. • Changed `client.supports_method` and `client.request_sync` calls to colon syntax in `M.symbol_from_node` in `lua/litee/lib/lsp/init.lua`.
Problem Root Cause: The current LSP hover popup content handling logic relies on deprecated Neovim internal APIs `vim.lsp.util.trim_empty_lines` and `vim.lsp.util.stylize_markdown`. These deprecated APIs may lead to future compatibility issues. Solution: Introduce a local `trim_empty_lines` function to replace `vim.lsp.util.trim_empty_lines`. Concurrently, remove the call to `vim.lsp.util.stylize_markdown` and instead use Neovim's native markdown filetype and Treesitter highlighting to render the hover content. Impact: • For Users: The display behavior and content of the LSP hover popup are expected to remain largely unchanged, maintaining functional consistency. • For Developers: Reduces reliance on deprecated Neovim internal APIs, lowering future code maintenance risks and enhancing robustness. • Potential Risks: Removing `stylize_markdown` might lead to subtle differences in specific markdown style highlighting, but given its deprecated status, this risk is acceptable. Key Changes: • Added a local `trim_empty_lines` function to remove leading and trailing empty lines from text. • Used the custom `trim_empty_lines` in `hover_handler` instead of `vim.lsp.util.trim_empty_lines`. • Removed the `vim.lsp.util.stylize_markdown` call, simplifying the highlighting logic. • Explicitly set the `markdown` filetype for the LSP float window buffer and attempted to start `treesitter` highlighting.
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.
Problem Origin:
LSP client methods used inconsistent calling syntax internally, potentially leading to inaccurate
selfpassing. The jump functionality utilizedvim.lsp.util.jump_to_location, which is not the latest or recommended interface for the Neovim LSP API.Solution:
Standardize all LSP client method calls in
litee.lib.lspto Lua's colon syntax (client:method(...)) to ensure correctselfpropagation. Inlitee.lib.jumps, replacevim.lsp.util.jump_to_locationwithvim.lsp.util.show_documentto adopt Neovim LSP's more modern and flexible document display interface.Impact:
• For users: No apparent direct functional behavior changes. • For developers: Improves internal code consistency and maintainability, adhering to Neovim LSP API best practices. • Potential risks: Limited risk, mainly internal API call adjustments; should have no functional regression after testing.
Key Changes:
• Replaced
jump_to_locationwithshow_documentin thejump_invokingfunction inlua/litee/lib/jumps/init.lua. • Changedclient.supports_methodandclient.requestcalls to colon syntax inM.multi_client_requestinlua/litee/lib/lsp/init.lua. • Changedclient.supports_methodandclient.request_synccalls to colon syntax inM.symbol_from_nodeinlua/litee/lib/lsp/init.lua.