mirror of
https://github.com/helix-editor/helix.git
synced 2025-10-06 00:13:28 +02:00
Compare commits
4 Commits
d0218f7e78
...
syntax-sym
Author | SHA1 | Date | |
---|---|---|---|
|
5ea92d1713 | ||
|
ece331855e | ||
|
4d49513c9e | ||
|
b24024f93f |
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1547,6 +1547,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"content_inspector",
|
||||
"crossterm",
|
||||
"dashmap",
|
||||
"fern",
|
||||
"futures-util",
|
||||
"grep-regex",
|
||||
|
@@ -28,3 +28,4 @@
|
||||
- [Adding textobject queries](./guides/textobject.md)
|
||||
- [Adding indent queries](./guides/indent.md)
|
||||
- [Adding injection queries](./guides/injection.md)
|
||||
- [Adding tags queries](./guides/tags.md)
|
||||
|
@@ -1,279 +1,279 @@
|
||||
| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default language servers |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| ada | ✓ | ✓ | | `ada_language_server` |
|
||||
| adl | ✓ | ✓ | ✓ | |
|
||||
| agda | ✓ | | | |
|
||||
| alloy | ✓ | | | |
|
||||
| amber | ✓ | | | `amber-lsp` |
|
||||
| astro | ✓ | | | `astro-ls` |
|
||||
| awk | ✓ | ✓ | | `awk-language-server` |
|
||||
| bash | ✓ | ✓ | ✓ | `bash-language-server` |
|
||||
| bass | ✓ | | | `bass` |
|
||||
| beancount | ✓ | | | `beancount-language-server` |
|
||||
| bibtex | ✓ | | | `texlab` |
|
||||
| bicep | ✓ | | | `bicep-langserver` |
|
||||
| bitbake | ✓ | | | `bitbake-language-server` |
|
||||
| blade | ✓ | | | |
|
||||
| blueprint | ✓ | | | `blueprint-compiler` |
|
||||
| c | ✓ | ✓ | ✓ | `clangd` |
|
||||
| c-sharp | ✓ | ✓ | | `OmniSharp` |
|
||||
| cabal | | | | `haskell-language-server-wrapper` |
|
||||
| caddyfile | ✓ | ✓ | ✓ | |
|
||||
| cairo | ✓ | ✓ | ✓ | `cairo-language-server` |
|
||||
| capnp | ✓ | | ✓ | |
|
||||
| cel | ✓ | | | |
|
||||
| circom | ✓ | | | `circom-lsp` |
|
||||
| clarity | ✓ | | | `clarinet` |
|
||||
| clojure | ✓ | | | `clojure-lsp` |
|
||||
| cmake | ✓ | ✓ | ✓ | `neocmakelsp`, `cmake-language-server` |
|
||||
| codeql | ✓ | ✓ | | `codeql` |
|
||||
| comment | ✓ | | | |
|
||||
| common-lisp | ✓ | | ✓ | `cl-lsp` |
|
||||
| cpon | ✓ | | ✓ | |
|
||||
| cpp | ✓ | ✓ | ✓ | `clangd` |
|
||||
| crystal | ✓ | ✓ | ✓ | `crystalline`, `ameba-ls` |
|
||||
| css | ✓ | | ✓ | `vscode-css-language-server` |
|
||||
| csv | ✓ | | | |
|
||||
| cue | ✓ | | | `cuelsp` |
|
||||
| cylc | ✓ | ✓ | ✓ | |
|
||||
| d | ✓ | ✓ | ✓ | `serve-d` |
|
||||
| dart | ✓ | ✓ | ✓ | `dart` |
|
||||
| dbml | ✓ | | | |
|
||||
| debian | ✓ | | | |
|
||||
| devicetree | ✓ | | | `dts-lsp` |
|
||||
| dhall | ✓ | ✓ | | `dhall-lsp-server` |
|
||||
| diff | ✓ | | | |
|
||||
| djot | ✓ | | | |
|
||||
| docker-compose | ✓ | ✓ | ✓ | `docker-compose-langserver`, `yaml-language-server` |
|
||||
| dockerfile | ✓ | ✓ | | `docker-langserver` |
|
||||
| dot | ✓ | | | `dot-language-server` |
|
||||
| dtd | ✓ | | | |
|
||||
| dune | ✓ | | | |
|
||||
| dunstrc | ✓ | | | |
|
||||
| earthfile | ✓ | ✓ | ✓ | `earthlyls` |
|
||||
| edoc | ✓ | | | |
|
||||
| eex | ✓ | | | |
|
||||
| ejs | ✓ | | | |
|
||||
| elisp | ✓ | | | |
|
||||
| elixir | ✓ | ✓ | ✓ | `elixir-ls` |
|
||||
| elm | ✓ | ✓ | | `elm-language-server` |
|
||||
| elvish | ✓ | | | `elvish` |
|
||||
| env | ✓ | ✓ | | |
|
||||
| erb | ✓ | | | |
|
||||
| erlang | ✓ | ✓ | | `erlang_ls`, `elp` |
|
||||
| esdl | ✓ | | | |
|
||||
| fennel | ✓ | | | `fennel-ls` |
|
||||
| fga | ✓ | ✓ | ✓ | |
|
||||
| fidl | ✓ | | | |
|
||||
| fish | ✓ | ✓ | ✓ | `fish-lsp` |
|
||||
| forth | ✓ | | | `forth-lsp` |
|
||||
| fortran | ✓ | | ✓ | `fortls` |
|
||||
| fsharp | ✓ | | | `fsautocomplete` |
|
||||
| gas | ✓ | ✓ | | `asm-lsp` |
|
||||
| gdscript | ✓ | ✓ | ✓ | |
|
||||
| gemini | ✓ | | | |
|
||||
| gherkin | ✓ | | | |
|
||||
| ghostty | ✓ | | | |
|
||||
| git-attributes | ✓ | | | |
|
||||
| git-commit | ✓ | ✓ | | |
|
||||
| git-config | ✓ | ✓ | | |
|
||||
| git-ignore | ✓ | | | |
|
||||
| git-notes | ✓ | | | |
|
||||
| git-rebase | ✓ | | | |
|
||||
| gjs | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
|
||||
| gleam | ✓ | ✓ | | `gleam` |
|
||||
| glimmer | ✓ | | | `ember-language-server` |
|
||||
| glsl | ✓ | ✓ | ✓ | `glsl_analyzer` |
|
||||
| gn | ✓ | | | |
|
||||
| go | ✓ | ✓ | ✓ | `gopls`, `golangci-lint-langserver` |
|
||||
| godot-resource | ✓ | ✓ | | |
|
||||
| gomod | ✓ | | | `gopls` |
|
||||
| gotmpl | ✓ | | | `gopls` |
|
||||
| gowork | ✓ | | | `gopls` |
|
||||
| gpr | ✓ | | | `ada_language_server` |
|
||||
| graphql | ✓ | ✓ | | `graphql-lsp` |
|
||||
| gren | ✓ | ✓ | | |
|
||||
| groovy | ✓ | | | |
|
||||
| gts | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
|
||||
| hare | ✓ | | | |
|
||||
| haskell | ✓ | ✓ | | `haskell-language-server-wrapper` |
|
||||
| haskell-persistent | ✓ | | | |
|
||||
| hcl | ✓ | ✓ | ✓ | `terraform-ls` |
|
||||
| heex | ✓ | ✓ | | `elixir-ls` |
|
||||
| helm | ✓ | | | `helm_ls` |
|
||||
| hocon | ✓ | ✓ | ✓ | |
|
||||
| hoon | ✓ | | | |
|
||||
| hosts | ✓ | | | |
|
||||
| html | ✓ | | | `vscode-html-language-server`, `superhtml` |
|
||||
| htmldjango | ✓ | | | `djlsp`, `vscode-html-language-server`, `superhtml` |
|
||||
| hurl | ✓ | ✓ | ✓ | |
|
||||
| hyprlang | ✓ | | ✓ | `hyprls` |
|
||||
| idris | | | | `idris2-lsp` |
|
||||
| iex | ✓ | | | |
|
||||
| ini | ✓ | | | |
|
||||
| ink | ✓ | | | |
|
||||
| inko | ✓ | ✓ | ✓ | |
|
||||
| janet | ✓ | | | |
|
||||
| java | ✓ | ✓ | ✓ | `jdtls` |
|
||||
| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| jinja | ✓ | | | |
|
||||
| jjdescription | ✓ | | | |
|
||||
| jq | ✓ | ✓ | | `jq-lsp` |
|
||||
| jsdoc | ✓ | | | |
|
||||
| json | ✓ | ✓ | ✓ | `vscode-json-language-server` |
|
||||
| json-ld | ✓ | ✓ | ✓ | `vscode-json-language-server` |
|
||||
| json5 | ✓ | | | |
|
||||
| jsonc | ✓ | | ✓ | `vscode-json-language-server` |
|
||||
| jsonnet | ✓ | | | `jsonnet-language-server` |
|
||||
| jsx | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| julia | ✓ | ✓ | ✓ | `julia` |
|
||||
| just | ✓ | ✓ | ✓ | `just-lsp` |
|
||||
| kdl | ✓ | ✓ | ✓ | |
|
||||
| koka | ✓ | | ✓ | `koka` |
|
||||
| kotlin | ✓ | ✓ | ✓ | `kotlin-language-server` |
|
||||
| koto | ✓ | ✓ | ✓ | `koto-ls` |
|
||||
| latex | ✓ | ✓ | | `texlab` |
|
||||
| ld | ✓ | | ✓ | |
|
||||
| ldif | ✓ | | | |
|
||||
| lean | ✓ | | | `lean` |
|
||||
| ledger | ✓ | | | |
|
||||
| llvm | ✓ | ✓ | ✓ | |
|
||||
| llvm-mir | ✓ | ✓ | ✓ | |
|
||||
| llvm-mir-yaml | ✓ | | ✓ | |
|
||||
| log | ✓ | | | |
|
||||
| lpf | ✓ | | | |
|
||||
| lua | ✓ | ✓ | ✓ | `lua-language-server` |
|
||||
| luau | ✓ | ✓ | ✓ | `luau-lsp` |
|
||||
| mail | ✓ | ✓ | | |
|
||||
| make | ✓ | | ✓ | |
|
||||
| markdoc | ✓ | | | `markdoc-ls` |
|
||||
| markdown | ✓ | | | `marksman`, `markdown-oxide` |
|
||||
| markdown-rustdoc | ✓ | | | |
|
||||
| markdown.inline | ✓ | | | |
|
||||
| matlab | ✓ | ✓ | ✓ | |
|
||||
| mermaid | ✓ | | | |
|
||||
| meson | ✓ | | ✓ | `mesonlsp` |
|
||||
| mint | | | | `mint` |
|
||||
| mojo | ✓ | ✓ | ✓ | `pixi` |
|
||||
| move | ✓ | | | |
|
||||
| msbuild | ✓ | | ✓ | |
|
||||
| nasm | ✓ | ✓ | | `asm-lsp` |
|
||||
| nestedtext | ✓ | ✓ | ✓ | |
|
||||
| nginx | ✓ | | | |
|
||||
| nickel | ✓ | | ✓ | `nls` |
|
||||
| nim | ✓ | ✓ | ✓ | `nimlangserver` |
|
||||
| nix | ✓ | ✓ | ✓ | `nil`, `nixd` |
|
||||
| nu | ✓ | | | `nu` |
|
||||
| nunjucks | ✓ | | | |
|
||||
| ocaml | ✓ | | ✓ | `ocamllsp` |
|
||||
| ocaml-interface | ✓ | | | `ocamllsp` |
|
||||
| odin | ✓ | ✓ | ✓ | `ols` |
|
||||
| ohm | ✓ | ✓ | ✓ | |
|
||||
| opencl | ✓ | ✓ | ✓ | `clangd` |
|
||||
| openscad | ✓ | | | `openscad-lsp` |
|
||||
| org | ✓ | | | |
|
||||
| pascal | ✓ | ✓ | | `pasls` |
|
||||
| passwd | ✓ | | | |
|
||||
| pem | ✓ | | | |
|
||||
| perl | ✓ | ✓ | ✓ | `perlnavigator` |
|
||||
| pest | ✓ | ✓ | ✓ | `pest-language-server` |
|
||||
| php | ✓ | ✓ | ✓ | `intelephense` |
|
||||
| php-only | ✓ | | | |
|
||||
| pkgbuild | ✓ | ✓ | ✓ | `termux-language-server`, `bash-language-server` |
|
||||
| pkl | ✓ | | ✓ | `pkl-lsp` |
|
||||
| po | ✓ | ✓ | | |
|
||||
| pod | ✓ | | | |
|
||||
| ponylang | ✓ | ✓ | ✓ | |
|
||||
| powershell | ✓ | | | |
|
||||
| prisma | ✓ | ✓ | | `prisma-language-server` |
|
||||
| prolog | ✓ | | ✓ | `swipl` |
|
||||
| properties | ✓ | ✓ | | |
|
||||
| protobuf | ✓ | ✓ | ✓ | `buf`, `pb`, `protols` |
|
||||
| prql | ✓ | | | |
|
||||
| pug | ✓ | | | |
|
||||
| purescript | ✓ | ✓ | | `purescript-language-server` |
|
||||
| python | ✓ | ✓ | ✓ | `ty`, `ruff`, `jedi-language-server`, `pylsp` |
|
||||
| qml | ✓ | ✓ | ✓ | `qmlls` |
|
||||
| quarto | ✓ | | ✓ | |
|
||||
| quint | ✓ | | | `quint-language-server` |
|
||||
| r | ✓ | | | `R` |
|
||||
| racket | ✓ | | ✓ | `racket` |
|
||||
| regex | ✓ | | | |
|
||||
| rego | ✓ | | | `regols` |
|
||||
| rescript | ✓ | ✓ | | `rescript-language-server` |
|
||||
| rmarkdown | ✓ | | ✓ | `R` |
|
||||
| robot | ✓ | | | `robotframework_ls` |
|
||||
| ron | ✓ | | ✓ | |
|
||||
| rst | ✓ | | | |
|
||||
| ruby | ✓ | ✓ | ✓ | `ruby-lsp`, `solargraph` |
|
||||
| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
|
||||
| rust-format-args | ✓ | | | |
|
||||
| rust-format-args-macro | ✓ | ✓ | ✓ | |
|
||||
| sage | ✓ | ✓ | | |
|
||||
| scala | ✓ | ✓ | ✓ | `metals` |
|
||||
| scheme | ✓ | | ✓ | |
|
||||
| scss | ✓ | | | `vscode-css-language-server` |
|
||||
| slang | ✓ | ✓ | ✓ | `slangd` |
|
||||
| slint | ✓ | ✓ | ✓ | `slint-lsp` |
|
||||
| smali | ✓ | | ✓ | |
|
||||
| smithy | ✓ | | | `cs` |
|
||||
| sml | ✓ | | | |
|
||||
| snakemake | ✓ | | ✓ | `pylsp` |
|
||||
| solidity | ✓ | ✓ | | `solc` |
|
||||
| sourcepawn | ✓ | ✓ | | `sourcepawn-studio` |
|
||||
| spade | ✓ | | ✓ | `spade-language-server` |
|
||||
| spicedb | ✓ | | | |
|
||||
| sql | ✓ | ✓ | | |
|
||||
| sshclientconfig | ✓ | | | |
|
||||
| starlark | ✓ | ✓ | ✓ | `starpls` |
|
||||
| strace | ✓ | | | |
|
||||
| supercollider | ✓ | | | |
|
||||
| svelte | ✓ | | ✓ | `svelteserver` |
|
||||
| sway | ✓ | ✓ | ✓ | `forc` |
|
||||
| swift | ✓ | ✓ | | `sourcekit-lsp` |
|
||||
| systemd | ✓ | | | `systemd-lsp` |
|
||||
| t32 | ✓ | | | |
|
||||
| tablegen | ✓ | ✓ | ✓ | |
|
||||
| tact | ✓ | ✓ | ✓ | |
|
||||
| task | ✓ | | | |
|
||||
| tcl | ✓ | | ✓ | |
|
||||
| teal | ✓ | | | `teal-language-server` |
|
||||
| templ | ✓ | | | `templ` |
|
||||
| tera | ✓ | | | |
|
||||
| textproto | ✓ | ✓ | ✓ | |
|
||||
| tfvars | ✓ | | ✓ | `terraform-ls` |
|
||||
| thrift | ✓ | | | |
|
||||
| tlaplus | ✓ | | | |
|
||||
| todotxt | ✓ | | | |
|
||||
| toml | ✓ | ✓ | | `taplo`, `tombi` |
|
||||
| tsq | ✓ | | | `ts_query_ls` |
|
||||
| tsx | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| twig | ✓ | | | |
|
||||
| typescript | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| typespec | ✓ | ✓ | ✓ | `tsp-server` |
|
||||
| typst | ✓ | | | `tinymist` |
|
||||
| ungrammar | ✓ | | | |
|
||||
| unison | ✓ | ✓ | ✓ | |
|
||||
| uxntal | ✓ | | | |
|
||||
| v | ✓ | ✓ | ✓ | `v-analyzer` |
|
||||
| vala | ✓ | ✓ | | `vala-language-server` |
|
||||
| vento | ✓ | | | |
|
||||
| verilog | ✓ | ✓ | | `svlangserver` |
|
||||
| vhdl | ✓ | | | `vhdl_ls` |
|
||||
| vhs | ✓ | | | |
|
||||
| vue | ✓ | | | `vue-language-server` |
|
||||
| wast | ✓ | | | |
|
||||
| wat | ✓ | | | `wat_server` |
|
||||
| webc | ✓ | | | |
|
||||
| werk | ✓ | | | |
|
||||
| wesl | ✓ | ✓ | | |
|
||||
| wgsl | ✓ | | | `wgsl-analyzer` |
|
||||
| wit | ✓ | | ✓ | |
|
||||
| wren | ✓ | ✓ | ✓ | |
|
||||
| xit | ✓ | | | |
|
||||
| xml | ✓ | | ✓ | |
|
||||
| xtc | ✓ | | | |
|
||||
| yaml | ✓ | ✓ | ✓ | `yaml-language-server`, `ansible-language-server` |
|
||||
| yara | ✓ | | | `yls` |
|
||||
| yuck | ✓ | | | |
|
||||
| zig | ✓ | ✓ | ✓ | `zls` |
|
||||
| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Code Navigation Tags | Default language servers |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| ada | ✓ | ✓ | | | `ada_language_server` |
|
||||
| adl | ✓ | ✓ | ✓ | | |
|
||||
| agda | ✓ | | | | |
|
||||
| alloy | ✓ | | | | |
|
||||
| amber | ✓ | | | | `amber-lsp` |
|
||||
| astro | ✓ | | | | `astro-ls` |
|
||||
| awk | ✓ | ✓ | | | `awk-language-server` |
|
||||
| bash | ✓ | ✓ | ✓ | | `bash-language-server` |
|
||||
| bass | ✓ | | | | `bass` |
|
||||
| beancount | ✓ | | | | `beancount-language-server` |
|
||||
| bibtex | ✓ | | | | `texlab` |
|
||||
| bicep | ✓ | | | | `bicep-langserver` |
|
||||
| bitbake | ✓ | | | | `bitbake-language-server` |
|
||||
| blade | ✓ | | | | |
|
||||
| blueprint | ✓ | | | | `blueprint-compiler` |
|
||||
| c | ✓ | ✓ | ✓ | ✓ | `clangd` |
|
||||
| c-sharp | ✓ | ✓ | | ✓ | `OmniSharp` |
|
||||
| cabal | | | | | `haskell-language-server-wrapper` |
|
||||
| caddyfile | ✓ | ✓ | ✓ | | |
|
||||
| cairo | ✓ | ✓ | ✓ | | `cairo-language-server` |
|
||||
| capnp | ✓ | | ✓ | | |
|
||||
| cel | ✓ | | | | |
|
||||
| circom | ✓ | | | | `circom-lsp` |
|
||||
| clarity | ✓ | | | | `clarinet` |
|
||||
| clojure | ✓ | | | | `clojure-lsp` |
|
||||
| cmake | ✓ | ✓ | ✓ | | `neocmakelsp`, `cmake-language-server` |
|
||||
| codeql | ✓ | ✓ | | | `codeql` |
|
||||
| comment | ✓ | | | | |
|
||||
| common-lisp | ✓ | | ✓ | | `cl-lsp` |
|
||||
| cpon | ✓ | | ✓ | | |
|
||||
| cpp | ✓ | ✓ | ✓ | ✓ | `clangd` |
|
||||
| crystal | ✓ | ✓ | ✓ | ✓ | `crystalline`, `ameba-ls` |
|
||||
| css | ✓ | | ✓ | | `vscode-css-language-server` |
|
||||
| csv | ✓ | | | | |
|
||||
| cue | ✓ | | | | `cuelsp` |
|
||||
| cylc | ✓ | ✓ | ✓ | | |
|
||||
| d | ✓ | ✓ | ✓ | | `serve-d` |
|
||||
| dart | ✓ | ✓ | ✓ | | `dart` |
|
||||
| dbml | ✓ | | | | |
|
||||
| debian | ✓ | | | | |
|
||||
| devicetree | ✓ | | | | `dts-lsp` |
|
||||
| dhall | ✓ | ✓ | | | `dhall-lsp-server` |
|
||||
| diff | ✓ | | | | |
|
||||
| djot | ✓ | | | | |
|
||||
| docker-compose | ✓ | ✓ | ✓ | | `docker-compose-langserver`, `yaml-language-server` |
|
||||
| dockerfile | ✓ | ✓ | | | `docker-langserver` |
|
||||
| dot | ✓ | | | | `dot-language-server` |
|
||||
| dtd | ✓ | | | | |
|
||||
| dune | ✓ | | | | |
|
||||
| dunstrc | ✓ | | | | |
|
||||
| earthfile | ✓ | ✓ | ✓ | | `earthlyls` |
|
||||
| edoc | ✓ | | | | |
|
||||
| eex | ✓ | | | | |
|
||||
| ejs | ✓ | | | | |
|
||||
| elisp | ✓ | | | ✓ | |
|
||||
| elixir | ✓ | ✓ | ✓ | ✓ | `elixir-ls` |
|
||||
| elm | ✓ | ✓ | | ✓ | `elm-language-server` |
|
||||
| elvish | ✓ | | | | `elvish` |
|
||||
| env | ✓ | ✓ | | | |
|
||||
| erb | ✓ | | | | |
|
||||
| erlang | ✓ | ✓ | | ✓ | `erlang_ls`, `elp` |
|
||||
| esdl | ✓ | | | | |
|
||||
| fennel | ✓ | | | | `fennel-ls` |
|
||||
| fga | ✓ | ✓ | ✓ | | |
|
||||
| fidl | ✓ | | | | |
|
||||
| fish | ✓ | ✓ | ✓ | | `fish-lsp` |
|
||||
| forth | ✓ | | | | `forth-lsp` |
|
||||
| fortran | ✓ | | ✓ | | `fortls` |
|
||||
| fsharp | ✓ | | | | `fsautocomplete` |
|
||||
| gas | ✓ | ✓ | | | `asm-lsp` |
|
||||
| gdscript | ✓ | ✓ | ✓ | ✓ | |
|
||||
| gemini | ✓ | | | | |
|
||||
| gherkin | ✓ | | | | |
|
||||
| ghostty | ✓ | | | | |
|
||||
| git-attributes | ✓ | | | | |
|
||||
| git-commit | ✓ | ✓ | | | |
|
||||
| git-config | ✓ | ✓ | | | |
|
||||
| git-ignore | ✓ | | | | |
|
||||
| git-notes | ✓ | | | | |
|
||||
| git-rebase | ✓ | | | | |
|
||||
| gjs | ✓ | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
|
||||
| gleam | ✓ | ✓ | | | `gleam` |
|
||||
| glimmer | ✓ | | | | `ember-language-server` |
|
||||
| glsl | ✓ | ✓ | ✓ | | `glsl_analyzer` |
|
||||
| gn | ✓ | | | | |
|
||||
| go | ✓ | ✓ | ✓ | ✓ | `gopls`, `golangci-lint-langserver` |
|
||||
| godot-resource | ✓ | ✓ | | | |
|
||||
| gomod | ✓ | | | | `gopls` |
|
||||
| gotmpl | ✓ | | | | `gopls` |
|
||||
| gowork | ✓ | | | | `gopls` |
|
||||
| gpr | ✓ | | | | `ada_language_server` |
|
||||
| graphql | ✓ | ✓ | | | `graphql-lsp` |
|
||||
| gren | ✓ | ✓ | | | |
|
||||
| groovy | ✓ | | | | |
|
||||
| gts | ✓ | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` |
|
||||
| hare | ✓ | | | | |
|
||||
| haskell | ✓ | ✓ | | | `haskell-language-server-wrapper` |
|
||||
| haskell-persistent | ✓ | | | | |
|
||||
| hcl | ✓ | ✓ | ✓ | | `terraform-ls` |
|
||||
| heex | ✓ | ✓ | | | `elixir-ls` |
|
||||
| helm | ✓ | | | | `helm_ls` |
|
||||
| hocon | ✓ | ✓ | ✓ | | |
|
||||
| hoon | ✓ | | | | |
|
||||
| hosts | ✓ | | | | |
|
||||
| html | ✓ | | | | `vscode-html-language-server`, `superhtml` |
|
||||
| htmldjango | ✓ | | | | `djlsp`, `vscode-html-language-server`, `superhtml` |
|
||||
| hurl | ✓ | ✓ | ✓ | | |
|
||||
| hyprlang | ✓ | | ✓ | | `hyprls` |
|
||||
| idris | | | | | `idris2-lsp` |
|
||||
| iex | ✓ | | | | |
|
||||
| ini | ✓ | | | | |
|
||||
| ink | ✓ | | | | |
|
||||
| inko | ✓ | ✓ | ✓ | | |
|
||||
| janet | ✓ | | | | |
|
||||
| java | ✓ | ✓ | ✓ | | `jdtls` |
|
||||
| javascript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| jinja | ✓ | | | | |
|
||||
| jjdescription | ✓ | | | | |
|
||||
| jq | ✓ | ✓ | | | `jq-lsp` |
|
||||
| jsdoc | ✓ | | | | |
|
||||
| json | ✓ | ✓ | ✓ | | `vscode-json-language-server` |
|
||||
| json-ld | ✓ | ✓ | ✓ | | `vscode-json-language-server` |
|
||||
| json5 | ✓ | | | | |
|
||||
| jsonc | ✓ | | ✓ | | `vscode-json-language-server` |
|
||||
| jsonnet | ✓ | | | | `jsonnet-language-server` |
|
||||
| jsx | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| julia | ✓ | ✓ | ✓ | | `julia` |
|
||||
| just | ✓ | ✓ | ✓ | | `just-lsp` |
|
||||
| kdl | ✓ | ✓ | ✓ | | |
|
||||
| koka | ✓ | | ✓ | | `koka` |
|
||||
| kotlin | ✓ | ✓ | ✓ | | `kotlin-language-server` |
|
||||
| koto | ✓ | ✓ | ✓ | | `koto-ls` |
|
||||
| latex | ✓ | ✓ | | | `texlab` |
|
||||
| ld | ✓ | | ✓ | | |
|
||||
| ldif | ✓ | | | | |
|
||||
| lean | ✓ | | | | `lean` |
|
||||
| ledger | ✓ | | | | |
|
||||
| llvm | ✓ | ✓ | ✓ | | |
|
||||
| llvm-mir | ✓ | ✓ | ✓ | | |
|
||||
| llvm-mir-yaml | ✓ | | ✓ | | |
|
||||
| log | ✓ | | | | |
|
||||
| lpf | ✓ | | | | |
|
||||
| lua | ✓ | ✓ | ✓ | | `lua-language-server` |
|
||||
| luau | ✓ | ✓ | ✓ | | `luau-lsp` |
|
||||
| mail | ✓ | ✓ | | | |
|
||||
| make | ✓ | | ✓ | | |
|
||||
| markdoc | ✓ | | | | `markdoc-ls` |
|
||||
| markdown | ✓ | | | ✓ | `marksman`, `markdown-oxide` |
|
||||
| markdown-rustdoc | ✓ | | | | |
|
||||
| markdown.inline | ✓ | | | | |
|
||||
| matlab | ✓ | ✓ | ✓ | | |
|
||||
| mermaid | ✓ | | | | |
|
||||
| meson | ✓ | | ✓ | | `mesonlsp` |
|
||||
| mint | | | | | `mint` |
|
||||
| mojo | ✓ | ✓ | ✓ | | `pixi` |
|
||||
| move | ✓ | | | | |
|
||||
| msbuild | ✓ | | ✓ | | |
|
||||
| nasm | ✓ | ✓ | | | `asm-lsp` |
|
||||
| nestedtext | ✓ | ✓ | ✓ | | |
|
||||
| nginx | ✓ | | | | |
|
||||
| nickel | ✓ | | ✓ | | `nls` |
|
||||
| nim | ✓ | ✓ | ✓ | | `nimlangserver` |
|
||||
| nix | ✓ | ✓ | ✓ | | `nil`, `nixd` |
|
||||
| nu | ✓ | | | | `nu` |
|
||||
| nunjucks | ✓ | | | | |
|
||||
| ocaml | ✓ | | ✓ | | `ocamllsp` |
|
||||
| ocaml-interface | ✓ | | | | `ocamllsp` |
|
||||
| odin | ✓ | ✓ | ✓ | | `ols` |
|
||||
| ohm | ✓ | ✓ | ✓ | | |
|
||||
| opencl | ✓ | ✓ | ✓ | | `clangd` |
|
||||
| openscad | ✓ | | | | `openscad-lsp` |
|
||||
| org | ✓ | | | | |
|
||||
| pascal | ✓ | ✓ | | | `pasls` |
|
||||
| passwd | ✓ | | | | |
|
||||
| pem | ✓ | | | | |
|
||||
| perl | ✓ | ✓ | ✓ | | `perlnavigator` |
|
||||
| pest | ✓ | ✓ | ✓ | | `pest-language-server` |
|
||||
| php | ✓ | ✓ | ✓ | ✓ | `intelephense` |
|
||||
| php-only | ✓ | | | ✓ | |
|
||||
| pkgbuild | ✓ | ✓ | ✓ | | `termux-language-server`, `bash-language-server` |
|
||||
| pkl | ✓ | | ✓ | | `pkl-lsp` |
|
||||
| po | ✓ | ✓ | | | |
|
||||
| pod | ✓ | | | | |
|
||||
| ponylang | ✓ | ✓ | ✓ | | |
|
||||
| powershell | ✓ | | | | |
|
||||
| prisma | ✓ | ✓ | | | `prisma-language-server` |
|
||||
| prolog | ✓ | | ✓ | | `swipl` |
|
||||
| properties | ✓ | ✓ | | | |
|
||||
| protobuf | ✓ | ✓ | ✓ | | `buf`, `pb`, `protols` |
|
||||
| prql | ✓ | | | | |
|
||||
| pug | ✓ | | | | |
|
||||
| purescript | ✓ | ✓ | | | `purescript-language-server` |
|
||||
| python | ✓ | ✓ | ✓ | ✓ | `ty`, `ruff`, `jedi-language-server`, `pylsp` |
|
||||
| qml | ✓ | ✓ | ✓ | | `qmlls` |
|
||||
| quarto | ✓ | | ✓ | | |
|
||||
| quint | ✓ | | | | `quint-language-server` |
|
||||
| r | ✓ | | | | `R` |
|
||||
| racket | ✓ | | ✓ | | `racket` |
|
||||
| regex | ✓ | | | | |
|
||||
| rego | ✓ | | | | `regols` |
|
||||
| rescript | ✓ | ✓ | | | `rescript-language-server` |
|
||||
| rmarkdown | ✓ | | ✓ | | `R` |
|
||||
| robot | ✓ | | | | `robotframework_ls` |
|
||||
| ron | ✓ | | ✓ | | |
|
||||
| rst | ✓ | | | | |
|
||||
| ruby | ✓ | ✓ | ✓ | ✓ | `ruby-lsp`, `solargraph` |
|
||||
| rust | ✓ | ✓ | ✓ | ✓ | `rust-analyzer` |
|
||||
| rust-format-args | ✓ | | | | |
|
||||
| rust-format-args-macro | ✓ | ✓ | ✓ | | |
|
||||
| sage | ✓ | ✓ | | | |
|
||||
| scala | ✓ | ✓ | ✓ | | `metals` |
|
||||
| scheme | ✓ | | ✓ | | |
|
||||
| scss | ✓ | | | | `vscode-css-language-server` |
|
||||
| slang | ✓ | ✓ | ✓ | | `slangd` |
|
||||
| slint | ✓ | ✓ | ✓ | | `slint-lsp` |
|
||||
| smali | ✓ | | ✓ | | |
|
||||
| smithy | ✓ | | | | `cs` |
|
||||
| sml | ✓ | | | | |
|
||||
| snakemake | ✓ | | ✓ | | `pylsp` |
|
||||
| solidity | ✓ | ✓ | | | `solc` |
|
||||
| sourcepawn | ✓ | ✓ | | | `sourcepawn-studio` |
|
||||
| spade | ✓ | | ✓ | | `spade-language-server` |
|
||||
| spicedb | ✓ | | | ✓ | |
|
||||
| sql | ✓ | ✓ | | | |
|
||||
| sshclientconfig | ✓ | | | | |
|
||||
| starlark | ✓ | ✓ | ✓ | | `starpls` |
|
||||
| strace | ✓ | | | | |
|
||||
| supercollider | ✓ | | | | |
|
||||
| svelte | ✓ | | ✓ | | `svelteserver` |
|
||||
| sway | ✓ | ✓ | ✓ | | `forc` |
|
||||
| swift | ✓ | ✓ | | | `sourcekit-lsp` |
|
||||
| systemd | ✓ | | | | `systemd-lsp` |
|
||||
| t32 | ✓ | | | | |
|
||||
| tablegen | ✓ | ✓ | ✓ | | |
|
||||
| tact | ✓ | ✓ | ✓ | | |
|
||||
| task | ✓ | | | | |
|
||||
| tcl | ✓ | | ✓ | | |
|
||||
| teal | ✓ | | | | `teal-language-server` |
|
||||
| templ | ✓ | | | | `templ` |
|
||||
| tera | ✓ | | | | |
|
||||
| textproto | ✓ | ✓ | ✓ | | |
|
||||
| tfvars | ✓ | | ✓ | | `terraform-ls` |
|
||||
| thrift | ✓ | | | | |
|
||||
| tlaplus | ✓ | | | | |
|
||||
| todotxt | ✓ | | | | |
|
||||
| toml | ✓ | ✓ | | | `taplo`, `tombi` |
|
||||
| tsq | ✓ | | | | `ts_query_ls` |
|
||||
| tsx | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| twig | ✓ | | | | |
|
||||
| typescript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| typespec | ✓ | ✓ | ✓ | | `tsp-server` |
|
||||
| typst | ✓ | | | ✓ | `tinymist` |
|
||||
| ungrammar | ✓ | | | | |
|
||||
| unison | ✓ | ✓ | ✓ | | |
|
||||
| uxntal | ✓ | | | | |
|
||||
| v | ✓ | ✓ | ✓ | | `v-analyzer` |
|
||||
| vala | ✓ | ✓ | | | `vala-language-server` |
|
||||
| vento | ✓ | | | | |
|
||||
| verilog | ✓ | ✓ | | | `svlangserver` |
|
||||
| vhdl | ✓ | | | | `vhdl_ls` |
|
||||
| vhs | ✓ | | | | |
|
||||
| vue | ✓ | | | | `vue-language-server` |
|
||||
| wast | ✓ | | | | |
|
||||
| wat | ✓ | | | | `wat_server` |
|
||||
| webc | ✓ | | | | |
|
||||
| werk | ✓ | | | | |
|
||||
| wesl | ✓ | ✓ | | | |
|
||||
| wgsl | ✓ | | | | `wgsl-analyzer` |
|
||||
| wit | ✓ | | ✓ | | |
|
||||
| wren | ✓ | ✓ | ✓ | | |
|
||||
| xit | ✓ | | | | |
|
||||
| xml | ✓ | | ✓ | | |
|
||||
| xtc | ✓ | | | | |
|
||||
| yaml | ✓ | ✓ | ✓ | | `yaml-language-server`, `ansible-language-server` |
|
||||
| yara | ✓ | | | | `yls` |
|
||||
| yuck | ✓ | | | | |
|
||||
| zig | ✓ | ✓ | ✓ | | `zls` |
|
||||
|
@@ -106,10 +106,10 @@
|
||||
| `code_action` | Perform code action | normal: `` <space>a ``, select: `` <space>a `` |
|
||||
| `buffer_picker` | Open buffer picker | normal: `` <space>b ``, select: `` <space>b `` |
|
||||
| `jumplist_picker` | Open jumplist picker | normal: `` <space>j ``, select: `` <space>j `` |
|
||||
| `symbol_picker` | Open symbol picker | normal: `` <space>s ``, select: `` <space>s `` |
|
||||
| `symbol_picker` | Open symbol picker | |
|
||||
| `changed_file_picker` | Open changed file picker | normal: `` <space>g ``, select: `` <space>g `` |
|
||||
| `select_references_to_symbol_under_cursor` | Select symbol references | normal: `` <space>h ``, select: `` <space>h `` |
|
||||
| `workspace_symbol_picker` | Open workspace symbol picker | normal: `` <space>S ``, select: `` <space>S `` |
|
||||
| `workspace_symbol_picker` | Open workspace symbol picker | |
|
||||
| `diagnostics_picker` | Open diagnostic picker | normal: `` <space>d ``, select: `` <space>d `` |
|
||||
| `workspace_diagnostics_picker` | Open workspace diagnostic picker | normal: `` <space>D ``, select: `` <space>D `` |
|
||||
| `last_picker` | Open last picker | normal: `` <space>' ``, select: `` <space>' `` |
|
||||
@@ -305,3 +305,7 @@
|
||||
| `goto_prev_tabstop` | Goto next snippet placeholder | |
|
||||
| `rotate_selections_first` | Make the first selection your primary one | |
|
||||
| `rotate_selections_last` | Make the last selection your primary one | |
|
||||
| `syntax_symbol_picker` | Open symbol picker from syntax information | |
|
||||
| `syntax_workspace_symbol_picker` | Open workspace symbol picker from syntax information | |
|
||||
| `lsp_or_syntax_symbol_picker` | Open symbol picker from LSP or syntax information | normal: `` <space>s ``, select: `` <space>s `` |
|
||||
| `lsp_or_syntax_workspace_symbol_picker` | Open workspace symbol picker from LSP or syntax information | normal: `` <space>S ``, select: `` <space>S `` |
|
||||
|
34
book/src/guides/tags.md
Normal file
34
book/src/guides/tags.md
Normal file
@@ -0,0 +1,34 @@
|
||||
## Adding tags queries
|
||||
|
||||
See tree-sitter's documentation on [Code Navigation Systems] for more
|
||||
background on tags queries.
|
||||
|
||||
Helix provides LSP-like features such as document and workspace symbol pickers
|
||||
out-of-the-box for languages with `tags.scm` queries based on syntax trees. To
|
||||
be analyzed a language must have a tree-sitter grammar and a `tags.scm` query
|
||||
file which pattern matches interesting nodes from syntax trees.
|
||||
|
||||
Query files should be placed in `runtime/queries/{language}/tags.scm`
|
||||
when contributing to Helix. You may place these under your local runtime
|
||||
directory (`~/.config/helix/runtime` in Linux for example) for the sake of
|
||||
testing.
|
||||
|
||||
The following [captures][tree-sitter-captures] are recognized:
|
||||
|
||||
| Capture name |
|
||||
|--- |
|
||||
| `definition.class` |
|
||||
| `definition.constant` |
|
||||
| `definition.function` |
|
||||
| `definition.interface` |
|
||||
| `definition.macro` |
|
||||
| `definition.module` |
|
||||
| `definition.struct` |
|
||||
| `definition.type` |
|
||||
|
||||
[Example query files][example-queries] can be found in the Helix GitHub
|
||||
repository.
|
||||
|
||||
[Code Navigation Systems]: https://tree-sitter.github.io/tree-sitter/4-code-navigation.html
|
||||
[tree-sitter-captures]: https://tree-sitter.github.io/tree-sitter/using-parsers/queries/index.html
|
||||
[example-queries]: https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+path%3A%2A%2A/tags.scm&type=Code
|
@@ -20,7 +20,10 @@ use ropey::RopeSlice;
|
||||
use tree_house::{
|
||||
highlighter,
|
||||
query_iter::QueryIter,
|
||||
tree_sitter::{Grammar, InactiveQueryCursor, InputEdit, Node, Query, RopeInput, Tree},
|
||||
tree_sitter::{
|
||||
query::{InvalidPredicateError, UserPredicate},
|
||||
Grammar, InactiveQueryCursor, InputEdit, Node, Query, RopeInput, Tree,
|
||||
},
|
||||
Error, InjectionLanguageMarker, LanguageConfig as SyntaxConfig, Layer,
|
||||
};
|
||||
|
||||
@@ -28,6 +31,7 @@ use crate::{indent::IndentQuery, tree_sitter, ChangeSet, Language};
|
||||
|
||||
pub use tree_house::{
|
||||
highlighter::{Highlight, HighlightEvent},
|
||||
query_iter::QueryIterEvent,
|
||||
Error as HighlighterError, LanguageLoader, TreeCursor, TREE_SITTER_MATCH_LIMIT,
|
||||
};
|
||||
|
||||
@@ -37,6 +41,7 @@ pub struct LanguageData {
|
||||
syntax: OnceCell<Option<SyntaxConfig>>,
|
||||
indent_query: OnceCell<Option<IndentQuery>>,
|
||||
textobject_query: OnceCell<Option<TextObjectQuery>>,
|
||||
tag_query: OnceCell<Option<TagQuery>>,
|
||||
}
|
||||
|
||||
impl LanguageData {
|
||||
@@ -46,6 +51,7 @@ impl LanguageData {
|
||||
syntax: OnceCell::new(),
|
||||
indent_query: OnceCell::new(),
|
||||
textobject_query: OnceCell::new(),
|
||||
tag_query: OnceCell::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +160,44 @@ impl LanguageData {
|
||||
.as_ref()
|
||||
}
|
||||
|
||||
/// Compiles the tags.scm query for a language.
|
||||
/// This function should only be used by this module or the xtask crate.
|
||||
pub fn compile_tag_query(
|
||||
grammar: Grammar,
|
||||
config: &LanguageConfiguration,
|
||||
) -> Result<Option<TagQuery>> {
|
||||
let name = &config.language_id;
|
||||
let text = read_query(name, "tags.scm");
|
||||
if text.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
let query = Query::new(grammar, &text, |_pattern, predicate| match predicate {
|
||||
// TODO: these predicates are allowed in tags.scm queries but not yet used.
|
||||
UserPredicate::IsPropertySet { key: "local", .. } => Ok(()),
|
||||
UserPredicate::Other(pred) => match pred.name() {
|
||||
"strip!" | "select-adjacent!" => Ok(()),
|
||||
_ => Err(InvalidPredicateError::unknown(predicate)),
|
||||
},
|
||||
_ => Err(InvalidPredicateError::unknown(predicate)),
|
||||
})
|
||||
.with_context(|| format!("Failed to compile tags.scm query for '{name}'"))?;
|
||||
Ok(Some(TagQuery { query }))
|
||||
}
|
||||
|
||||
fn tag_query(&self, loader: &Loader) -> Option<&TagQuery> {
|
||||
self.tag_query
|
||||
.get_or_init(|| {
|
||||
let grammar = self.syntax_config(loader)?.grammar;
|
||||
Self::compile_tag_query(grammar, &self.config)
|
||||
.map_err(|err| {
|
||||
log::error!("{err}");
|
||||
})
|
||||
.ok()
|
||||
.flatten()
|
||||
})
|
||||
.as_ref()
|
||||
}
|
||||
|
||||
fn reconfigure(&self, scopes: &[String]) {
|
||||
if let Some(Some(config)) = self.syntax.get() {
|
||||
reconfigure_highlights(config, scopes);
|
||||
@@ -339,6 +383,10 @@ impl Loader {
|
||||
self.language(lang).textobject_query(self)
|
||||
}
|
||||
|
||||
pub fn tag_query(&self, lang: Language) -> Option<&TagQuery> {
|
||||
self.language(lang).tag_query(self)
|
||||
}
|
||||
|
||||
pub fn language_server_configs(&self) -> &HashMap<String, LanguageServerConfiguration> {
|
||||
&self.language_server_configs
|
||||
}
|
||||
@@ -511,6 +559,19 @@ impl Syntax {
|
||||
{
|
||||
QueryIter::new(&self.inner, source, loader, range)
|
||||
}
|
||||
|
||||
pub fn tags<'a>(
|
||||
&'a self,
|
||||
source: RopeSlice<'a>,
|
||||
loader: &'a Loader,
|
||||
range: impl RangeBounds<u32>,
|
||||
) -> QueryIter<'a, 'a, impl FnMut(Language) -> Option<&'a Query> + 'a, ()> {
|
||||
self.query_iter(
|
||||
source,
|
||||
|lang| loader.tag_query(lang).map(|q| &q.query),
|
||||
range,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub type Highlighter<'a> = highlighter::Highlighter<'a, 'a, Loader>;
|
||||
@@ -881,6 +942,11 @@ impl TextObjectQuery {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TagQuery {
|
||||
pub query: Query,
|
||||
}
|
||||
|
||||
pub fn pretty_print_tree<W: fmt::Write>(fmt: &mut W, node: Node) -> fmt::Result {
|
||||
if node.child_count() == 0 {
|
||||
if node_is_visible(&node) {
|
||||
|
@@ -244,7 +244,12 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
|
||||
/// Otherwise (workspace, false) is returned
|
||||
pub fn find_workspace() -> (PathBuf, bool) {
|
||||
let current_dir = current_working_dir();
|
||||
for ancestor in current_dir.ancestors() {
|
||||
find_workspace_in(current_dir)
|
||||
}
|
||||
|
||||
pub fn find_workspace_in(dir: impl AsRef<Path>) -> (PathBuf, bool) {
|
||||
let dir = dir.as_ref();
|
||||
for ancestor in dir.ancestors() {
|
||||
if ancestor.join(".git").exists()
|
||||
|| ancestor.join(".svn").exists()
|
||||
|| ancestor.join(".jj").exists()
|
||||
@@ -254,7 +259,7 @@ pub fn find_workspace() -> (PathBuf, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
(current_dir, true)
|
||||
(dir.to_owned(), true)
|
||||
}
|
||||
|
||||
fn default_config_file() -> PathBuf {
|
||||
|
@@ -91,6 +91,8 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
grep-regex = "0.1.13"
|
||||
grep-searcher = "0.1.14"
|
||||
|
||||
dashmap = "6.0"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
|
||||
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
|
||||
libc = "0.2.174"
|
||||
|
@@ -1,5 +1,6 @@
|
||||
pub(crate) mod dap;
|
||||
pub(crate) mod lsp;
|
||||
pub(crate) mod syntax;
|
||||
pub(crate) mod typed;
|
||||
|
||||
pub use dap::*;
|
||||
@@ -11,6 +12,7 @@ use helix_stdx::{
|
||||
};
|
||||
use helix_vcs::{FileChange, Hunk};
|
||||
pub use lsp::*;
|
||||
pub use syntax::*;
|
||||
use tui::{
|
||||
text::{Span, Spans},
|
||||
widgets::Cell,
|
||||
@@ -603,6 +605,10 @@ impl MappableCommand {
|
||||
goto_prev_tabstop, "Goto next snippet placeholder",
|
||||
rotate_selections_first, "Make the first selection your primary one",
|
||||
rotate_selections_last, "Make the last selection your primary one",
|
||||
syntax_symbol_picker, "Open symbol picker from syntax information",
|
||||
syntax_workspace_symbol_picker, "Open workspace symbol picker from syntax information",
|
||||
lsp_or_syntax_symbol_picker, "Open symbol picker from LSP or syntax information",
|
||||
lsp_or_syntax_workspace_symbol_picker, "Open workspace symbol picker from LSP or syntax information",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6823,3 +6829,34 @@ fn jump_to_word(cx: &mut Context, behaviour: Movement) {
|
||||
}
|
||||
jump_to_label(cx, words, behaviour)
|
||||
}
|
||||
|
||||
fn lsp_or_syntax_symbol_picker(cx: &mut Context) {
|
||||
let doc = doc!(cx.editor);
|
||||
|
||||
if doc
|
||||
.language_servers_with_feature(LanguageServerFeature::DocumentSymbols)
|
||||
.next()
|
||||
.is_some()
|
||||
{
|
||||
lsp::symbol_picker(cx);
|
||||
} else if doc.syntax().is_some() {
|
||||
syntax_symbol_picker(cx);
|
||||
} else {
|
||||
cx.editor
|
||||
.set_error("No language server supporting document symbols or syntax info available");
|
||||
}
|
||||
}
|
||||
|
||||
fn lsp_or_syntax_workspace_symbol_picker(cx: &mut Context) {
|
||||
let doc = doc!(cx.editor);
|
||||
|
||||
if doc
|
||||
.language_servers_with_feature(LanguageServerFeature::WorkspaceSymbols)
|
||||
.next()
|
||||
.is_some()
|
||||
{
|
||||
lsp::workspace_symbol_picker(cx);
|
||||
} else {
|
||||
syntax_workspace_symbol_picker(cx);
|
||||
}
|
||||
}
|
||||
|
446
helix-term/src/commands/syntax.rs
Normal file
446
helix-term/src/commands/syntax.rs
Normal file
@@ -0,0 +1,446 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
iter,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use dashmap::DashMap;
|
||||
use futures_util::FutureExt;
|
||||
use grep_regex::RegexMatcherBuilder;
|
||||
use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
|
||||
use helix_core::{
|
||||
syntax::{Loader, QueryIterEvent},
|
||||
Rope, RopeSlice, Selection, Syntax, Uri,
|
||||
};
|
||||
use helix_stdx::{
|
||||
path,
|
||||
rope::{self, RopeSliceExt},
|
||||
};
|
||||
use helix_view::{
|
||||
align_view,
|
||||
document::{from_reader, SCRATCH_BUFFER_NAME},
|
||||
Align, Document, DocumentId, Editor,
|
||||
};
|
||||
use ignore::{DirEntry, WalkBuilder, WalkState};
|
||||
|
||||
use crate::{
|
||||
filter_picker_entry,
|
||||
ui::{
|
||||
overlay::overlaid,
|
||||
picker::{Injector, PathOrId},
|
||||
Picker, PickerColumn,
|
||||
},
|
||||
};
|
||||
|
||||
use super::Context;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum TagKind {
|
||||
Class,
|
||||
Constant,
|
||||
Function,
|
||||
Interface,
|
||||
Macro,
|
||||
Module,
|
||||
Struct,
|
||||
Type,
|
||||
}
|
||||
|
||||
impl TagKind {
|
||||
fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Class => "class",
|
||||
Self::Constant => "constant",
|
||||
Self::Function => "function",
|
||||
Self::Interface => "interface",
|
||||
Self::Macro => "macro",
|
||||
Self::Module => "module",
|
||||
Self::Struct => "struct",
|
||||
Self::Type => "type",
|
||||
}
|
||||
}
|
||||
|
||||
fn from_name(name: &str) -> Option<Self> {
|
||||
match name {
|
||||
"class" => Some(TagKind::Class),
|
||||
"constant" => Some(TagKind::Constant),
|
||||
"function" => Some(TagKind::Function),
|
||||
"interface" => Some(TagKind::Interface),
|
||||
"macro" => Some(TagKind::Macro),
|
||||
"module" => Some(TagKind::Module),
|
||||
"struct" => Some(TagKind::Struct),
|
||||
"type" => Some(TagKind::Type),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Uri is cheap to clone and DocumentId is Copy
|
||||
#[derive(Debug, Clone)]
|
||||
enum UriOrDocumentId {
|
||||
Uri(Uri),
|
||||
Id(DocumentId),
|
||||
}
|
||||
|
||||
impl UriOrDocumentId {
|
||||
fn path_or_id(&self) -> Option<PathOrId<'_>> {
|
||||
match self {
|
||||
Self::Id(id) => Some(PathOrId::Id(*id)),
|
||||
Self::Uri(uri) => uri.as_path().map(PathOrId::Path),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Tag {
|
||||
kind: TagKind,
|
||||
name: String,
|
||||
start: usize,
|
||||
end: usize,
|
||||
start_line: usize,
|
||||
end_line: usize,
|
||||
doc: UriOrDocumentId,
|
||||
}
|
||||
|
||||
fn tags_iter<'a>(
|
||||
syntax: &'a Syntax,
|
||||
loader: &'a Loader,
|
||||
text: RopeSlice<'a>,
|
||||
doc: UriOrDocumentId,
|
||||
pattern: Option<&'a rope::Regex>,
|
||||
) -> impl Iterator<Item = Tag> + 'a {
|
||||
let mut tags_iter = syntax.tags(text, loader, ..);
|
||||
|
||||
iter::from_fn(move || loop {
|
||||
let QueryIterEvent::Match(mat) = tags_iter.next()? else {
|
||||
continue;
|
||||
};
|
||||
let query = &loader
|
||||
.tag_query(tags_iter.current_language())
|
||||
.expect("must have a tags query to emit matches")
|
||||
.query;
|
||||
let Some(kind) = query
|
||||
.capture_name(mat.capture)
|
||||
.strip_prefix("definition.")
|
||||
.and_then(TagKind::from_name)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let range = mat.node.byte_range();
|
||||
if pattern.is_some_and(|pattern| {
|
||||
!pattern.is_match(text.regex_input_at_bytes(range.start as usize..range.end as usize))
|
||||
}) {
|
||||
continue;
|
||||
}
|
||||
let start = text.byte_to_char(range.start as usize);
|
||||
let end = text.byte_to_char(range.end as usize);
|
||||
return Some(Tag {
|
||||
kind,
|
||||
name: text.slice(start..end).to_string(),
|
||||
start,
|
||||
end,
|
||||
start_line: text.char_to_line(start),
|
||||
end_line: text.char_to_line(end),
|
||||
doc: doc.clone(),
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
pub fn syntax_symbol_picker(cx: &mut Context) {
|
||||
let doc = doc!(cx.editor);
|
||||
let Some(syntax) = doc.syntax() else {
|
||||
cx.editor
|
||||
.set_error("Syntax tree is not available on this buffer");
|
||||
return;
|
||||
};
|
||||
let doc_id = doc.id();
|
||||
let text = doc.text().slice(..);
|
||||
let loader = cx.editor.syn_loader.load();
|
||||
let tags = tags_iter(syntax, &loader, text, UriOrDocumentId::Id(doc.id()), None);
|
||||
|
||||
let columns = vec![
|
||||
PickerColumn::new("kind", |tag: &Tag, _| tag.kind.as_str().into()),
|
||||
PickerColumn::new("name", |tag: &Tag, _| tag.name.as_str().into()),
|
||||
];
|
||||
|
||||
let picker = Picker::new(
|
||||
columns,
|
||||
1, // name
|
||||
tags,
|
||||
(),
|
||||
move |cx, tag, action| {
|
||||
cx.editor.switch(doc_id, action);
|
||||
let view = view_mut!(cx.editor);
|
||||
let doc = doc_mut!(cx.editor, &doc_id);
|
||||
doc.set_selection(view.id, Selection::single(tag.start, tag.end));
|
||||
if action.align_view(view, doc.id()) {
|
||||
align_view(doc, view, Align::Center)
|
||||
}
|
||||
},
|
||||
)
|
||||
.with_preview(|_editor, tag| {
|
||||
Some((tag.doc.path_or_id()?, Some((tag.start_line, tag.end_line))))
|
||||
})
|
||||
.truncate_start(false);
|
||||
|
||||
cx.push_layer(Box::new(overlaid(picker)));
|
||||
}
|
||||
|
||||
pub fn syntax_workspace_symbol_picker(cx: &mut Context) {
|
||||
#[derive(Debug)]
|
||||
struct SearchState {
|
||||
searcher_builder: SearcherBuilder,
|
||||
walk_builder: WalkBuilder,
|
||||
regex_matcher_builder: RegexMatcherBuilder,
|
||||
rope_regex_builder: rope::RegexBuilder,
|
||||
search_root: PathBuf,
|
||||
/// A cache of files that have been parsed in prior searches.
|
||||
syntax_cache: DashMap<PathBuf, Option<(Rope, Syntax)>>,
|
||||
}
|
||||
|
||||
let mut searcher_builder = SearcherBuilder::new();
|
||||
searcher_builder.binary_detection(BinaryDetection::quit(b'\x00'));
|
||||
|
||||
// Search from the workspace that the currently focused document is within. This behaves like global
|
||||
// search most of the time but helps when you have two projects open in splits.
|
||||
let search_root = if let Some(path) = doc!(cx.editor).path() {
|
||||
helix_loader::find_workspace_in(path).0
|
||||
} else {
|
||||
helix_loader::find_workspace().0
|
||||
};
|
||||
|
||||
let absolute_root = search_root
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|_| search_root.clone());
|
||||
|
||||
let config = cx.editor.config();
|
||||
let dedup_symlinks = config.file_picker.deduplicate_links;
|
||||
|
||||
let mut walk_builder = WalkBuilder::new(&search_root);
|
||||
walk_builder
|
||||
.hidden(config.file_picker.hidden)
|
||||
.parents(config.file_picker.parents)
|
||||
.ignore(config.file_picker.ignore)
|
||||
.follow_links(config.file_picker.follow_symlinks)
|
||||
.git_ignore(config.file_picker.git_ignore)
|
||||
.git_global(config.file_picker.git_global)
|
||||
.git_exclude(config.file_picker.git_exclude)
|
||||
.max_depth(config.file_picker.max_depth)
|
||||
.filter_entry(move |entry| filter_picker_entry(entry, &absolute_root, dedup_symlinks))
|
||||
.add_custom_ignore_filename(helix_loader::config_dir().join("ignore"))
|
||||
.add_custom_ignore_filename(".helix/ignore");
|
||||
|
||||
let mut regex_matcher_builder = RegexMatcherBuilder::new();
|
||||
regex_matcher_builder.case_smart(config.search.smart_case);
|
||||
let mut rope_regex_builder = rope::RegexBuilder::new();
|
||||
rope_regex_builder.syntax(rope::Config::new().case_insensitive(config.search.smart_case));
|
||||
let state = SearchState {
|
||||
searcher_builder,
|
||||
walk_builder,
|
||||
regex_matcher_builder,
|
||||
rope_regex_builder,
|
||||
search_root,
|
||||
syntax_cache: DashMap::default(),
|
||||
};
|
||||
let reg = cx.register.unwrap_or('/');
|
||||
cx.editor.registers.last_search_register = reg;
|
||||
let columns = vec![
|
||||
PickerColumn::new("kind", |tag: &Tag, _| tag.kind.as_str().into()),
|
||||
PickerColumn::new("name", |tag: &Tag, _| tag.name.as_str().into()).without_filtering(),
|
||||
PickerColumn::new("path", |tag: &Tag, state: &SearchState| {
|
||||
match &tag.doc {
|
||||
UriOrDocumentId::Uri(uri) => {
|
||||
if let Some(path) = uri.as_path() {
|
||||
let path = if let Ok(stripped) = path.strip_prefix(&state.search_root) {
|
||||
stripped
|
||||
} else {
|
||||
path
|
||||
};
|
||||
path.to_string_lossy().into()
|
||||
} else {
|
||||
uri.to_string().into()
|
||||
}
|
||||
}
|
||||
// This picker only uses `Id` for scratch buffers for better display.
|
||||
UriOrDocumentId::Id(_) => SCRATCH_BUFFER_NAME.into(),
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
let get_tags = |query: &str,
|
||||
editor: &mut Editor,
|
||||
state: Arc<SearchState>,
|
||||
injector: &Injector<_, _>| {
|
||||
if query.len() < 3 {
|
||||
return async { Ok(()) }.boxed();
|
||||
}
|
||||
// Attempt to find the tag in any open documents.
|
||||
let pattern = match state.rope_regex_builder.build(query) {
|
||||
Ok(pattern) => pattern,
|
||||
Err(err) => return async { Err(anyhow::anyhow!(err)) }.boxed(),
|
||||
};
|
||||
let loader = editor.syn_loader.load();
|
||||
for doc in editor.documents() {
|
||||
let Some(syntax) = doc.syntax() else { continue };
|
||||
let text = doc.text().slice(..);
|
||||
let uri_or_id = doc
|
||||
.uri()
|
||||
.map(UriOrDocumentId::Uri)
|
||||
.unwrap_or_else(|| UriOrDocumentId::Id(doc.id()));
|
||||
for tag in tags_iter(syntax, &loader, text.slice(..), uri_or_id, Some(&pattern)) {
|
||||
if injector.push(tag).is_err() {
|
||||
return async { Ok(()) }.boxed();
|
||||
}
|
||||
}
|
||||
}
|
||||
if !state.search_root.exists() {
|
||||
return async { Err(anyhow::anyhow!("Current working directory does not exist")) }
|
||||
.boxed();
|
||||
}
|
||||
let matcher = match state.regex_matcher_builder.build(query) {
|
||||
Ok(matcher) => {
|
||||
// Clear any "Failed to compile regex" errors out of the statusline.
|
||||
editor.clear_status();
|
||||
matcher
|
||||
}
|
||||
Err(err) => {
|
||||
log::info!(
|
||||
"Failed to compile search pattern in workspace symbol search: {}",
|
||||
err
|
||||
);
|
||||
return async { Err(anyhow::anyhow!("Failed to compile regex")) }.boxed();
|
||||
}
|
||||
};
|
||||
let pattern = Arc::new(pattern);
|
||||
let injector = injector.clone();
|
||||
let loader = editor.syn_loader.load();
|
||||
let documents: HashSet<_> = editor
|
||||
.documents()
|
||||
.filter_map(Document::path)
|
||||
.cloned()
|
||||
.collect();
|
||||
async move {
|
||||
let searcher = state.searcher_builder.build();
|
||||
state.walk_builder.build_parallel().run(|| {
|
||||
let mut searcher = searcher.clone();
|
||||
let matcher = matcher.clone();
|
||||
let injector = injector.clone();
|
||||
let loader = loader.clone();
|
||||
let documents = &documents;
|
||||
let pattern = pattern.clone();
|
||||
let syntax_cache = &state.syntax_cache;
|
||||
Box::new(move |entry: Result<DirEntry, ignore::Error>| -> WalkState {
|
||||
let entry = match entry {
|
||||
Ok(entry) => entry,
|
||||
Err(_) => return WalkState::Continue,
|
||||
};
|
||||
match entry.file_type() {
|
||||
Some(entry) if entry.is_file() => {}
|
||||
// skip everything else
|
||||
_ => return WalkState::Continue,
|
||||
};
|
||||
let path = entry.path();
|
||||
// If this document is open, skip it because we've already processed it above.
|
||||
if documents.contains(path) {
|
||||
return WalkState::Continue;
|
||||
};
|
||||
let mut quit = false;
|
||||
let sink = sinks::UTF8(|_line, _content| {
|
||||
if !syntax_cache.contains_key(path) {
|
||||
// Read the file into a Rope and attempt to recognize the language
|
||||
// and parse it with tree-sitter. Save the Rope and Syntax for future
|
||||
// queries.
|
||||
syntax_cache.insert(path.to_path_buf(), syntax_for_path(path, &loader));
|
||||
};
|
||||
let entry = syntax_cache.get(path).unwrap();
|
||||
let Some((text, syntax)) = entry.value() else {
|
||||
// If the file couldn't be parsed, move on.
|
||||
return Ok(false);
|
||||
};
|
||||
let uri = Uri::from(path::normalize(path));
|
||||
for tag in tags_iter(
|
||||
syntax,
|
||||
&loader,
|
||||
text.slice(..),
|
||||
UriOrDocumentId::Uri(uri),
|
||||
Some(&pattern),
|
||||
) {
|
||||
if injector.push(tag).is_err() {
|
||||
quit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Quit after seeing the first regex match. We only care to find files
|
||||
// that contain the pattern and then we run the tags query within
|
||||
// those. The location and contents of a match are irrelevant - it's
|
||||
// only important _if_ a file matches.
|
||||
Ok(false)
|
||||
});
|
||||
if let Err(err) = searcher.search_path(&matcher, path, sink) {
|
||||
log::info!("Workspace syntax search error: {}, {}", path.display(), err);
|
||||
}
|
||||
if quit {
|
||||
WalkState::Quit
|
||||
} else {
|
||||
WalkState::Continue
|
||||
}
|
||||
})
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
.boxed()
|
||||
};
|
||||
let picker = Picker::new(
|
||||
columns,
|
||||
1, // name
|
||||
[],
|
||||
state,
|
||||
move |cx, tag, action| {
|
||||
let doc_id = match &tag.doc {
|
||||
UriOrDocumentId::Id(id) => *id,
|
||||
UriOrDocumentId::Uri(uri) => match cx.editor.open(uri.as_path().expect(""), action) {
|
||||
Ok(id) => id,
|
||||
Err(e) => {
|
||||
cx.editor
|
||||
.set_error(format!("Failed to open file '{uri:?}': {e}"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
let doc = doc_mut!(cx.editor, &doc_id);
|
||||
let view = view_mut!(cx.editor);
|
||||
let len_chars = doc.text().len_chars();
|
||||
if tag.start >= len_chars || tag.end > len_chars {
|
||||
cx.editor.set_error("The location you jumped to does not exist anymore because the file has changed.");
|
||||
return;
|
||||
}
|
||||
doc.set_selection(view.id, Selection::single(tag.start, tag.end));
|
||||
if action.align_view(view, doc.id()) {
|
||||
align_view(doc, view, Align::Center)
|
||||
}
|
||||
},
|
||||
)
|
||||
.with_dynamic_query(get_tags, Some(275))
|
||||
.with_preview(move |_editor, tag| {
|
||||
Some((
|
||||
tag.doc.path_or_id()?,
|
||||
Some((tag.start_line, tag.end_line)),
|
||||
))
|
||||
})
|
||||
.truncate_start(false);
|
||||
cx.push_layer(Box::new(overlaid(picker)));
|
||||
}
|
||||
|
||||
/// Create a Rope and language config for a given existing path without creating a full Document.
|
||||
fn syntax_for_path(path: &Path, loader: &Loader) -> Option<(Rope, Syntax)> {
|
||||
let mut file = std::fs::File::open(path).ok()?;
|
||||
let (rope, _encoding, _has_bom) = from_reader(&mut file, None).ok()?;
|
||||
let text = rope.slice(..);
|
||||
let language = loader
|
||||
.language_for_filename(path)
|
||||
.or_else(|| loader.language_for_shebang(text))?;
|
||||
Syntax::new(text, language, loader)
|
||||
.ok()
|
||||
.map(|syntax| (rope, syntax))
|
||||
}
|
@@ -12,11 +12,17 @@ pub enum TsFeature {
|
||||
Highlight,
|
||||
TextObject,
|
||||
AutoIndent,
|
||||
Tags,
|
||||
}
|
||||
|
||||
impl TsFeature {
|
||||
pub fn all() -> &'static [Self] {
|
||||
&[Self::Highlight, Self::TextObject, Self::AutoIndent]
|
||||
&[
|
||||
Self::Highlight,
|
||||
Self::TextObject,
|
||||
Self::AutoIndent,
|
||||
Self::Tags,
|
||||
]
|
||||
}
|
||||
|
||||
pub fn runtime_filename(&self) -> &'static str {
|
||||
@@ -24,6 +30,7 @@ impl TsFeature {
|
||||
Self::Highlight => "highlights.scm",
|
||||
Self::TextObject => "textobjects.scm",
|
||||
Self::AutoIndent => "indents.scm",
|
||||
Self::Tags => "tags.scm",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +39,7 @@ impl TsFeature {
|
||||
Self::Highlight => "Syntax Highlighting",
|
||||
Self::TextObject => "Treesitter Textobjects",
|
||||
Self::AutoIndent => "Auto Indent",
|
||||
Self::Tags => "Code Navigation Tags",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +48,7 @@ impl TsFeature {
|
||||
Self::Highlight => "Highlight",
|
||||
Self::TextObject => "Textobject",
|
||||
Self::AutoIndent => "Indent",
|
||||
Self::Tags => "Tags",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -227,8 +227,8 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
|
||||
"E" => file_explorer_in_current_buffer_directory,
|
||||
"b" => buffer_picker,
|
||||
"j" => jumplist_picker,
|
||||
"s" => symbol_picker,
|
||||
"S" => workspace_symbol_picker,
|
||||
"s" => lsp_or_syntax_symbol_picker,
|
||||
"S" => lsp_or_syntax_workspace_symbol_picker,
|
||||
"d" => diagnostics_picker,
|
||||
"D" => workspace_diagnostics_picker,
|
||||
"g" => changed_file_picker,
|
||||
|
@@ -2046,7 +2046,10 @@ roots = ["rebar.config"]
|
||||
shebangs = ["escript"]
|
||||
comment-token = "%%"
|
||||
indent = { tab-width = 4, unit = " " }
|
||||
language-servers = [ "erlang-ls", "elp" ]
|
||||
language-servers = [
|
||||
{ name = "erlang-ls", except-features = ["document-symbols", "workspace-symbols"] },
|
||||
{ name = "elp", except-features = ["document-symbols", "workspace-symbols"] }
|
||||
]
|
||||
|
||||
[[grammar]]
|
||||
name = "erlang"
|
||||
|
@@ -19,5 +19,3 @@
|
||||
(invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send
|
||||
|
||||
(namespace_declaration name: (identifier) @name) @definition.module
|
||||
|
||||
(namespace_declaration name: (identifier) @name) @module
|
||||
|
9
runtime/queries/c/tags.scm
Normal file
9
runtime/queries/c/tags.scm
Normal file
@@ -0,0 +1,9 @@
|
||||
(function_declarator
|
||||
declarator: [(identifier) (field_identifier)] @definition.function)
|
||||
|
||||
(preproc_function_def name: (identifier) @definition.function)
|
||||
|
||||
(type_definition
|
||||
declarator: (type_identifier) @definition.type)
|
||||
|
||||
(preproc_def name: (identifier) @definition.constant)
|
12
runtime/queries/cpp/tags.scm
Normal file
12
runtime/queries/cpp/tags.scm
Normal file
@@ -0,0 +1,12 @@
|
||||
; inherits: c
|
||||
|
||||
(function_declarator
|
||||
declarator: (qualified_identifier name: (identifier) @definition.function))
|
||||
|
||||
(struct_specifier
|
||||
name: (type_identifier) @definition.struct
|
||||
body: (field_declaration_list))
|
||||
|
||||
(class_specifier
|
||||
name: (type_identifier) @definition.class
|
||||
body: (field_declaration_list))
|
54
runtime/queries/elixir/tags.scm
Normal file
54
runtime/queries/elixir/tags.scm
Normal file
@@ -0,0 +1,54 @@
|
||||
; Definitions
|
||||
|
||||
; * modules and protocols
|
||||
(call
|
||||
target: (identifier) @ignore
|
||||
(arguments (alias) @name)
|
||||
(#any-of? @ignore "defmodule" "defprotocol")) @definition.module
|
||||
|
||||
; * functions/macros
|
||||
(call
|
||||
target: (identifier) @ignore
|
||||
(arguments
|
||||
[
|
||||
; zero-arity functions with no parentheses
|
||||
(identifier) @name
|
||||
; regular function clause
|
||||
(call target: (identifier) @name)
|
||||
; function clause with a guard clause
|
||||
(binary_operator
|
||||
left: (call target: (identifier) @name)
|
||||
operator: "when")
|
||||
])
|
||||
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp")) @definition.function
|
||||
|
||||
; References
|
||||
|
||||
; ignore calls to kernel/special-forms keywords
|
||||
(call
|
||||
target: (identifier) @ignore
|
||||
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defmodule" "defprotocol" "defimpl" "defstruct" "defexception" "defoverridable" "alias" "case" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
|
||||
|
||||
; ignore module attributes
|
||||
(unary_operator
|
||||
operator: "@"
|
||||
operand: (call
|
||||
target: (identifier) @ignore))
|
||||
|
||||
; * function call
|
||||
(call
|
||||
target: [
|
||||
; local
|
||||
(identifier) @name
|
||||
; remote
|
||||
(dot
|
||||
right: (identifier) @name)
|
||||
]) @reference.call
|
||||
|
||||
; * pipe into function call
|
||||
(binary_operator
|
||||
operator: "|>"
|
||||
right: (identifier) @name) @reference.call
|
||||
|
||||
; * modules
|
||||
(alias) @name @reference.module
|
45
runtime/queries/erlang/tags.scm
Normal file
45
runtime/queries/erlang/tags.scm
Normal file
@@ -0,0 +1,45 @@
|
||||
; Modules
|
||||
(attribute
|
||||
name: (atom) @_attr
|
||||
(arguments (atom) @definition.module)
|
||||
(#eq? @_attr "module"))
|
||||
|
||||
; Constants
|
||||
((attribute
|
||||
name: (atom) @_attr
|
||||
(arguments
|
||||
.
|
||||
[
|
||||
(atom) @definition.constant
|
||||
(call function: [(variable) (atom)] @definition.macro)
|
||||
]))
|
||||
(#eq? @_attr "define"))
|
||||
|
||||
; Record definitions
|
||||
((attribute
|
||||
name: (atom) @_attr
|
||||
(arguments
|
||||
.
|
||||
(atom) @definition.struct))
|
||||
(#eq? @_attr "record"))
|
||||
|
||||
; Function specs
|
||||
((attribute
|
||||
name: (atom) @_attr
|
||||
(stab_clause name: (atom) @definition.interface))
|
||||
(#eq? @_attr "spec"))
|
||||
|
||||
; Types
|
||||
((attribute
|
||||
name: (atom) @_attr
|
||||
(arguments
|
||||
(binary_operator
|
||||
left: [
|
||||
(atom) @definition.type
|
||||
(call function: (atom) @definition.type)
|
||||
]
|
||||
operator: "::")))
|
||||
(#any-of? @_attr "type" "opaque"))
|
||||
|
||||
; Functions
|
||||
(function_clause name: (atom) @definition.function)
|
@@ -2,4 +2,4 @@
|
||||
|
||||
(function_definition (name) @name) @definition.function
|
||||
|
||||
(call (name) @name) @reference.call
|
||||
(call (identifier) @name) @reference.call
|
||||
|
@@ -4,7 +4,7 @@
|
||||
(function_declaration
|
||||
name: (identifier) @name) @definition.function
|
||||
(#strip! @doc "^//\\s*")
|
||||
(#set-adjacent! @doc @definition.function)
|
||||
(#select-adjacent! @doc @definition.function)
|
||||
)
|
||||
|
||||
(
|
||||
@@ -13,7 +13,7 @@
|
||||
(method_declaration
|
||||
name: (field_identifier) @name) @definition.method
|
||||
(#strip! @doc "^//\\s*")
|
||||
(#set-adjacent! @doc @definition.method)
|
||||
(#select-adjacent! @doc @definition.method)
|
||||
)
|
||||
|
||||
(call_expression
|
||||
|
2
runtime/queries/markdown/tags.scm
Normal file
2
runtime/queries/markdown/tags.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
; TODO: have symbol types for markup?
|
||||
(atx_heading) @definition.class
|
26
runtime/queries/rust/tags.scm
Normal file
26
runtime/queries/rust/tags.scm
Normal file
@@ -0,0 +1,26 @@
|
||||
(struct_item
|
||||
name: (type_identifier) @definition.struct)
|
||||
|
||||
(const_item
|
||||
name: (identifier) @definition.constant)
|
||||
|
||||
(trait_item
|
||||
name: (type_identifier) @definition.interface)
|
||||
|
||||
(function_item
|
||||
name: (identifier) @definition.function)
|
||||
|
||||
(function_signature_item
|
||||
name: (identifier) @definition.function)
|
||||
|
||||
(enum_item
|
||||
name: (type_identifier) @definition.type)
|
||||
|
||||
(enum_variant
|
||||
name: (identifier) @definition.struct)
|
||||
|
||||
(mod_item
|
||||
name: (identifier) @definition.module)
|
||||
|
||||
(macro_definition
|
||||
name: (identifier) @definition.macro)
|
6
runtime/queries/typst/tags.scm
Normal file
6
runtime/queries/typst/tags.scm
Normal file
@@ -0,0 +1,6 @@
|
||||
; should be a heading
|
||||
(heading (text) @definition.class)
|
||||
|
||||
; should be a label/reference/tag
|
||||
(heading (label) @definition.function)
|
||||
(content (label) @definition.function)
|
@@ -36,6 +36,7 @@ pub mod tasks {
|
||||
let grammar = syntax_config.grammar;
|
||||
LanguageData::compile_indent_query(grammar, config)?;
|
||||
LanguageData::compile_textobject_query(grammar, config)?;
|
||||
LanguageData::compile_tag_query(grammar, config)?;
|
||||
}
|
||||
|
||||
println!("Query check succeeded");
|
||||
|
Reference in New Issue
Block a user