Skip to content

Conversation

@niexin-dev
Copy link

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 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.
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

Successfully merging this pull request may close these issues.

1 participant