protols/src
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
..
config Add support for setting include paths via initializationParams (#91) 2025-09-20 23:01:46 +05:30
context feat: Add docs about include_path and format code. (#57) 2025-02-24 01:25:13 +05:30
docs feat: Add completion for builtin types with documentation (#81) 2025-06-02 22:31:30 +05:30
formatter fix: does not works in no workspace mode (#69) 2025-03-29 00:32:51 +05:30
parser chore: bump dependencies and release 0.12.8 with if chaining (#87) 2025-08-26 23:26:15 +05:30
workspace feat: Add support for relative package resolution (#85) 2025-06-06 18:01:04 +05:30
docs.rs feat: Add completion for builtin types with documentation (#81) 2025-06-02 22:31:30 +05:30
lsp.rs Add support for setting include paths via initializationParams (#91) 2025-09-20 23:01:46 +05:30
main.rs feat: Use builder pattern and log unhandled notifications (#84) 2025-06-06 03:26:50 +05:30
nodekind.rs feat: Add import path and tree refactor (#48) 2025-01-12 22:04:03 +05:30
protoc.rs chore: bump dependencies and release 0.12.8 with if chaining (#87) 2025-08-26 23:26:15 +05:30
server.rs feat: Use builder pattern and log unhandled notifications (#84) 2025-06-06 03:26:50 +05:30
state.rs chore: bump dependencies and release 0.12.8 with if chaining (#87) 2025-08-26 23:26:15 +05:30
utils.rs fix: nothing works in a file without a package (#77) 2025-05-03 12:31:33 +05:30