Skip to content

Add LSP definition support#31

Merged
linw1995 merged 3 commits intomainfrom
dev
Aug 14, 2025
Merged

Add LSP definition support#31
linw1995 merged 3 commits intomainfrom
dev

Conversation

@linw1995
Copy link
Copy Markdown
Owner

Add LSP definition support to MCP server with enhanced result handling for multiple response formats.

- Add lsp_definition method to NeovimClientTrait interface
- Implement Lua script for textDocument/definition LSP requests
- Add lsp_definition MCP tool with universal document identifier support
- Include comprehensive integration tests for definition lookup
- Rename HoverParams to TextDocumentPositionParams for broader LSP usage
- Change return type from Vec<Location> to DefinitionResult enum
- Add LocationLink struct for enhanced definition information
- Support single location, location list, and location link formats
- Update integration tests to handle all definition result types
@linw1995 linw1995 requested a review from Copilot August 14, 2025 15:31
@linw1995 linw1995 self-assigned this Aug 14, 2025
@linw1995 linw1995 added the enhancement New feature or request label Aug 14, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds LSP definition support to the MCP server enabling clients to retrieve symbol definitions through the Neovim LSP integration. This enhancement allows users to programmatically navigate to symbol definitions using the Language Server Protocol.

  • Implements new lsp_definition tool in the MCP server with position-based symbol lookup
  • Adds comprehensive definition result handling supporting Location, Locations array, and LocationLinks formats
  • Includes integration tests validating definition lookup functionality with Go code examples

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/server/tools.rs Adds DefinitionParams struct and lsp_definition tool method for handling definition requests
src/neovim/lua/lsp_definition.lua Implements Lua script for executing LSP textDocument/definition requests through Neovim
src/neovim/integration_tests.rs Adds comprehensive test case validating definition lookup with Go language server
src/neovim/client.rs Extends client interface with definition support and renames HoverParams to TextDocumentPositionParams for reusability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Update tool count from 13 to 14 tools in documentation
- Add lsp_definition to universal LSP tools list
- Fix LSP definition result handling to return Option<DefinitionResult>
- Remove unused buffer_id parameter from Lua definition script
- Update integration test assertions for optional definition results
- Fix markdown line length issues for linter compliance
@linw1995 linw1995 merged commit ac59074 into main Aug 14, 2025
1 check passed
@linw1995 linw1995 deleted the dev branch August 14, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants