Skip to content

Commit 979a0e4

Browse files
committed
Add a workspace syntax symbol picker
1 parent 5d6071f commit 979a0e4

File tree

7 files changed

+367
-7
lines changed

7 files changed

+367
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/generated/static-cmd.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
| `symbol_picker` | Open symbol picker | |
107107
| `changed_file_picker` | Open changed file picker | normal: `` <space>g ``, select: `` <space>g `` |
108108
| `select_references_to_symbol_under_cursor` | Select symbol references | normal: `` <space>h ``, select: `` <space>h `` |
109-
| `workspace_symbol_picker` | Open workspace symbol picker | normal: `` <space>S ``, select: `` <space>S `` |
109+
| `workspace_symbol_picker` | Open workspace symbol picker | |
110110
| `diagnostics_picker` | Open diagnostic picker | normal: `` <space>d ``, select: `` <space>d `` |
111111
| `workspace_diagnostics_picker` | Open workspace diagnostic picker | normal: `` <space>D ``, select: `` <space>D `` |
112112
| `last_picker` | Open last picker | normal: `` <space>' ``, select: `` <space>' `` |
@@ -295,4 +295,6 @@
295295
| `goto_next_tabstop` | goto next snippet placeholder | |
296296
| `goto_prev_tabstop` | goto next snippet placeholder | |
297297
| `syntax_symbol_picker` | Open a picker of symbols from the syntax tree | |
298+
| `syntax_workspace_symbol_picker` | Open a picker of symbols for the workspace based on syntax trees | |
298299
| `lsp_or_syntax_symbol_picker` | Open an LSP symbol picker if available, or syntax otherwise | normal: `` <space>s ``, select: `` <space>s `` |
300+
| `lsp_or_syntax_workspace_symbol_picker` | Open a workspace LSP symbol picker if available, or syntax workspace symbol picker otherwise | normal: `` <space>S ``, select: `` <space>S `` |

helix-loader/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
230230
/// Otherwise (workspace, false) is returned
231231
pub fn find_workspace() -> (PathBuf, bool) {
232232
let current_dir = current_working_dir();
233-
for ancestor in current_dir.ancestors() {
233+
find_workspace_in(current_dir)
234+
}
235+
236+
pub fn find_workspace_in(dir: impl AsRef<Path>) -> (PathBuf, bool) {
237+
let dir = dir.as_ref();
238+
for ancestor in dir.ancestors() {
234239
if ancestor.join(".git").exists()
235240
|| ancestor.join(".svn").exists()
236241
|| ancestor.join(".jj").exists()
@@ -240,7 +245,7 @@ pub fn find_workspace() -> (PathBuf, bool) {
240245
}
241246
}
242247

243-
(current_dir, true)
248+
(dir.to_owned(), true)
244249
}
245250

246251
fn default_config_file() -> PathBuf {

helix-term/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ serde = { version = "1.0", features = ["derive"] }
7272
grep-regex = "0.1.13"
7373
grep-searcher = "0.1.14"
7474

75+
dashmap = "6.0"
76+
7577
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
7678
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
7779
libc = "0.2.168"

helix-term/src/commands.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,9 @@ impl MappableCommand {
590590
goto_next_tabstop, "goto next snippet placeholder",
591591
goto_prev_tabstop, "goto next snippet placeholder",
592592
syntax_symbol_picker, "Open a picker of symbols from the syntax tree",
593+
syntax_workspace_symbol_picker, "Open a picker of symbols for the workspace based on syntax trees",
593594
lsp_or_syntax_symbol_picker, "Open an LSP symbol picker if available, or syntax otherwise",
595+
lsp_or_syntax_workspace_symbol_picker, "Open a workspace LSP symbol picker if available, or syntax workspace symbol picker otherwise",
594596
);
595597
}
596598

@@ -6520,3 +6522,17 @@ fn lsp_or_syntax_symbol_picker(cx: &mut Context) {
65206522
.set_error("No language server supporting document symbols or syntax info available");
65216523
}
65226524
}
6525+
6526+
fn lsp_or_syntax_workspace_symbol_picker(cx: &mut Context) {
6527+
let doc = doc!(cx.editor);
6528+
6529+
if doc
6530+
.language_servers_with_feature(LanguageServerFeature::WorkspaceSymbols)
6531+
.next()
6532+
.is_some()
6533+
{
6534+
lsp::workspace_symbol_picker(cx);
6535+
} else {
6536+
syntax_workspace_symbol_picker(cx);
6537+
}
6538+
}

0 commit comments

Comments
 (0)