Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 16, 2025

This PR adds the ability to configure include paths dynamically through LSP initializationParams, addressing a key limitation for Neovim users where command-line arguments must be static but initialization options can be set dynamically.

Problem

Neovim's LSP configuration requires cmd and args to be static, making it impossible to dynamically configure include paths based on project context. While Neovim supports changing initializationParams via the before_init callback, protols didn't support include path configuration through this mechanism.

Solution

Extended the LSP initialization process to parse and use include paths from initializationParams.include_paths. The implementation:

  • Integrates seamlessly: Merges with existing CLI and configuration file include paths
  • Handles errors gracefully: Invalid formats are logged but don't crash the server
  • Maintains compatibility: All existing functionality continues to work unchanged

Usage

Neovim users can now configure include paths dynamically:

require'lspconfig'.protols.setup{
  before_init = function(_, config)
    config.init_options = {
      include_paths = {
        "/usr/local/include/protobuf",
        "vendor/protos",
        "../shared-protos"
      }
    }
  end
}

Implementation Details

  • Extended WorkspaceProtoConfigs to store initialization include paths
  • Added parse_init_include_paths() function to handle JSON parsing with robust error handling
  • Updated include path resolution to merge all sources (config file + CLI + initialization)
  • Added comprehensive test coverage with 6 new test cases
  • Updated documentation with usage examples

Testing

All existing tests continue to pass, plus new tests covering:

  • Array format parsing
  • String format parsing
  • Invalid format handling
  • Integration with existing include path sources
  • Real-world usage scenarios

Fixes #90.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Sep 16, 2025

@coder3101 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] feature request: ability to set include paths via initializationParams Add support for setting include paths via initializationParams Sep 16, 2025
Copilot AI requested a review from coder3101 September 16, 2025 06:33
Copilot finished work on behalf of coder3101 September 16, 2025 06:33
@coder3101 coder3101 marked this pull request as ready for review September 20, 2025 17:08
@coder3101 coder3101 enabled auto-merge (squash) September 20, 2025 17:30
Copy link
Owner

@coder3101 coder3101 left a comment

Choose a reason for hiding this comment

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

Nice work @copilot !

@coder3101 coder3101 disabled auto-merge September 20, 2025 17:31
@coder3101 coder3101 merged commit e3a23db into main Sep 20, 2025
1 check passed
@coder3101 coder3101 deleted the copilot/fix-90 branch September 20, 2025 17:31
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.

feature request: ability to set include paths via initializationParams

2 participants