Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for lsp workspace command arguments in prompt #12075

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,19 +1426,28 @@ fn lsp_workspace_command(
};
cx.jobs.callback(callback);
} else {
let command = args.join(" ");
let command = args.first().unwrap().to_string();

let matches: Vec<_> = ls_id_commands
.filter(|(_ls_id, c)| *c == &command)
.collect();

match matches.as_slice() {
[(ls_id, _command)] => {
let lsp_command_args: Vec<Value> = args[1..]
.iter()
.map(|s| Value::String(s.to_string()))
.collect();
Comment on lines +1437 to +1440
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're parsing a list of JSON values then we should use the streaming deserializer from serde_json like #12527 does for :toggle-option. The streaming deserializer will take a slightly different syntax for strings - :lsp-workspace-command lsp.Command "foo" "bar" - which would be a breaking change to the syntax added if we merge this as-is.

I'll include this change on that PR since it's not possible to parse the args accurately with the way we parse the command line on master

execute_lsp_command(
cx.editor,
*ls_id,
helix_lsp::lsp::Command {
title: command.clone(),
arguments: None,
arguments: if lsp_command_args.is_empty() {
None
} else {
Some(lsp_command_args)
},
command,
},
);
Expand Down