Skip to content

Commit

Permalink
chore: disable code lens feature of lsp (#3789)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves: 
**Disable Code Lens feature of LSP #3788**

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
kobyhallx authored Dec 13, 2023
1 parent 24ff886 commit c85b064
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 262 deletions.
5 changes: 2 additions & 3 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use notifications::{
on_did_open_text_document, on_did_save_text_document, on_exit, on_initialized,
};
use requests::{
on_code_lens_request, on_formatting, on_goto_definition_request, on_initialize,
on_profile_run_request, on_shutdown, on_test_run_request, on_tests_request,
on_formatting, on_goto_definition_request, on_initialize, on_profile_run_request, on_shutdown,
on_test_run_request, on_tests_request,
};
use serde_json::Value as JsonValue;
use tower::Service;
Expand Down Expand Up @@ -72,7 +72,6 @@ impl NargoLspService {
.request::<request::Initialize, _>(on_initialize)
.request::<request::Formatting, _>(on_formatting)
.request::<request::Shutdown, _>(on_shutdown)
.request::<request::CodeLens, _>(on_code_lens_request)
.request::<request::NargoTests, _>(on_tests_request)
.request::<request::NargoTestRun, _>(on_test_run_request)
.request::<request::NargoProfileRun, _>(on_profile_run_request)
Expand Down
3 changes: 0 additions & 3 deletions tooling/lsp/src/notifications/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ pub(super) fn on_did_save_text_document(
})
.collect();

// We need to refresh lenses when we compile since that's the only time they can be accurately reflected
std::mem::drop(state.client.code_lens_refresh(()));

let _ = state.client.publish_diagnostics(PublishDiagnosticsParams {
uri: params.text_document.uri,
version: None,
Expand Down
235 changes: 0 additions & 235 deletions tooling/lsp/src/requests/code_lens_request.rs

This file was deleted.

11 changes: 3 additions & 8 deletions tooling/lsp/src/requests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::future::Future;

use crate::types::{CodeLensOptions, InitializeParams};
use crate::types::InitializeParams;
use async_lsp::ResponseError;
use lsp_types::{Position, TextDocumentSyncCapability, TextDocumentSyncKind};
use nargo_fmt::Config;
Expand All @@ -20,15 +20,14 @@ use crate::{
// They are not attached to the `NargoLspService` struct so they can be unit tested with only `LspState`
// and params passed in.

mod code_lens_request;
mod goto_definition;
mod profile_run;
mod test_run;
mod tests;

pub(crate) use {
code_lens_request::on_code_lens_request, goto_definition::on_goto_definition_request,
profile_run::on_profile_run_request, test_run::on_test_run_request, tests::on_tests_request,
goto_definition::on_goto_definition_request, profile_run::on_profile_run_request,
test_run::on_test_run_request, tests::on_tests_request,
};

pub(crate) fn on_initialize(
Expand All @@ -40,8 +39,6 @@ pub(crate) fn on_initialize(
async {
let text_document_sync = TextDocumentSyncCapability::Kind(TextDocumentSyncKind::FULL);

let code_lens = CodeLensOptions { resolve_provider: Some(false) };

let nargo = NargoCapability {
tests: Some(NargoTestsOptions {
fetch: Some(true),
Expand All @@ -53,7 +50,6 @@ pub(crate) fn on_initialize(
Ok(InitializeResult {
capabilities: ServerCapabilities {
text_document_sync: Some(text_document_sync),
code_lens_provider: Some(code_lens),
document_formatting_provider: true,
nargo: Some(nargo),
definition_provider: Some(lsp_types::OneOf::Left(true)),
Expand Down Expand Up @@ -131,7 +127,6 @@ mod initialization {
text_document_sync: Some(TextDocumentSyncCapability::Kind(
TextDocumentSyncKind::FULL
)),
code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(false) }),
document_formatting_provider: true,
..
}
Expand Down
18 changes: 5 additions & 13 deletions tooling/lsp/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use std::collections::{BTreeMap, HashMap};

// Re-providing lsp_types that we don't need to override
pub(crate) use lsp_types::{
CodeLens, CodeLensOptions, CodeLensParams, Command, Diagnostic, DiagnosticSeverity,
DidChangeConfigurationParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams,
DidOpenTextDocumentParams, DidSaveTextDocumentParams, InitializeParams, InitializedParams,
LogMessageParams, MessageType, Position, PublishDiagnosticsParams, Range, ServerInfo,
TextDocumentSyncCapability, Url,
Diagnostic, DiagnosticSeverity, DidChangeConfigurationParams, DidChangeTextDocumentParams,
DidCloseTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams,
InitializeParams, InitializedParams, LogMessageParams, MessageType, Position,
PublishDiagnosticsParams, Range, ServerInfo, TextDocumentSyncCapability, Url,
};

pub(crate) mod request {
Expand All @@ -25,9 +24,7 @@ pub(crate) mod request {
};

// Re-providing lsp_types that we don't need to override
pub(crate) use lsp_types::request::{
CodeLensRequest as CodeLens, Formatting, GotoDefinition, Shutdown,
};
pub(crate) use lsp_types::request::{Formatting, GotoDefinition, Shutdown};

#[derive(Debug)]
pub(crate) struct Initialize;
Expand Down Expand Up @@ -115,10 +112,6 @@ pub(crate) struct ServerCapabilities {
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) definition_provider: Option<OneOf<bool, DefinitionOptions>>,

/// The server provides code lens.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) code_lens_provider: Option<CodeLensOptions>,

/// The server provides document formatting.
pub(crate) document_formatting_provider: bool,

Expand Down Expand Up @@ -221,5 +214,4 @@ pub(crate) struct NargoProfileRunResult {
pub(crate) opcodes_counts: HashMap<Location, OpCodesCount>,
}

pub(crate) type CodeLensResult = Option<Vec<CodeLens>>;
pub(crate) type GotoDefinitionResult = Option<lsp_types::GotoDefinitionResponse>;

0 comments on commit c85b064

Please sign in to comment.