This is a result of a small investigation into how to make protols work
out of the box with the well-known protobuf types, even though it does
not ship them. See https://github.com/NixOS/nixpkgs/pull/465302.
The idea is to be able to configure, in compile time, a lowest-priority
include path that a distro package could set to make sure, without
compromising other sources of include paths, that protols can find the
well-known types even when `pkg-config` and `protobuf` are missing from
the environment and no paths have been manually configured via CLI or
settings.
Please advise on the best name for the environment variable.
## Overview
This PR implements workspace symbols support for the protols LSP server,
enabling clients to search for symbols across all files in the
workspace. This complements the existing document symbols feature by
providing a global symbol search capability.
## Changes
### Server Capabilities
- Added `workspace_symbol_provider` to the LSP server capabilities
advertised during initialization
- Registered the `WorkspaceSymbolRequest` handler in the server router
### Implementation
The implementation adds a `workspace_symbol` method in `src/lsp.rs` that
processes workspace symbol requests with query-based filtering. The
method now includes full workspace parsing before symbol collection:
1. **Full Workspace Parsing**: Before collecting symbols, the handler
parses all `.proto` files from all workspace folders (similar to
references and rename capabilities), ensuring complete coverage
2. **`find_workspace_symbols`** in `src/state.rs`: Collects symbols from
all parsed trees in the workspace, filters them based on the query
string (case-insensitive substring match), and returns sorted results
3. **`collect_workspace_symbols`** in `src/state.rs`: Recursively
traverses document symbols to extract workspace symbols, maintaining
parent-child relationships via the `container_name` field
4. **`get_workspaces`** in `src/config/workspace.rs`: New helper method
to retrieve all workspace folder URIs
### Features
- **Full workspace coverage**: Parses all proto files in all workspace
folders, not just opened files and their imports
- **Cross-file symbol search**: Search for messages, enums, and other
symbols across all proto files in the workspace
- **Query filtering**: Case-insensitive substring matching on symbol
names
- **Nested symbol support**: Correctly handles and reports nested
messages with their container names
- **Consistent ordering**: Results are sorted alphabetically by name and
then by URI for predictable behavior
- **Progress reporting**: Supports LSP work done progress tokens for
long-running workspace parsing operations
### Example Usage
When a client sends a `workspace/symbol` request with query `"author"`:
```json
{
"query": "author"
}
```
The server parses all workspace files and returns all symbols matching
"author" across the workspace:
```json
[
{
"name": "Author",
"kind": 23,
"location": {
"uri": "file:///path/to/b.proto",
"range": { "start": { "line": 5, "character": 0 }, ... }
}
}
]
```
### Testing
Added comprehensive test coverage in
`src/workspace/workspace_symbol.rs`:
- Test with empty query (returns all symbols)
- Test with specific queries ("author", "address")
- Test that non-matching queries return empty results
- Uses insta snapshot testing for regression protection
All 29 tests pass successfully (28 existing + 1 new).
Fixescoder3101/protols#21
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Add support for workspace symbols</issue_title>
> <issue_description>We already support document symbols, it's time to
support workspace symbols as well.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> <comment_new><author>@coder3101</author><body>
> can be re-opened if requested.</body></comment_new>
> </comments>
>
</details>
Fixescoder3101/protols#21
<!-- 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>
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>
This PR adds a comprehensive `.github/copilot-instructions.md` file that
provides GitHub Copilot coding agents with detailed instructions for
working effectively in the Protols codebase.
## What's Included
The instructions file provides complete guidance for:
**Build & Development Workflow:**
- Step-by-step setup with exact commands and validated timing
expectations
- Rust toolchain usage (`cargo build` ~1 min, `cargo test` ~6 sec,
`cargo clippy` ~15 sec)
- External dependency setup (protoc, clang-format) with verification
commands
- Critical timeout warnings ("NEVER CANCEL" with 90+ minute timeouts for
builds)
**Manual Validation Scenarios:**
- 4 comprehensive test scenarios covering build validation, dependency
verification, LSP functionality testing, and sample file validation
- Specific commands for testing core LSP features (hover, workspace
operations, go-to-definition)
- Integration testing with Protocol Buffer files using protoc and
clang-format
**Project Navigation & Structure:**
- Detailed source code organization (`src/lsp.rs`, `src/parser/`,
`src/workspace/`, etc.)
- Key files and their purposes (1400+ lines across 22 test modules)
- Sample files for testing (`sample/simple.proto`, test input files)
**Development Best Practices:**
- Common debugging workflows and log file locations
- Performance expectations and timing guidelines
- CI validation requirements (`cargo fmt --check`, `cargo clippy`, full
test suite)
## Validation
Every single command in the instructions has been tested and validated
to work correctly:
- ✅ All build commands execute successfully with measured timing
- ✅ Full test suite passes (22 tests in ~6 seconds)
- ✅ External dependencies (protoc 3.21.12, clang-format 18.1.3) verified
- ✅ LSP functionality confirmed through specific test execution
- ✅ Sample proto file processing validated
The instructions follow an imperative tone ("Run this command", "Always
test") and provide copy-pasteable commands that agents can execute
reliably to build, test, and validate changes to the Language Server
Protocol implementation.
Fixes#92.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `esm.ubuntu.com`
> - Triggering command: `/usr/lib/apt/methods/https` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/coder3101/protols/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.
---------
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 <coder3101@users.noreply.github.com>
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from
0.3.19 to 0.3.20.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/tokio-rs/tracing/releases">tracing-subscriber's
releases</a>.</em></p>
<blockquote>
<h2>tracing-subscriber 0.3.20</h2>
<p><strong>Security Fix</strong>: ANSI Escape Sequence Injection
(CVE-TBD)</p>
<h2>Impact</h2>
<p>Previous versions of tracing-subscriber were vulnerable to ANSI
escape sequence injection attacks. Untrusted user input containing ANSI
escape sequences could be injected into terminal output when logged,
potentially allowing attackers to:</p>
<ul>
<li>Manipulate terminal title bars</li>
<li>Clear screens or modify terminal display</li>
<li>Potentially mislead users through terminal manipulation</li>
</ul>
<p>In isolation, impact is minimal, however security issues have been
found in terminal emulators that enabled an attacker to use ANSI escape
sequences via logs to exploit vulnerabilities in the terminal
emulator.</p>
<h2>Solution</h2>
<p>Version 0.3.20 fixes this vulnerability by escaping ANSI control
characters in when writing events to destinations that may be printed to
the terminal.</p>
<h2>Affected Versions</h2>
<p>All versions of tracing-subscriber prior to 0.3.20 are affected by
this vulnerability.</p>
<h2>Recommendations</h2>
<p>Immediate Action Required: We recommend upgrading to
tracing-subscriber 0.3.20 immediately, especially if your
application:</p>
<ul>
<li>Logs user-provided input (form data, HTTP headers, query parameters,
etc.)</li>
<li>Runs in environments where terminal output is displayed to
users</li>
</ul>
<h2>Migration</h2>
<p>This is a patch release with no breaking API changes. Simply update
your Cargo.toml:</p>
<pre lang="toml"><code>[dependencies]
tracing-subscriber = "0.3.20"
</code></pre>
<h2>Acknowledgments</h2>
<p>We would like to thank <a href="http://github.com/zefr0x">zefr0x</a>
who responsibly reported the issue at
<code>security@tokio.rs</code>.</p>
<p>If you believe you have found a security vulnerability in any
tokio-rs project, please email us at <code>security@tokio.rs</code>.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4c52ca5266"><code>4c52ca5</code></a>
fmt: fix ANSI escape sequence injection vulnerability (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3368">#3368</a>)</li>
<li><a
href="f71cebe41e"><code>f71cebe</code></a>
subscriber: impl Clone for EnvFilter (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3360">#3360</a>)</li>
<li><a
href="3a1f571102"><code>3a1f571</code></a>
Fix CI (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3361">#3361</a>)</li>
<li><a
href="e63ef57f3d"><code>e63ef57</code></a>
chore: prepare tracing-attributes 0.1.30 (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3316">#3316</a>)</li>
<li><a
href="6e59a13b1a"><code>6e59a13</code></a>
attributes: fix tracing::instrument regression around shadowing (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3311">#3311</a>)</li>
<li><a
href="e4df761275"><code>e4df761</code></a>
tracing: update core to 0.1.34 and attributes to 0.1.29 (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3305">#3305</a>)</li>
<li><a
href="643f392ebb"><code>643f392</code></a>
chore: prepare tracing-attributes 0.1.29 (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3304">#3304</a>)</li>
<li><a
href="d08e7a6eea"><code>d08e7a6</code></a>
chore: prepare tracing-core 0.1.34 (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3302">#3302</a>)</li>
<li><a
href="6e70c571d3"><code>6e70c57</code></a>
tracing-subscriber: count numbers of enters in <code>Timings</code> (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/2944">#2944</a>)</li>
<li><a
href="c01d4fd9de"><code>c01d4fd</code></a>
fix docs and enable CI on <code>main</code> branch (<a
href="https://redirect.github.com/tokio-rs/tracing/issues/3295">#3295</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.3.19...tracing-subscriber-0.3.20">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/coder3101/protols/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
fixes#75
Prior to this `protols` could not resolve relative package names, this
fixes it and now LSP should be able to properly jump/hover and find
references/rename even in packages with field name relative to current
package.
Potentially fixes#83
Prior to this, any unhandled notification not starting with `$` would
have caused the main loop to exit with error resulting in server to
crash. Moreover, this unhandled_notification handler only works with
builder pattern which imo is cleaner and offers ability to separate out
implementation of various requests into its own files (i'll maybe do
that someday).
Prior to this, a proto file without a package declaration didn't
supported any operation as parser required that a package be present.
For missing package we now consider . as package
When a file is opened, all imports are parsed recursively up to a depth
of 8. When a file is being edited it and its imports are parsed with a
depth of 2.
As the tree-parser was unable to parse the following, they were falsely
shown as syntax error during diagnostics.
- reserved field with single quotation
- reserved fields without quotation
- edition keyword