Skip to content

Commit

Permalink
feat: LSP inlay parameter hints (#5553)
Browse files Browse the repository at this point in the history
# Description

## Problem

Resolves #5554

## Summary

The type and parameter hints can be toggled from a configuration which
we get during LSP initialization. However, vscode-noir doesn't sent
those configs yet, but at least the code here will work once we do that
on the other side. For now they will always show up.


https://github.com/user-attachments/assets/ebc52b52-287a-43fa-b87d-1a74012c3e78

## Additional Context

None.

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
asterite authored Jul 19, 2024
1 parent 0943223 commit 822fe2c
Show file tree
Hide file tree
Showing 4 changed files with 465 additions and 62 deletions.
7 changes: 4 additions & 3 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use requests::{
on_goto_definition_request, on_goto_type_definition_request, on_hover_request, on_initialize,
on_inlay_hint_request, on_prepare_rename_request, on_profile_run_request,
on_references_request, on_rename_request, on_shutdown, on_test_run_request, on_tests_request,
LspInitializationOptions,
};
use serde_json::Value as JsonValue;
use thiserror::Error;
Expand Down Expand Up @@ -85,7 +86,7 @@ pub struct LspState {
cached_lenses: HashMap<String, Vec<CodeLens>>,
cached_definitions: HashMap<String, NodeInterner>,
cached_parsed_files: HashMap<PathBuf, (usize, (ParsedModule, Vec<ParserError>))>,
parsing_cache_enabled: bool,
options: LspInitializationOptions,
}

impl LspState {
Expand All @@ -102,7 +103,7 @@ impl LspState {
cached_definitions: HashMap::new(),
open_documents_count: 0,
cached_parsed_files: HashMap::new(),
parsing_cache_enabled: true,
options: Default::default(),
}
}
}
Expand Down Expand Up @@ -341,7 +342,7 @@ fn prepare_source(source: String, state: &mut LspState) -> (Context<'static, 'st
}

fn parse_diff(file_manager: &FileManager, state: &mut LspState) -> ParsedFiles {
if state.parsing_cache_enabled {
if state.options.enable_parsing_cache {
let noir_file_hashes: Vec<_> = file_manager
.as_file_map()
.all_file_ids()
Expand Down
Loading

0 comments on commit 822fe2c

Please sign in to comment.