Skip to content

Commit

Permalink
Merge branch 'completion_preselect' into custom_merges
Browse files Browse the repository at this point in the history
  • Loading branch information
lazytanuki committed Jun 10, 2022
2 parents ba8b8c5 + ba40e71 commit aaa0924
Show file tree
Hide file tree
Showing 29 changed files with 355 additions and 174 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ hidden = false
| `auto-format` | Enable automatic formatting on save. | `true` |
| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
| `completion-doc-preview` | Show the documentation of the first item in the completion menu | `false` |
| `auto-info` | Whether to display infoboxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |

### `[editor.lsp]` Section

| Key | Description | Default |
| --- | ----------- | ------- |
| `display-messages` | Display LSP progress messages below statusline[^1] | `false` |
| Key | Description | Default |
| --- | ----------- | ------- |
| `display-messages` | Display LSP progress messages below statusline[^1] | `false` |
| `preselect` | Show the LSP server's preselected suggestions first | `true` |

[^1]: A progress spinner is always shown in the statusline beside the file path.

Expand Down
6 changes: 3 additions & 3 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
| edoc || | | |
| eex || | | |
| ejs || | | |
| elixir || | | `elixir-ls` |
| elixir || | | `elixir-ls` |
| elm || | | `elm-language-server` |
| erb || | | |
| erlang || | | `erlang_ls` |
| erlang || | | `erlang_ls` |
| fish |||| |
| gdscript || || |
| git-attributes || | | |
Expand All @@ -27,7 +27,7 @@
| git-diff || | | |
| git-ignore || | | |
| git-rebase || | | |
| gleam || | | |
| gleam || | | |
| glsl || || |
| go |||| `gopls` |
| gomod || | | `gopls` |
Expand Down
4 changes: 2 additions & 2 deletions helix-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ lsp-types = { version = "0.93", features = ["proposed"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
tokio = { version = "1.18", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
tokio-stream = "0.1.8"
tokio = { version = "1.19", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
tokio-stream = "0.1.9"
which = "4.2"
9 changes: 8 additions & 1 deletion helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,14 @@ impl Application {
self.lsp_progress.update(server_id, token, work);
}

if self.config.load().editor.lsp.display_messages {
if self
.config
.load()
.editor
.lsp
.display_messages
.unwrap_or(false)
{
self.editor.set_status(status);
}
}
Expand Down
53 changes: 31 additions & 22 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ impl ui::menu::Item for lsp::CodeActionOrCommand {
lsp::CodeActionOrCommand::Command(command) => command.title.as_str(),
}
}

fn preselected(&self) -> bool {
false
}
}

pub fn code_action(cx: &mut Context) {
Expand Down Expand Up @@ -252,34 +256,39 @@ pub fn code_action(cx: &mut Context) {
return;
}

let mut picker = ui::Menu::new(actions, move |editor, code_action, event| {
if event != PromptEvent::Validate {
return;
}
let mut picker = ui::Menu::new(
actions,
ui::menu::SortStrategy::Text,
false,
move |editor, code_action, event| {
if event != PromptEvent::Validate {
return;
}

// always present here
let code_action = code_action.unwrap();
// always present here
let code_action = code_action.unwrap();

match code_action {
lsp::CodeActionOrCommand::Command(command) => {
log::debug!("code action command: {:?}", command);
execute_lsp_command(editor, command.clone());
}
lsp::CodeActionOrCommand::CodeAction(code_action) => {
log::debug!("code action: {:?}", code_action);
if let Some(ref workspace_edit) = code_action.edit {
log::debug!("edit: {:?}", workspace_edit);
apply_workspace_edit(editor, offset_encoding, workspace_edit);
match code_action {
lsp::CodeActionOrCommand::Command(command) => {
log::debug!("code action command: {:?}", command);
execute_lsp_command(editor, command.clone());
}
lsp::CodeActionOrCommand::CodeAction(code_action) => {
log::debug!("code action: {:?}", code_action);
if let Some(ref workspace_edit) = code_action.edit {
log::debug!("edit: {:?}", workspace_edit);
apply_workspace_edit(editor, offset_encoding, workspace_edit);
}

// if code action provides both edit and command first the edit
// should be applied and then the command
if let Some(command) = &code_action.command {
execute_lsp_command(editor, command.clone());
// if code action provides both edit and command first the edit
// should be applied and then the command
if let Some(command) = &code_action.command {
execute_lsp_command(editor, command.clone());
}
}
}
}
});
},
);
picker.move_down(); // pre-select the first item

let popup = Popup::new("code-action", picker).margin(helix_view::graphics::Margin {
Expand Down
Loading

0 comments on commit aaa0924

Please sign in to comment.