protols/rust-toolchain.toml
Copilot e3a23dbe7b
Add support for setting include paths via initializationParams (#91)
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:

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

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: coder3101 <22212259+coder3101@users.noreply.github.com>
Co-authored-by: Ashar <ashar786khan@gmail.com>
Co-authored-by: Ashar <coder3101@users.noreply.github.com>
2025-09-20 23:01:46 +05:30

2 lines
31 B
TOML

[toolchain]
channel = "stable"