Skip to content

Commit

Permalink
Emit No-op Code Action
Browse files Browse the repository at this point in the history
While nvim looks for code actions on-demand, VS Code pulls them regularly
and is strict about errors that can kill the LSP. This change emits a
no-op code action instead of an error, which is now the correct semantic.
  • Loading branch information
PatWie committed Sep 6, 2024
1 parent e176795 commit 501512d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/code_action_providers/lua/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::server::ResolveAction;

use super::bindings::LuaInterface;


pub struct LuaProvider {
prompt_handler: Arc<Llm>,
lua_source: String,
Expand Down
3 changes: 2 additions & 1 deletion src/code_action_providers/yaml/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::code_action_providers::traits::ActionContext;
use crate::code_action_providers::traits::ActionProvider;
use crate::code_action_providers::{helper, parsed_document::ParsedDocument};
use crate::llm_handlers::traits::Llm;
use crate::server::nop_codeaction;
use crate::server::ResolveAction;

use super::config;
Expand Down Expand Up @@ -117,7 +118,7 @@ impl ActionProvider for YamlProvider {
}
}
}
return Err(Error::new(tower_lsp::jsonrpc::ErrorCode::ParseError));
return Ok(nop_codeaction());
}
fn create_code_action(
&self,
Expand Down
13 changes: 13 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ impl std::fmt::Debug for Backend {
}
}

pub fn nop_codeaction() -> CodeAction {
CodeAction {
title: "cancel".to_owned(),
kind: None,
diagnostics: None,
edit: None,
command: None,
is_preferred: None,
disabled: None,
data: None,
}
}

#[tower_lsp::async_trait]
impl LanguageServer for Backend {
async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
Expand Down

0 comments on commit 501512d

Please sign in to comment.