From a78b7894066b6ccf56c404b7543b45e2dfd99982 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Mon, 22 Nov 2021 00:25:08 +0530 Subject: Auto generate docs for language support --- languages.toml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 4208e4b6..ca339c98 100644 --- a/languages.toml +++ b/languages.toml @@ -1,5 +1,6 @@ [[language]] name = "rust" +display-name = "Rust" scope = "source.rust" injection-regex = "rust" file-types = ["rs"] @@ -14,6 +15,7 @@ procMacro = { enable = false } [[language]] name = "toml" +display-name = "TOML" scope = "source.toml" injection-regex = "toml" file-types = ["toml"] @@ -24,6 +26,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "protobuf" +display-name = "Protobuf" scope = "source.proto" injection-regex = "protobuf" file-types = ["proto"] @@ -34,6 +37,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "elixir" +display-name = "Elixir" scope = "source.elixir" injection-regex = "elixir" file-types = ["ex", "exs"] @@ -46,6 +50,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "mint" +display-name = "Mint" scope = "source.mint" injection-regex = "mint" file-types = ["mint"] @@ -58,6 +63,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "json" +display-name = "JSON" scope = "source.json" injection-regex = "json" file-types = ["json"] @@ -67,6 +73,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "c" +display-name = "C" scope = "source.c" injection-regex = "c" file-types = ["c"] # TODO: ["h"] @@ -78,6 +85,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "cpp" +display-name = "C++" scope = "source.cpp" injection-regex = "cpp" file-types = ["cc", "hh", "cpp", "hpp", "h", "ipp", "tpp", "cxx", "hxx", "ixx", "txx", "ino"] @@ -89,6 +97,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "c-sharp" +display-name = "C#" scope = "source.csharp" injection-regex = "c-?sharp" file-types = ["cs"] @@ -99,6 +108,7 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "go" +display-name = "Go" scope = "source.go" injection-regex = "go" file-types = ["go"] @@ -112,6 +122,7 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "javascript" +display-name = "JavaScript" scope = "source.js" injection-regex = "^(js|javascript)$" file-types = ["js", "mjs"] @@ -124,6 +135,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "typescript" +display-name = "TypeScript" scope = "source.ts" injection-regex = "^(ts|typescript)$" file-types = ["ts"] @@ -136,6 +148,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "tsx" +display-name = "TSX" scope = "source.tsx" injection-regex = "^(tsx)$" # |typescript file-types = ["tsx"] @@ -147,6 +160,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "css" +display-name = "CSS" scope = "source.css" injection-regex = "css" file-types = ["css"] @@ -156,6 +170,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "html" +display-name = "HTML" scope = "text.html.basic" injection-regex = "html" file-types = ["html"] @@ -165,6 +180,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "python" +display-name = "Python" scope = "source.python" injection-regex = "python" file-types = ["py"] @@ -178,6 +194,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "nix" +display-name = "Nix" scope = "source.nix" injection-regex = "nix" file-types = ["nix"] @@ -190,6 +207,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "ruby" +display-name = "Ruby" scope = "source.ruby" injection-regex = "ruby" file-types = ["rb"] @@ -202,6 +220,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "bash" +display-name = "Bash" scope = "source.bash" injection-regex = "bash" file-types = ["sh", "bash"] @@ -214,6 +233,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "php" +display-name = "PHP" scope = "source.php" injection-regex = "php" file-types = ["php"] @@ -224,6 +244,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "latex" +display-name = "LaTeX" scope = "source.tex" injection-regex = "tex" file-types = ["tex"] @@ -234,6 +255,7 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "julia" +display-name = "Julia" scope = "source.julia" injection-regex = "julia" file-types = ["jl"] @@ -259,6 +281,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "java" +display-name = "Java" scope = "source.java" injection-regex = "java" file-types = ["java"] @@ -267,6 +290,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "ledger" +display-name = "Ledger" scope = "source.ledger" injection-regex = "ledger" file-types = ["ldg", "ledger", "journal"] @@ -276,6 +300,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "ocaml" +display-name = "OCaml" scope = "source.ocaml" injection-regex = "ocaml" file-types = ["ml"] @@ -286,6 +311,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "ocaml-interface" +display-name = "OCaml-Interface" scope = "source.ocaml.interface" file-types = ["mli"] shebangs = [] @@ -295,6 +321,7 @@ indent = { tab-width = 2, unit = " "} [[language]] name = "lua" +display-name = "Lua" scope = "source.lua" file-types = ["lua"] shebangs = ["lua"] @@ -304,6 +331,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "svelte" +display-name = "Svelte" scope = "source.svelte" injection-regex = "svelte" file-types = ["svelte"] @@ -314,6 +342,7 @@ language-server = { command = "svelteserver", args = ["--stdio"] } [[language]] name = "vue" +display-name = "Vue" scope = "source.vue" injection-regex = "vue" file-types = ["vue"] @@ -322,6 +351,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "yaml" +display-name = "YAML" scope = "source.yaml" file-types = ["yml", "yaml"] roots = [] @@ -330,6 +360,7 @@ indent = { tab-width = 2, unit = " " } # [[language]] # name = "haskell" +# display-name = "Haskell" # scope = "source.haskell" # injection-regex = "haskell" # file-types = ["hs"] @@ -340,6 +371,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "zig" +display-name = "Zig" scope = "source.zig" injection-regex = "zig" file-types = ["zig"] @@ -352,6 +384,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "prolog" +display-name = "Prolog" scope = "source.prolog" roots = [] file-types = ["pl", "prolog"] @@ -365,6 +398,7 @@ language-server = { command = "swipl", args = [ [[language]] name = "tsq" +display-name = "TSQ" scope = "source.tsq" file-types = ["scm"] roots = [] @@ -373,6 +407,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "cmake" +display-name = "CMake" scope = "source.cmake" file-types = ["cmake", "CMakeLists.txt"] roots = [] @@ -382,6 +417,7 @@ language-server = { command = "cmake-language-server" } [[language]] name = "glsl" +display-name = "GLSL" scope = "source.glsl" file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ] roots = [] @@ -390,6 +426,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "perl" +display-name = "Perl" scope = "source.perl" file-types = ["pl", "pm"] shebangs = ["perl"] @@ -399,6 +436,7 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "racket" +display-name = "Racket" scope = "source.rkt" roots = [] file-types = ["rkt"] @@ -408,6 +446,7 @@ language-server = { command = "racket", args = ["-l", "racket-langserver"] } [[language]] name = "wgsl" +display-name = "WGSL" scope = "source.wgsl" file-types = ["wgsl"] roots = [] @@ -416,6 +455,7 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "llvm" +display-name = "LLVM" scope = "source.llvm" roots = [] file-types = ["ll"] -- cgit v1.2.3-70-g09d2 From d08bdfa838098769afc59146b62f9d613d4a7ff4 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Tue, 7 Dec 2021 21:27:21 +0530 Subject: Use same name used in config files for langs in docs --- book/src/generated/lang-support.md | 78 +++++++++++++++++++------------------- helix-core/src/indent.rs | 1 - helix-core/src/syntax.rs | 1 - languages.toml | 41 -------------------- xtask/src/main.rs | 2 +- 5 files changed, 40 insertions(+), 83 deletions(-) (limited to 'languages.toml') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 729801ad..96d9b6a0 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -1,41 +1,41 @@ | Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP | | --- | --- | --- | --- | --- | -| Bash | ✓ | | | `bash-language-server` | -| C | ✓ | | | `clangd` | -| C# | ✓ | | | | -| CMake | ✓ | | | `cmake-language-server` | -| C++ | ✓ | | | `clangd` | -| CSS | ✓ | | | | -| Elixir | ✓ | | | `elixir-ls` | -| GLSL | ✓ | | ✓ | | -| Go | ✓ | ✓ | ✓ | `gopls` | -| HTML | ✓ | | | | -| Java | ✓ | | | | -| JavaScript | ✓ | | ✓ | | -| JSON | ✓ | | ✓ | | -| Julia | ✓ | | | `julia` | -| LaTeX | ✓ | | | | -| Ledger | ✓ | | | | -| LLVM | ✓ | | | | -| Lua | ✓ | | ✓ | | -| Mint | | | | `mint` | -| Nix | ✓ | | ✓ | `rnix-lsp` | -| OCaml | ✓ | | ✓ | | -| OCaml-Interface | ✓ | | | | -| Perl | ✓ | ✓ | | | -| PHP | ✓ | | ✓ | | -| Prolog | | | | `swipl` | -| Protobuf | ✓ | | ✓ | | -| Python | ✓ | ✓ | ✓ | `pylsp` | -| Racket | | | | `racket` | -| Ruby | ✓ | | | `solargraph` | -| Rust | ✓ | ✓ | ✓ | `rust-analyzer` | -| Svelte | ✓ | | ✓ | `svelteserver` | -| TOML | ✓ | | | | -| TSQ | ✓ | | | | -| TSX | ✓ | | | `typescript-language-server` | -| TypeScript | ✓ | | ✓ | `typescript-language-server` | -| Vue | ✓ | | | | -| WGSL | ✓ | | | | -| YAML | ✓ | | ✓ | | -| Zig | ✓ | | ✓ | `zls` | +| bash | ✓ | | | `bash-language-server` | +| c | ✓ | | | `clangd` | +| c-sharp | ✓ | | | | +| cmake | ✓ | | | `cmake-language-server` | +| cpp | ✓ | | | `clangd` | +| css | ✓ | | | | +| elixir | ✓ | | | `elixir-ls` | +| glsl | ✓ | | ✓ | | +| go | ✓ | ✓ | ✓ | `gopls` | +| html | ✓ | | | | +| java | ✓ | | | | +| javascript | ✓ | | ✓ | | +| json | ✓ | | ✓ | | +| julia | ✓ | | | `julia` | +| latex | ✓ | | | | +| ledger | ✓ | | | | +| llvm | ✓ | | | | +| lua | ✓ | | ✓ | | +| mint | | | | `mint` | +| nix | ✓ | | ✓ | `rnix-lsp` | +| ocaml | ✓ | | ✓ | | +| ocaml-interface | ✓ | | | | +| perl | ✓ | ✓ | | | +| php | ✓ | | ✓ | | +| prolog | | | | `swipl` | +| protobuf | ✓ | | ✓ | | +| python | ✓ | ✓ | ✓ | `pylsp` | +| racket | | | | `racket` | +| ruby | ✓ | | | `solargraph` | +| rust | ✓ | ✓ | ✓ | `rust-analyzer` | +| svelte | ✓ | | ✓ | `svelteserver` | +| toml | ✓ | | | | +| tsq | ✓ | | | | +| tsx | ✓ | | | `typescript-language-server` | +| typescript | ✓ | | ✓ | `typescript-language-server` | +| vue | ✓ | | | | +| wgsl | ✓ | | | | +| yaml | ✓ | | ✓ | | +| zig | ✓ | | ✓ | `zls` | diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 3ce3620a..b6f5081a 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -452,7 +452,6 @@ where file_types: vec!["rs".to_string()], shebangs: vec![], language_id: "Rust".to_string(), - display_name: "Rust".to_string(), highlight_config: OnceCell::new(), config: None, // diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 3c65ae33..ef35fc75 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -51,7 +51,6 @@ pub struct Configuration { pub struct LanguageConfiguration { #[serde(rename = "name")] pub language_id: String, // c-sharp, rust - pub display_name: String, // C#, Rust pub scope: String, // source.rust pub file_types: Vec, // filename ends_with? #[serde(default)] diff --git a/languages.toml b/languages.toml index ca339c98..428051a7 100644 --- a/languages.toml +++ b/languages.toml @@ -1,6 +1,5 @@ [[language]] name = "rust" -display-name = "Rust" scope = "source.rust" injection-regex = "rust" file-types = ["rs"] @@ -15,7 +14,6 @@ procMacro = { enable = false } [[language]] name = "toml" -display-name = "TOML" scope = "source.toml" injection-regex = "toml" file-types = ["toml"] @@ -26,7 +24,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "protobuf" -display-name = "Protobuf" scope = "source.proto" injection-regex = "protobuf" file-types = ["proto"] @@ -37,7 +34,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "elixir" -display-name = "Elixir" scope = "source.elixir" injection-regex = "elixir" file-types = ["ex", "exs"] @@ -50,7 +46,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "mint" -display-name = "Mint" scope = "source.mint" injection-regex = "mint" file-types = ["mint"] @@ -63,7 +58,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "json" -display-name = "JSON" scope = "source.json" injection-regex = "json" file-types = ["json"] @@ -73,7 +67,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "c" -display-name = "C" scope = "source.c" injection-regex = "c" file-types = ["c"] # TODO: ["h"] @@ -85,7 +78,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "cpp" -display-name = "C++" scope = "source.cpp" injection-regex = "cpp" file-types = ["cc", "hh", "cpp", "hpp", "h", "ipp", "tpp", "cxx", "hxx", "ixx", "txx", "ino"] @@ -97,7 +89,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "c-sharp" -display-name = "C#" scope = "source.csharp" injection-regex = "c-?sharp" file-types = ["cs"] @@ -108,7 +99,6 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "go" -display-name = "Go" scope = "source.go" injection-regex = "go" file-types = ["go"] @@ -122,7 +112,6 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "javascript" -display-name = "JavaScript" scope = "source.js" injection-regex = "^(js|javascript)$" file-types = ["js", "mjs"] @@ -135,7 +124,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "typescript" -display-name = "TypeScript" scope = "source.ts" injection-regex = "^(ts|typescript)$" file-types = ["ts"] @@ -148,7 +136,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "tsx" -display-name = "TSX" scope = "source.tsx" injection-regex = "^(tsx)$" # |typescript file-types = ["tsx"] @@ -160,7 +147,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "css" -display-name = "CSS" scope = "source.css" injection-regex = "css" file-types = ["css"] @@ -170,7 +156,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "html" -display-name = "HTML" scope = "text.html.basic" injection-regex = "html" file-types = ["html"] @@ -180,7 +165,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "python" -display-name = "Python" scope = "source.python" injection-regex = "python" file-types = ["py"] @@ -194,7 +178,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "nix" -display-name = "Nix" scope = "source.nix" injection-regex = "nix" file-types = ["nix"] @@ -207,7 +190,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "ruby" -display-name = "Ruby" scope = "source.ruby" injection-regex = "ruby" file-types = ["rb"] @@ -220,7 +202,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "bash" -display-name = "Bash" scope = "source.bash" injection-regex = "bash" file-types = ["sh", "bash"] @@ -233,7 +214,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "php" -display-name = "PHP" scope = "source.php" injection-regex = "php" file-types = ["php"] @@ -244,7 +224,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "latex" -display-name = "LaTeX" scope = "source.tex" injection-regex = "tex" file-types = ["tex"] @@ -255,7 +234,6 @@ indent = { tab-width = 4, unit = "\t" } [[language]] name = "julia" -display-name = "Julia" scope = "source.julia" injection-regex = "julia" file-types = ["jl"] @@ -271,7 +249,6 @@ language-server = { command = "julia", args = [ using Pkg; import StaticLint; env_path = dirname(Pkg.Types.Context().env.project_file); - server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, ""); server.runlinter = true; run(server); @@ -281,7 +258,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "java" -display-name = "Java" scope = "source.java" injection-regex = "java" file-types = ["java"] @@ -290,7 +266,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "ledger" -display-name = "Ledger" scope = "source.ledger" injection-regex = "ledger" file-types = ["ldg", "ledger", "journal"] @@ -300,7 +275,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "ocaml" -display-name = "OCaml" scope = "source.ocaml" injection-regex = "ocaml" file-types = ["ml"] @@ -311,7 +285,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "ocaml-interface" -display-name = "OCaml-Interface" scope = "source.ocaml.interface" file-types = ["mli"] shebangs = [] @@ -321,7 +294,6 @@ indent = { tab-width = 2, unit = " "} [[language]] name = "lua" -display-name = "Lua" scope = "source.lua" file-types = ["lua"] shebangs = ["lua"] @@ -331,7 +303,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "svelte" -display-name = "Svelte" scope = "source.svelte" injection-regex = "svelte" file-types = ["svelte"] @@ -342,7 +313,6 @@ language-server = { command = "svelteserver", args = ["--stdio"] } [[language]] name = "vue" -display-name = "Vue" scope = "source.vue" injection-regex = "vue" file-types = ["vue"] @@ -351,7 +321,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "yaml" -display-name = "YAML" scope = "source.yaml" file-types = ["yml", "yaml"] roots = [] @@ -360,7 +329,6 @@ indent = { tab-width = 2, unit = " " } # [[language]] # name = "haskell" -# display-name = "Haskell" # scope = "source.haskell" # injection-regex = "haskell" # file-types = ["hs"] @@ -371,7 +339,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "zig" -display-name = "Zig" scope = "source.zig" injection-regex = "zig" file-types = ["zig"] @@ -384,7 +351,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "prolog" -display-name = "Prolog" scope = "source.prolog" roots = [] file-types = ["pl", "prolog"] @@ -398,7 +364,6 @@ language-server = { command = "swipl", args = [ [[language]] name = "tsq" -display-name = "TSQ" scope = "source.tsq" file-types = ["scm"] roots = [] @@ -407,7 +372,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "cmake" -display-name = "CMake" scope = "source.cmake" file-types = ["cmake", "CMakeLists.txt"] roots = [] @@ -417,7 +381,6 @@ language-server = { command = "cmake-language-server" } [[language]] name = "glsl" -display-name = "GLSL" scope = "source.glsl" file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ] roots = [] @@ -426,7 +389,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "perl" -display-name = "Perl" scope = "source.perl" file-types = ["pl", "pm"] shebangs = ["perl"] @@ -436,7 +398,6 @@ indent = { tab-width = 2, unit = " " } [[language]] name = "racket" -display-name = "Racket" scope = "source.rkt" roots = [] file-types = ["rkt"] @@ -446,7 +407,6 @@ language-server = { command = "racket", args = ["-l", "racket-langserver"] } [[language]] name = "wgsl" -display-name = "WGSL" scope = "source.wgsl" file-types = ["wgsl"] roots = [] @@ -455,7 +415,6 @@ indent = { tab-width = 4, unit = " " } [[language]] name = "llvm" -display-name = "LLVM" scope = "source.llvm" roots = [] file-types = ["ll"] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 37e70592..7256653a 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -184,7 +184,7 @@ pub mod md_gen { .iter() .find(|l| l.language_id == lang) .unwrap(); // lang comes from config - row.push(lc.display_name.clone()); + row.push(lc.language_id.clone()); for (_feat, support_list) in &ts_features_to_langs { row.push( -- cgit v1.2.3-70-g09d2 From 4527d63a652fdf323e623ebced47bc43484194da Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 14 Dec 2021 13:57:31 +0900 Subject: fix: rust: disable unresolved-proc-macro Since we disabled proc macro expansion, disable the related info level lint: https://users.rust-lang.org/t/how-to-disable-rust-analyzer-proc-macro-warnings-in-neovim/53150/3 --- languages.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 428051a7..07b6dba9 100644 --- a/languages.toml +++ b/languages.toml @@ -11,6 +11,7 @@ indent = { tab-width = 4, unit = " " } [language.config] cargo = { loadOutDirsFromCheck = true } procMacro = { enable = false } +diagnostics = { disabled = ["unresolved-proc-macro"] } [[language]] name = "toml" -- cgit v1.2.3-70-g09d2 From 49e067874133e12d10ad3ac0c941438e2d7025e7 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 15 Dec 2021 00:45:38 +0900 Subject: Add markdown grammar Fixes #215 --- .gitmodules | 4 ++++ helix-syntax/languages/tree-sitter-markdown | 1 + languages.toml | 9 ++++++++ runtime/queries/markdown/highlights.scm | 35 +++++++++++++++++++++++++++++ runtime/queries/markdown/injections.scm | 0 runtime/queries/svelte/highlights.scm | 2 +- theme.toml | 6 +++++ 7 files changed, 56 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-markdown create mode 100644 runtime/queries/markdown/highlights.scm create mode 100644 runtime/queries/markdown/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 6295b9e9..9c10846d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -150,3 +150,7 @@ path = helix-syntax/languages/tree-sitter-llvm url = https://github.com/benwilliamgraham/tree-sitter-llvm shallow = true +[submodule "helix-syntax/languages/tree-sitter-markdown"] + path = helix-syntax/languages/tree-sitter-markdown + url = https://github.com/MDeiml/tree-sitter-markdown + shallow = true diff --git a/helix-syntax/languages/tree-sitter-markdown b/helix-syntax/languages/tree-sitter-markdown new file mode 160000 index 00000000..ad8c3291 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-markdown @@ -0,0 +1 @@ +Subproject commit ad8c32917a16dfbb387d1da567bf0c3fb6fffde2 diff --git a/languages.toml b/languages.toml index 07b6dba9..abb94acf 100644 --- a/languages.toml +++ b/languages.toml @@ -421,3 +421,12 @@ roots = [] file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "markdown" +scope = "source.md" +injection-regex = "md|markdown" +file-types = ["md"] +roots = [] + +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm new file mode 100644 index 00000000..a102719b --- /dev/null +++ b/runtime/queries/markdown/highlights.scm @@ -0,0 +1,35 @@ +[ + (atx_heading) + (setext_heading) +] @markup.heading + +(code_fence_content) @none + +[ + (indented_code_block) + (fenced_code_block) +] @markup.raw.block + +(code_span) @markup.raw.inline + +(emphasis) @markup.italic + +(strong_emphasis) @markup.bold + +(link_destination) @markup.underline.link + +; (link_label) @markup.label ; TODO: rename + +[ + (list_marker_plus) + (list_marker_minus) + (list_marker_star) + (list_marker_dot) + (list_marker_parenthesis) +] @punctuation.special + +[ + (backslash_escape) + (hard_line_break) +] @string.character.escape + diff --git a/runtime/queries/markdown/injections.scm b/runtime/queries/markdown/injections.scm new file mode 100644 index 00000000..e69de29b diff --git a/runtime/queries/svelte/highlights.scm b/runtime/queries/svelte/highlights.scm index 4fcdfd66..f9eef6b5 100644 --- a/runtime/queries/svelte/highlights.scm +++ b/runtime/queries/svelte/highlights.scm @@ -25,7 +25,7 @@ ((attribute (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @markup.undeline.link)) + (quoted_attribute_value (attribute_value) @markup.underline.link)) (#match? @_attr "^(href|src)$")) (tag_name) @tag diff --git a/theme.toml b/theme.toml index 8c0d1f6c..0a79861e 100644 --- a/theme.toml +++ b/theme.toml @@ -28,6 +28,12 @@ string = "silver" # used for lifetimes label = "honey" +"markup.heading" = "lilac" +"markup.bold" = { modifiers = ["bold"] } +"markup.italic" = { modifiers = ["italic"] } +"markup.underline.link" = { fg = "silver", modifiers = ["underlined"] } +"markup.raw" = "almond" + # TODO: diferentiate doc comment # concat (ERROR) @error.syntax and "MISSING ;" selectors for errors -- cgit v1.2.3-70-g09d2 From 0683f0a20ae1c1ce3e7788e303c468767381e6fd Mon Sep 17 00:00:00 2001 From: Oliver Hechtl Date: Sat, 18 Dec 2021 05:40:34 +0100 Subject: Add scala syntax highlights (#1278) * add partial scala syntax highlights * ran cargo xtask docgen * updated tree-sitter-scala, fixed highlights * fix comments * move identifier to the end of the highlights * add indents--- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-scala | 2 +- languages.toml | 9 ++ runtime/queries/scala/highlights.scm | 203 +++++++++++++++++++++++++++++++ runtime/queries/scala/indents.toml | 23 ++++ runtime/queries/scala/injections.scm | 1 + 6 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/scala/highlights.scm create mode 100644 runtime/queries/scala/indents.toml create mode 100644 runtime/queries/scala/injections.scm (limited to 'languages.toml') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 80989e63..b7babd8c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -31,6 +31,7 @@ | racket | | | | `racket` | | ruby | ✓ | | | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | +| scala | ✓ | | | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | | toml | ✓ | | | | | tsq | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-scala b/helix-syntax/languages/tree-sitter-scala index fb23ed9a..0a3dd53a 160000 --- a/helix-syntax/languages/tree-sitter-scala +++ b/helix-syntax/languages/tree-sitter-scala @@ -1 +1 @@ -Subproject commit fb23ed9a99da012d86b7a5059b9d8928607cce29 +Subproject commit 0a3dd53a7fc4b352a538397d054380aaa28be54c diff --git a/languages.toml b/languages.toml index abb94acf..88882f3e 100644 --- a/languages.toml +++ b/languages.toml @@ -430,3 +430,12 @@ file-types = ["md"] roots = [] indent = { tab-width = 2, unit = " " } + +[[language]] +name = "scala" +scope = "source.scala" +roots = ["build.sbt"] +file-types = ["scala", "sbt"] +comment-token = "//" +indent = { tab-width = 2, unit = " " } +language-server = { command = "metals" } diff --git a/runtime/queries/scala/highlights.scm b/runtime/queries/scala/highlights.scm new file mode 100644 index 00000000..50a6e18a --- /dev/null +++ b/runtime/queries/scala/highlights.scm @@ -0,0 +1,203 @@ +; CREDITS @stumash (stuart.mashaal@gmail.com) + +;; variables + + +((identifier) @variable.builtin + (#match? @variable.builtin "^this$")) + +(interpolation) @none + +; Assume other uppercase names constants. +; NOTE: In order to distinguish constants we highlight +; all the identifiers that are uppercased. But this solution +; is not suitable for all occurrences e.g. it will highlight +; an uppercased method as a constant if used with no params. +; Introducing highlighting for those specific cases, is probably +; best way to resolve the issue. +((identifier) @constant (#match? @constant "^[A-Z]")) + +;; types + +(type_identifier) @type + +(class_definition + name: (identifier) @type) + +(object_definition + name: (identifier) @type) + +(trait_definition + name: (identifier) @type) + +(type_definition + name: (type_identifier) @type) + +; method definition + +(class_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) +(object_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) +(trait_definition + body: (template_body + (function_definition + name: (identifier) @function.method))) + +; imports + +(import_declaration + path: (identifier) @namespace) +((stable_identifier (identifier) @namespace)) + +((import_declaration + path: (identifier) @type) (#match? @type "^[A-Z]")) +((stable_identifier (identifier) @type) (#match? @type "^[A-Z]")) + +((import_selectors (identifier) @type) (#match? @type "^[A-Z]")) + +; method invocation + + +(call_expression + function: (identifier) @function) + +(call_expression + function: (field_expression + field: (identifier) @function.method)) + +((call_expression + function: (identifier) @variable.other.member) + (#match? @variable.other.member "^[A-Z]")) + +(generic_function + function: (identifier) @function) + +( + (identifier) @function.builtin + (#match? @function.builtin "^super$") +) + +; function definitions + +(function_definition + name: (identifier) @function) + +(parameter + name: (identifier) @variable.parameter) + +; expressions + + +(field_expression field: (identifier) @variable.other.member) +(field_expression value: (identifier) @type + (#match? @type "^[A-Z]")) + +(infix_expression operator: (identifier) @operator) +(infix_expression operator: (operator_identifier) @operator) +(infix_type operator: (operator_identifier) @operator) +(infix_type operator: (operator_identifier) @operator) + +; literals +(boolean_literal) @constant.builtin.boolean +(integer_literal) @constant.numeric.integer +(floating_point_literal) @constant.numeric.float + + +(symbol_literal) @string.special.symbol + +[ +(string) +(character_literal) +(interpolated_string_expression) +] @string + +(interpolation "$" @punctuation.special) + +;; keywords + +[ + "abstract" + "case" + "class" + "extends" + "final" + "finally" +;; `forSome` existential types not implemented yet + "implicit" + "lazy" +;; `macro` not implemented yet + "object" + "override" + "package" + "private" + "protected" + "sealed" + "trait" + "type" + "val" + "var" + "with" +] @keyword + +(null_literal) @constant.builtin +(wildcard) @keyword + +;; special keywords + +"new" @keyword.operator + +[ + "else" + "if" + "match" + "try" + "catch" + "throw" +] @keyword.control.conditional + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," +] @punctuation.delimiter + +[ + "do" + "for" + "while" + "yield" +] @keyword.control.repeat + +"def" @keyword.function + +[ + "=>" + "<-" + "@" +] @keyword.operator + +"import" @keyword.control.import + +"return" @keyword.control.return + +(comment) @comment + +;; `case` is a conditional keyword in case_block + +(case_block + (case_clause ("case") @keyword.control.conditional)) + +(identifier) @variable \ No newline at end of file diff --git a/runtime/queries/scala/indents.toml b/runtime/queries/scala/indents.toml new file mode 100644 index 00000000..6de54844 --- /dev/null +++ b/runtime/queries/scala/indents.toml @@ -0,0 +1,23 @@ + +indent = [ + "block", + "arguments", + "parameter", + "class_definition", + "trait_definition", + "object_definition", + "function_definition", + "val_definition", + "import_declaration", + "while_expression", + "do_while_expression", + "for_expression", + "try_expression", + "match_expression" +] + +outdent = [ + "}", + "]", + ")" +] diff --git a/runtime/queries/scala/injections.scm b/runtime/queries/scala/injections.scm new file mode 100644 index 00000000..4bb7d675 --- /dev/null +++ b/runtime/queries/scala/injections.scm @@ -0,0 +1 @@ +(comment) @comment -- cgit v1.2.3-70-g09d2 From edf3c70c302aef628dc1a63895e2492d34e82507 Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Sat, 18 Dec 2021 17:41:32 +1300 Subject: Add dart lsp config and queries (#1250) * Add language: dart The setup requires that dart be in the users path, such as: ``` export PATH="$HOME/Android/flutter/bin/cache/dart-sdk/bin/:$PATH" ``` Refactor the dart highlights * lang: dart: add indents and locals * lang: dart: corrections to local scope Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + helix-syntax/languages/tree-sitter-dart | 1 + languages.toml | 12 +- runtime/queries/dart/highlights.scm | 237 ++++++++++++++++++++++++++++++++ runtime/queries/dart/indents.toml | 20 +++ runtime/queries/dart/locals.scm | 20 +++ 6 files changed, 293 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-dart create mode 100644 runtime/queries/dart/highlights.scm create mode 100644 runtime/queries/dart/indents.toml create mode 100644 runtime/queries/dart/locals.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 9c10846d..4b142adf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -154,3 +154,7 @@ path = helix-syntax/languages/tree-sitter-markdown url = https://github.com/MDeiml/tree-sitter-markdown shallow = true +[submodule "helix-syntax/languages/tree-sitter-dart"] + path = helix-syntax/languages/tree-sitter-dart + url = https://github.com/UserNobody14/tree-sitter-dart.git + shallow = true diff --git a/helix-syntax/languages/tree-sitter-dart b/helix-syntax/languages/tree-sitter-dart new file mode 160000 index 00000000..6a253766 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-dart @@ -0,0 +1 @@ +Subproject commit 6a25376685d1d47968c2cef06d4db8d84a70025e diff --git a/languages.toml b/languages.toml index 88882f3e..5c2bc8bb 100644 --- a/languages.toml +++ b/languages.toml @@ -431,6 +431,16 @@ roots = [] indent = { tab-width = 2, unit = " " } +[[language]] +name = "dart" +scope = "source.dart" +file-types = ["dart"] +roots = ["pubspec.yaml"] +auto-format = true +comment-token = "//" +language-server = { command = "dart", args = ["language-server", "--client-id=helix"] } +indent = { tab-width = 2, unit = " " } + [[language]] name = "scala" scope = "source.scala" @@ -438,4 +448,4 @@ roots = ["build.sbt"] file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } -language-server = { command = "metals" } +language-server = { command = "metals" } \ No newline at end of file diff --git a/runtime/queries/dart/highlights.scm b/runtime/queries/dart/highlights.scm new file mode 100644 index 00000000..9f667d6b --- /dev/null +++ b/runtime/queries/dart/highlights.scm @@ -0,0 +1,237 @@ +(dotted_identifier_list) @string + +; Methods +; -------------------- +(super) @function.builtin + +(function_expression_body (identifier) @function.method) +((identifier)(selector (argument_part)) @function.method) + +; Annotations +; -------------------- +(annotation + name: (identifier) @attribute) +(marker_annotation + name: (identifier) @attribute) + +; Types +; -------------------- +(class_definition + name: (identifier) @type) + +(constructor_signature + name: (identifier) @function.method) + +(function_signature + name: (identifier) @function.method) + +(getter_signature + (identifier) @function.builtin) + +(setter_signature + name: (identifier) @function.builtin) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @type.builtin) + +(void_type) @type.builtin + +((scoped_identifier + scope: (identifier) @type) + (#match? @type "^[a-zA-Z]")) + +((scoped_identifier + scope: (identifier) @type + name: (identifier) @type) + (#match? @type "^[a-zA-Z]")) + +; the DisabledDrawerButtons in : const DisabledDrawerButtons(history: true), +(type_identifier) @type.builtin + +; Variables +; -------------------- +; the "File" in var file = File(); +((identifier) @namespace + (#match? @namespace "^_?[A-Z].*[a-z]")) ; catch Classes or IClasses not CLASSES + +("Function" @type.builtin) +(inferred_type) @type.builtin + +; properties +(unconditional_assignable_selector + (identifier) @variable.other.member) + +(conditional_assignable_selector + (identifier) @variable.other.member) + +; assignments +; -------------------- +; the "strings" in : strings = "some string" +(assignment_expression + left: (assignable_expression) @variable) + +(this) @variable.builtin + +; Parameters +; -------------------- +(formal_parameter + name: (identifier) @variable) + +(named_argument + (label (identifier) @variable)) + +; Literals +; -------------------- +[ + (hex_integer_literal) + (decimal_integer_literal) + (decimal_floating_point_literal) + ;(octal_integer_literal) + ;(hex_floating_point_literal) +] @constant.numeric.integer + +(symbol_literal) @string.special.symbol +(string_literal) @string + +[ + (const_builtin) + (final_builtin) +] @variable.builtin + +[ + (true) + (false) +] @constant.builtin.boolean + +(null_literal) @constant.builtin + +(comment) @comment.line +(documentation_comment) @comment.block.documentation + +; Tokens +; -------------------- +(template_substitution + "$" @punctuation.special + "{" @punctuation.special + "}" @punctuation.special +) @embedded + +(template_substitution + "$" @punctuation.special + (identifier_dollar_escaped) @variable +) @embedded + +(escape_sequence) @constant.character.escape + +; Punctuation +;--------------------- +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +; Operators +;--------------------- +[ + "@" + "?" + "=>" + ".." + "==" + "&&" + "%" + "<" + ">" + "=" + ">=" + "<=" + "||" + (multiplicative_operator) + (increment_operator) + (is_operator) + (prefix_operator) + (equality_operator) + (additive_operator) +] @operator + +; Keywords +; -------------------- +["import" "library" "export"] @keyword.control.import +["do" "while" "continue" "for"] @keyword.control.repeat +["return" "yield"] @keyword.control.return +["as" "in" "is"] @keyword.operator + +[ + "?." + "??" + "if" + "else" + "switch" + "default" + "late" +] @keyword.control.conditional + +[ + "try" + "throw" + "catch" + "finally" + (break_statement) +] @keyword.control.exception + +; Reserved words (cannot be used as identifiers) +[ + (case_builtin) + "abstract" + "async" + "async*" + "await" + "class" + "covariant" + "deferred" + "dynamic" + "enum" + "extends" + "extension" + "external" + "factory" + "Function" + "get" + "implements" + "interface" + "mixin" + "new" + "on" + "operator" + "part" + "required" + "set" + "show" + "static" + "super" + "sync*" + "typedef" + "with" +] @keyword + +; when used as an identifier: +((identifier) @variable.builtin + (#match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$")) + +; Error +(ERROR) @error + diff --git a/runtime/queries/dart/indents.toml b/runtime/queries/dart/indents.toml new file mode 100644 index 00000000..5c11e05d --- /dev/null +++ b/runtime/queries/dart/indents.toml @@ -0,0 +1,20 @@ +indent = [ + "class_body", + "function_body", + "function_expression_body", + "declaration", + "initializers", + "switch_block", + "if_statement", + "formal_parameter_list", + "formal_parameter", + "list_literal", + "return_statement", + "arguments" +] + +outdent = [ + "}", + "]", + ")" +] diff --git a/runtime/queries/dart/locals.scm b/runtime/queries/dart/locals.scm new file mode 100644 index 00000000..629838e5 --- /dev/null +++ b/runtime/queries/dart/locals.scm @@ -0,0 +1,20 @@ +; Scopes +;------- + +[ + (block) + (try_statement) + (catch_clause) + (finally_clause) +] @local.scope + +; Definitions +;------------ + +(class_definition + body: (_) @local.definition) + +; References +;------------ + +(identifier) @local.reference -- cgit v1.2.3-70-g09d2 From e72786df8eae5684c0330be18f190a33f516da76 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 19 Dec 2021 08:56:56 -0600 Subject: Add tree-sitter-comment (#1300) * Add tree-sitter-comment Fix #1164 * fix precedence in tree-sitter-comment highlights connects https://github.com/helix-editor/helix/pull/1170 * set injection-regex for comment language * remove comment filetype * fix comment injections for neovim-style injections tags * add comment injections for elixir * remove f.comment * fix spacing in .gitmodules * run 'cargo xtask docgen' Co-authored-by: Ivan Tham --- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-comment | 1 + languages.toml | 9 ++++++++- runtime/queries/comment/highlights.scm | 30 ++++++++++++++++++++++++++++++ runtime/queries/elixir/injections.scm | 2 ++ runtime/queries/glsl/injections.scm | 6 ++++-- runtime/queries/julia/injections.scm | 8 +++++--- runtime/queries/ledger/injections.scm | 4 ++-- runtime/queries/python/injections.scm | 2 ++ runtime/queries/rust/injections.scm | 3 +++ runtime/queries/svelte/injections.scm | 4 ++-- runtime/queries/tsq/injections.scm | 2 ++ 13 files changed, 66 insertions(+), 10 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-comment create mode 100644 runtime/queries/comment/highlights.scm create mode 100644 runtime/queries/elixir/injections.scm create mode 100644 runtime/queries/python/injections.scm create mode 100644 runtime/queries/tsq/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index a899c778..c7b81336 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,6 +142,10 @@ path = helix-syntax/languages/tree-sitter-perl url = https://github.com/ganezdragon/tree-sitter-perl shallow = true +[submodule "helix-syntax/languages/tree-sitter-comment"] + path = helix-syntax/languages/tree-sitter-comment + url = https://github.com/stsewd/tree-sitter-comment + shallow = true [submodule "helix-syntax/languages/tree-sitter-wgsl"] path = helix-syntax/languages/tree-sitter-wgsl url = https://github.com/szebniok/tree-sitter-wgsl diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 3255b9af..cb91872b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -4,6 +4,7 @@ | c | ✓ | | | `clangd` | | c-sharp | ✓ | | | | | cmake | ✓ | | | `cmake-language-server` | +| comment | ✓ | | | | | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | diff --git a/helix-syntax/languages/tree-sitter-comment b/helix-syntax/languages/tree-sitter-comment new file mode 160000 index 00000000..5dd3c62f --- /dev/null +++ b/helix-syntax/languages/tree-sitter-comment @@ -0,0 +1 @@ +Subproject commit 5dd3c62f1bbe378b220fe16b317b85247898639e diff --git a/languages.toml b/languages.toml index 5c2bc8bb..0695022e 100644 --- a/languages.toml +++ b/languages.toml @@ -406,6 +406,13 @@ shebangs = ["racket"] comment-token = ";" language-server = { command = "racket", args = ["-l", "racket-langserver"] } +[[language]] +name = "comment" +scope = "scope.comment" +roots = [] +file-types = [] +injection-regex = "comment" + [[language]] name = "wgsl" scope = "source.wgsl" @@ -448,4 +455,4 @@ roots = ["build.sbt"] file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } -language-server = { command = "metals" } \ No newline at end of file +language-server = { command = "metals" } diff --git a/runtime/queries/comment/highlights.scm b/runtime/queries/comment/highlights.scm new file mode 100644 index 00000000..88685d59 --- /dev/null +++ b/runtime/queries/comment/highlights.scm @@ -0,0 +1,30 @@ +[ + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter + +((tag (name) @warning) + (#match? @warning "^(TODO|HACK|WARNING)$")) + +("text" @warning + (#match? @warning "^(TODO|HACK|WARNING)$")) + +((tag (name) @error) + (match? @error "^(FIXME|XXX|BUG)$")) + +("text" @error + (match? @error "^(FIXME|XXX|BUG)$")) + +(tag + (name) @ui.text + (user)? @constant) + +; Issue number (#123) +("text" @constant.numeric + (#match? @constant.numeric "^#[0-9]+$")) + +; User mention (@user) +("text" @tag + (#match? @tag "^[@][a-zA-Z0-9_-]+$")) diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/elixir/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/glsl/injections.scm b/runtime/queries/glsl/injections.scm index 7d3323b1..b01b8b4b 100644 --- a/runtime/queries/glsl/injections.scm +++ b/runtime/queries/glsl/injections.scm @@ -1,3 +1,5 @@ -(preproc_arg) @glsl +((preproc_arg) @injection.content + (#set! injection.language "glsl")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/julia/injections.scm b/runtime/queries/julia/injections.scm index be2412c0..3cf7339f 100644 --- a/runtime/queries/julia/injections.scm +++ b/runtime/queries/julia/injections.scm @@ -1,5 +1,7 @@ ; TODO: re-add when markdown is added. -; ((triple_string) @markdown -; (#offset! @markdown 0 3 0 -3)) +; ((triple_string) @injection.content +; (#offset! @injection.content 0 3 0 -3) +; (#set! injection.language "markdown")) -(comment) @comment +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ledger/injections.scm b/runtime/queries/ledger/injections.scm index 2d948141..c1714786 100644 --- a/runtime/queries/ledger/injections.scm +++ b/runtime/queries/ledger/injections.scm @@ -1,2 +1,2 @@ -(comment) @comment -(note) @comment +([(comment) (note)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/python/injections.scm b/runtime/queries/python/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/python/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm index 6035d418..d8382e49 100644 --- a/runtime/queries/rust/injections.scm +++ b/runtime/queries/rust/injections.scm @@ -1,3 +1,6 @@ +([(line_comment) (block_comment)] @injection.content + (#set! injection.language "comment")) + ((macro_invocation (token_tree) @injection.content) (#set! injection.language "rust") diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm index 266f4701..04e860cf 100644 --- a/runtime/queries/svelte/injections.scm +++ b/runtime/queries/svelte/injections.scm @@ -26,5 +26,5 @@ (#set! injection.language "typescript") ) -(comment) @comment - +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tsq/injections.scm b/runtime/queries/tsq/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/tsq/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From 205dc8776b6ff4f5ab331df9c33b33e44caab12c Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 21 Dec 2021 03:02:53 +0100 Subject: Add fish highlighting (#1308) The highlights were copied and modified from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/fish/highlights.scm--- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-fish | 1 + languages.toml | 11 +++ runtime/queries/fish/highlights.scm | 156 ++++++++++++++++++++++++++++++++ runtime/queries/fish/indents.toml | 12 +++ runtime/queries/fish/injections.scm | 2 + runtime/queries/fish/textobjects.scm | 1 + 8 files changed, 188 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-fish create mode 100644 runtime/queries/fish/highlights.scm create mode 100644 runtime/queries/fish/indents.toml create mode 100644 runtime/queries/fish/injections.scm create mode 100644 runtime/queries/fish/textobjects.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index c7b81336..dcec2813 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,3 +162,7 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-fish"] + path = helix-syntax/languages/tree-sitter-fish + url = https://github.com/ram02z/tree-sitter-fish + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index cb91872b..24b75b64 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -9,6 +9,7 @@ | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | | elixir | ✓ | | | `elixir-ls` | +| fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-fish b/helix-syntax/languages/tree-sitter-fish new file mode 160000 index 00000000..04e54ab6 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-fish @@ -0,0 +1 @@ +Subproject commit 04e54ab6585dfd4fee6ddfe5849af56f101b6d4f diff --git a/languages.toml b/languages.toml index 0695022e..61eb47ec 100644 --- a/languages.toml +++ b/languages.toml @@ -45,6 +45,17 @@ comment-token = "#" language-server = { command = "elixir-ls" } indent = { tab-width = 2, unit = " " } +[[language]] +name = "fish" +scope = "source.fish" +injection-regex = "fish" +file-types = ["fish"] +shebangs = ["fish"] +roots = [] +comment-token = "#" + +indent = { tab-width = 4, unit = " " } + [[language]] name = "mint" scope = "source.mint" diff --git a/runtime/queries/fish/highlights.scm b/runtime/queries/fish/highlights.scm new file mode 100644 index 00000000..def53931 --- /dev/null +++ b/runtime/queries/fish/highlights.scm @@ -0,0 +1,156 @@ +;; Operators + +[ + "&&" + "||" + "|" + "&" + "=" + "!=" + ".." + "!" + (direction) + (stream_redirect) + (test_option) +] @operator + +[ + "not" + "and" + "or" +] @keyword.operator + +;; Conditionals + +(if_statement +[ + "if" + "end" +] @keyword.control.conditional) + +(switch_statement +[ + "switch" + "end" +] @keyword.control.conditional) + +(case_clause +[ + "case" +] @keyword.control.conditional) + +(else_clause +[ + "else" +] @keyword.control.conditional) + +(else_if_clause +[ + "else" + "if" +] @keyword.control.conditional) + +;; Loops/Blocks + +(while_statement +[ + "while" + "end" +] @keyword.control.repeat) + +(for_statement +[ + "for" + "end" +] @keyword.control.repeat) + +(begin_statement +[ + "begin" + "end" +] @keyword.control.repeat) + +;; Keywords + +[ + "in" + (break) + (continue) +] @keyword + +"return" @keyword.control.return + +;; Punctuation + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +;; Commands + +(command + argument: [ + (word) @variable.parameter (#match? @variable.parameter "^-") + ] +) + +; non-bultin command names +(command name: (word) @function) + +; derived from builtin -n (fish 3.2.2) +(command + name: [ + (word) @function.builtin + (#match? @function.builtin "^(\.|:|_|alias|argparse|bg|bind|block|breakpoint|builtin|cd|command|commandline|complete|contains|count|disown|echo|emit|eval|exec|exit|fg|functions|history|isatty|jobs|math|printf|pwd|random|read|realpath|set|set_color|source|status|string|test|time|type|ulimit|wait)$") + ] +) + +(test_command "test" @function.builtin) + +;; Functions + +(function_definition ["function" "end"] @keyword.function) + +(function_definition + name: [ + (word) (concatenation) + ] +@function) + +(function_definition + option: [ + (word) + (concatenation (word)) + ] @variable.parameter (#match? @variable.parameter "^-") +) + +;; Strings + +[(double_quote_string) (single_quote_string)] @string +(escape_sequence) @constant.character.escape + +;; Variables + +(variable_name) @variable +(variable_expansion) @constant + +;; Nodes + +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(comment) @comment +(test_option) @string + +((word) @constant.builtin.boolean +(#match? @constant.builtin.boolean "^(true|false)$")) + +;; Error + +(ERROR) @error diff --git a/runtime/queries/fish/indents.toml b/runtime/queries/fish/indents.toml new file mode 100644 index 00000000..6f1e563a --- /dev/null +++ b/runtime/queries/fish/indents.toml @@ -0,0 +1,12 @@ +indent = [ + "function_definition", + "while_statement", + "for_statement", + "if_statement", + "begin_statement", + "switch_statement", +] + +outdent = [ + "end" +] diff --git a/runtime/queries/fish/injections.scm b/runtime/queries/fish/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/fish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fish/textobjects.scm b/runtime/queries/fish/textobjects.scm new file mode 100644 index 00000000..67fd6614 --- /dev/null +++ b/runtime/queries/fish/textobjects.scm @@ -0,0 +1 @@ +(function_definition) @function.around -- cgit v1.2.3-70-g09d2 From dba22c60ed7fc336ad619b1246333f0116b47bcd Mon Sep 17 00:00:00 2001 From: Midnight Exigent Date: Tue, 21 Dec 2021 10:22:15 +0100 Subject: Support dockerfiles (#1303) * allow language.config (in languages.toml) to be passed in as a toml object * Change config field for languages from json string to toml object * remove indents on languages.toml config * fix: remove patch version from serde_json import in helix-core * Use same tree-sitter-zig as upstream/master * fix(completion_popup): Fixes #1256 * Update helix-term/src/ui/completion.rs * feat(languages): Add support for `Dockerfile`s * docs(cargo-xtask-docgen): * improvement(langs-dockerfile): Add `injection-regex` to `languages.toml` for `Dockerfile` * improvement(langs-dockerfile): Add injections.scm * Update .gitmodules Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-dockerfile | 1 + languages.toml | 11 ++++++ runtime/queries/dockerfile/highlights.scm | 51 +++++++++++++++++++++++++++ runtime/queries/dockerfile/injections.scm | 6 ++++ 6 files changed, 74 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-dockerfile create mode 100644 runtime/queries/dockerfile/highlights.scm create mode 100644 runtime/queries/dockerfile/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index dcec2813..edfe3c39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -162,6 +162,10 @@ path = helix-syntax/languages/tree-sitter-dart url = https://github.com/UserNobody14/tree-sitter-dart.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-dockerfile"] + path = helix-syntax/languages/tree-sitter-dockerfile + url = https://github.com/camdencheek/tree-sitter-dockerfile.git + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 24b75b64..c7054201 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -8,6 +8,7 @@ | cpp | ✓ | | | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | +| dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | glsl | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-dockerfile b/helix-syntax/languages/tree-sitter-dockerfile new file mode 160000 index 00000000..7af32bc0 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-dockerfile @@ -0,0 +1 @@ +Subproject commit 7af32bc04a66ab196f5b9f92ac471f29372ae2ce diff --git a/languages.toml b/languages.toml index 61eb47ec..50c6f7f9 100644 --- a/languages.toml +++ b/languages.toml @@ -467,3 +467,14 @@ file-types = ["scala", "sbt"] comment-token = "//" indent = { tab-width = 2, unit = " " } language-server = { command = "metals" } + +[[language]] +name = "dockerfile" +scope = "source.dockerfile" +injection-regex = "docker|dockerfile" +roots = ["Dockerfile"] +file-types = ["Dockerfile"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } +language-server = { command = "docker-langserver", args = ["--stdio"] } + diff --git a/runtime/queries/dockerfile/highlights.scm b/runtime/queries/dockerfile/highlights.scm new file mode 100644 index 00000000..5a945fb9 --- /dev/null +++ b/runtime/queries/dockerfile/highlights.scm @@ -0,0 +1,51 @@ +[ + "FROM" + "AS" + "RUN" + "CMD" + "LABEL" + "EXPOSE" + "ENV" + "ADD" + "COPY" + "ENTRYPOINT" + "VOLUME" + "USER" + "WORKDIR" + "ARG" + "ONBUILD" + "STOPSIGNAL" + "HEALTHCHECK" + "SHELL" + "MAINTAINER" + "CROSS_BUILD" +] @keyword + +[ + ":" + "@" +] @operator + +(comment) @comment + + +(image_spec + (image_tag + ":" @punctuation.special) + (image_digest + "@" @punctuation.special)) + +(double_quoted_string) @string + +(expansion + [ + "$" + "{" + "}" + ] @punctuation.special +) @none + +((variable) @constant + (#match? @constant "^[A-Z][A-Z_0-9]*$")) + + diff --git a/runtime/queries/dockerfile/injections.scm b/runtime/queries/dockerfile/injections.scm new file mode 100644 index 00000000..20396f1a --- /dev/null +++ b/runtime/queries/dockerfile/injections.scm @@ -0,0 +1,6 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +([(shell_command) (shell_fragment)] @injection.content + (#set! injection.language "bash")) + -- cgit v1.2.3-70-g09d2 From 34766e242ab0a059c8313b068b98d275e2a879b8 Mon Sep 17 00:00:00 2001 From: Dylan Richardson Date: Tue, 21 Dec 2021 18:45:02 -0600 Subject: languages: add .dockerfile extension (#1330) Many folks use `.dockerfile` as an extension for dockerfiles in addition to plain `Dockerfile`. This change associates both file extensions with dockerfile syntax highlighting--- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 50c6f7f9..54fa63ee 100644 --- a/languages.toml +++ b/languages.toml @@ -473,7 +473,7 @@ name = "dockerfile" scope = "source.dockerfile" injection-regex = "docker|dockerfile" roots = ["Dockerfile"] -file-types = ["Dockerfile"] +file-types = ["Dockerfile", "dockerfile"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } -- cgit v1.2.3-70-g09d2 From 13d804418f35878ca155d36d0bb9c0c1a51fcd5a Mon Sep 17 00:00:00 2001 From: Laurențiu Nicola Date: Fri, 24 Dec 2021 16:56:13 +0200 Subject: Enable Rust proc macro support (#1350) --- languages.toml | 5 ----- 1 file changed, 5 deletions(-) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 54fa63ee..dd18fa19 100644 --- a/languages.toml +++ b/languages.toml @@ -8,10 +8,6 @@ auto-format = true comment-token = "//" language-server = { command = "rust-analyzer" } indent = { tab-width = 4, unit = " " } -[language.config] -cargo = { loadOutDirsFromCheck = true } -procMacro = { enable = false } -diagnostics = { disabled = ["unresolved-proc-macro"] } [[language]] name = "toml" @@ -477,4 +473,3 @@ file-types = ["Dockerfile", "dockerfile"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } - -- cgit v1.2.3-70-g09d2 From fd31662b70ee32d199950ba2873680fc9043c975 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 12:44:45 -0600 Subject: add gitcommit grammar and language configuration --- .gitmodules | 6 +++++- book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 + languages.toml | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 160000 helix-syntax/languages/tree-sitter-gitcommit (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index edfe3c39..ad100a00 100644 --- a/.gitmodules +++ b/.gitmodules @@ -165,8 +165,12 @@ [submodule "helix-syntax/languages/tree-sitter-dockerfile"] path = helix-syntax/languages/tree-sitter-dockerfile url = https://github.com/camdencheek/tree-sitter-dockerfile.git - shallow = true + shallow = true [submodule "helix-syntax/languages/tree-sitter-fish"] path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true +[submodule "helix-syntax/languages/tree-sitter-gitcommit"] + path = helix-syntax/languages/tree-sitter-gitcommit + url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 2777dc4e..d6e0d9af 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,6 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | +| gitcommit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit new file mode 160000 index 00000000..6a2ddbec --- /dev/null +++ b/helix-syntax/languages/tree-sitter-gitcommit @@ -0,0 +1 @@ +Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index dd18fa19..f73011c8 100644 --- a/languages.toml +++ b/languages.toml @@ -473,3 +473,11 @@ file-types = ["Dockerfile", "dockerfile"] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } + +[[language]] +name = "gitcommit" +scope = "git.commitmsg" +roots = [] +file-types = ["COMMIT_EDITMSG"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } -- cgit v1.2.3-70-g09d2 From c3fb86cbaa5c6973fe014a4401c4e0d6f663384d Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 24 Dec 2021 16:49:27 -0600 Subject: tree-sitter-gitcommit->tree-sitter-git-commit --- .gitmodules | 6 +++--- book/src/generated/lang-support.md | 2 +- helix-syntax/languages/tree-sitter-git-commit | 1 + helix-syntax/languages/tree-sitter-gitcommit | 1 - languages.toml | 2 +- runtime/queries/git-commit/highlights.scm | 18 ++++++++++++++++++ runtime/queries/git-commit/injections.scm | 15 +++++++++++++++ runtime/queries/gitcommit/highlights.scm | 18 ------------------ runtime/queries/gitcommit/injections.scm | 15 --------------- 9 files changed, 39 insertions(+), 39 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-commit delete mode 160000 helix-syntax/languages/tree-sitter-gitcommit create mode 100644 runtime/queries/git-commit/highlights.scm create mode 100644 runtime/queries/git-commit/injections.scm delete mode 100644 runtime/queries/gitcommit/highlights.scm delete mode 100644 runtime/queries/gitcommit/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index ad100a00..d5bd61c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -170,7 +170,7 @@ path = helix-syntax/languages/tree-sitter-fish url = https://github.com/ram02z/tree-sitter-fish shallow = true -[submodule "helix-syntax/languages/tree-sitter-gitcommit"] - path = helix-syntax/languages/tree-sitter-gitcommit - url = https://github.com/the-mikedavis/tree-sitter-gitcommit.git +[submodule "helix-syntax/languages/tree-sitter-git-commit"] + path = helix-syntax/languages/tree-sitter-git-commit + url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d6e0d9af..9c42005b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -11,7 +11,7 @@ | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | -| gitcommit | ✓ | | | | +| git-commit | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit new file mode 160000 index 00000000..5cd4776c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -0,0 +1 @@ +Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 diff --git a/helix-syntax/languages/tree-sitter-gitcommit b/helix-syntax/languages/tree-sitter-gitcommit deleted file mode 160000 index 6a2ddbec..00000000 --- a/helix-syntax/languages/tree-sitter-gitcommit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a2ddbecd49fa8e7e1fda24d43e363cfd9171ca0 diff --git a/languages.toml b/languages.toml index f73011c8..616ef234 100644 --- a/languages.toml +++ b/languages.toml @@ -475,7 +475,7 @@ indent = { tab-width = 2, unit = " " } language-server = { command = "docker-langserver", args = ["--stdio"] } [[language]] -name = "gitcommit" +name = "git-commit" scope = "git.commitmsg" roots = [] file-types = ["COMMIT_EDITMSG"] diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm new file mode 100644 index 00000000..04d70416 --- /dev/null +++ b/runtime/queries/git-commit/highlights.scm @@ -0,0 +1,18 @@ +(subject) @markup.heading +(path) @string.special.path +(branch) @string.special.symbol +(commit) @constant +(item) @markup.link.url +(header) @tag + +(change kind: "new file" @diff.plus) +(change kind: "deleted" @diff.minus) +(change kind: "modified" @diff.delta) +(change kind: "renamed" @diff.delta.moved) + +[":" "->"] @punctuation.delimeter +(comment) @comment + +; once we have diff injections, @comment should become @none +((comment (scissors)) + (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm new file mode 100644 index 00000000..2837a586 --- /dev/null +++ b/runtime/queries/git-commit/injections.scm @@ -0,0 +1,15 @@ +; once a diff grammar is available, we can inject diff highlighting into the +; trailer after scissors (git commit --verbose) +; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 +; +; ((comment (scissors)) +; (message) @injection.content +; (#set! injection.language "diff")) + +; --- + +; once a rebase grammar is available, we can inject rebase highlighting into +; interactive rebase summary sections like so: +; +; ((rebase_command) @injection.content +; (#set! injection.language "git-rebase")) diff --git a/runtime/queries/gitcommit/highlights.scm b/runtime/queries/gitcommit/highlights.scm deleted file mode 100644 index 04d70416..00000000 --- a/runtime/queries/gitcommit/highlights.scm +++ /dev/null @@ -1,18 +0,0 @@ -(subject) @markup.heading -(path) @string.special.path -(branch) @string.special.symbol -(commit) @constant -(item) @markup.link.url -(header) @tag - -(change kind: "new file" @diff.plus) -(change kind: "deleted" @diff.minus) -(change kind: "modified" @diff.delta) -(change kind: "renamed" @diff.delta.moved) - -[":" "->"] @punctuation.delimeter -(comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/gitcommit/injections.scm b/runtime/queries/gitcommit/injections.scm deleted file mode 100644 index 2837a586..00000000 --- a/runtime/queries/gitcommit/injections.scm +++ /dev/null @@ -1,15 +0,0 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- - -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) -- cgit v1.2.3-70-g09d2 From bcf3808e9763bfe1bbf70f6053f890c80639d7c9 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 29 Dec 2021 09:31:23 -0600 Subject: Add tree-sitter-git-diff (#1373) * add submodule on tree-sitter-git-diff * add git-diff highlights * inject git-diff into git-commit * update tree-sitter-git-commit with fix for bad diff case * add git-diff to language support docs * include-children in diff injections This ensures that children nodes of $.message are included in the injection, such as $.user or issue/pr numbers. Without this change, diffs containing '#' or '@' characters can trip up the injection and be parsed separately. See https://github.com/helix-editor/helix/pull/1373#issuecomment-1001215629 * set diff language's scope as source.diff--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-commit | 2 +- helix-syntax/languages/tree-sitter-git-diff | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 4 ---- runtime/queries/git-commit/injections.scm | 13 ++++--------- runtime/queries/git-diff/highlights.scm | 6 ++++++ 8 files changed, 26 insertions(+), 14 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-diff create mode 100644 runtime/queries/git-diff/highlights.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index d5bd61c9..422671b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,3 +174,7 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-diff"] + path = helix-syntax/languages/tree-sitter-git-diff + url = https://github.com/the-mikedavis/tree-sitter-git-diff.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 5d172751..91575c62 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -12,6 +12,7 @@ | elixir | ✓ | | | `elixir-ls` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | +| git-diff | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-commit b/helix-syntax/languages/tree-sitter-git-commit index 5cd4776c..066e395e 160000 --- a/helix-syntax/languages/tree-sitter-git-commit +++ b/helix-syntax/languages/tree-sitter-git-commit @@ -1 +1 @@ -Subproject commit 5cd4776c86c82d9d6afdc8c73a47a08057aef618 +Subproject commit 066e395e1107df17183cf3ae4230f1a1406cc972 diff --git a/helix-syntax/languages/tree-sitter-git-diff b/helix-syntax/languages/tree-sitter-git-diff new file mode 160000 index 00000000..c12e6ecb --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-diff @@ -0,0 +1 @@ +Subproject commit c12e6ecb54485f764250556ffd7ccb18f8e2942b diff --git a/languages.toml b/languages.toml index 616ef234..c3ae9f62 100644 --- a/languages.toml +++ b/languages.toml @@ -481,3 +481,12 @@ roots = [] file-types = ["COMMIT_EDITMSG"] comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-diff" +scope = "source.diff" +roots = [] +file-types = ["diff"] +injection-regex = "diff" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index a74bb381..ffcc31ae 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -13,7 +13,3 @@ [":" "->"] @punctuation.delimeter (comment) @comment - -; once we have diff injections, @comment should become @none -((comment (scissors)) - (message)+ @comment) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index 2837a586..bd96f1de 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -1,12 +1,7 @@ -; once a diff grammar is available, we can inject diff highlighting into the -; trailer after scissors (git commit --verbose) -; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539 -; -; ((comment (scissors)) -; (message) @injection.content -; (#set! injection.language "diff")) - -; --- +((comment (scissors)) + (message) @injection.content + (#set! injection.include-children) + (#set! injection.language "diff")) ; once a rebase grammar is available, we can inject rebase highlighting into ; interactive rebase summary sections like so: diff --git a/runtime/queries/git-diff/highlights.scm b/runtime/queries/git-diff/highlights.scm new file mode 100644 index 00000000..1c1a8829 --- /dev/null +++ b/runtime/queries/git-diff/highlights.scm @@ -0,0 +1,6 @@ +[(addition) (new_file)] @diff.plus +[(deletion) (old_file)] @diff.minus + +(commit) @constant +(location) @attribute +(command) @markup.bold -- cgit v1.2.3-70-g09d2 From 8fda87af2bb0625c502a23ddbd78a7447ada7bcb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 30 Dec 2021 16:58:47 -0600 Subject: add tree-sitter-git-rebase (#1402) * add submodule on tree-sitter-rebase, add to languages * add basic highlights query * inject bash in execute statements * update tree-sitter-rebase * tree-sitter-rebase->tree-sitter-git-rebase * get injection working with tree-sitter-git-commit * set scope under source.gitrebase * unset include-children on commit message injections * Revert "unset include-children on commit message injections" This reverts commit 2ecee155ea8e229651920b291062c2ee84b47944. * fix generated language docs * use rebase_command scopes from tree-sitter-git-commit--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-git-rebase | 1 + languages.toml | 9 +++++++++ runtime/queries/git-commit/highlights.scm | 1 - runtime/queries/git-commit/injections.scm | 8 +++----- runtime/queries/git-rebase/highlights.scm | 11 +++++++++++ runtime/queries/git-rebase/injections.scm | 4 ++++ 8 files changed, 33 insertions(+), 6 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-git-rebase create mode 100644 runtime/queries/git-rebase/highlights.scm create mode 100644 runtime/queries/git-rebase/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 422671b4..22f70c80 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,3 +178,7 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-git-rebase"] + path = helix-syntax/languages/tree-sitter-git-rebase + url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 91575c62..09284d46 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -13,6 +13,7 @@ | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | | git-diff | ✓ | | | | +| git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | html | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-git-rebase b/helix-syntax/languages/tree-sitter-git-rebase new file mode 160000 index 00000000..332dc528 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-git-rebase @@ -0,0 +1 @@ +Subproject commit 332dc528f27044bc4427024dbb33e6941fc131f2 diff --git a/languages.toml b/languages.toml index c3ae9f62..3d9bac7b 100644 --- a/languages.toml +++ b/languages.toml @@ -490,3 +490,12 @@ file-types = ["diff"] injection-regex = "diff" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "git-rebase" +scope = "source.gitrebase" +roots = [] +file-types = ["git-rebase-todo"] +injection-regex = "git-rebase" +comment-token = "#" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/git-commit/highlights.scm b/runtime/queries/git-commit/highlights.scm index ffcc31ae..0b50d419 100644 --- a/runtime/queries/git-commit/highlights.scm +++ b/runtime/queries/git-commit/highlights.scm @@ -4,7 +4,6 @@ (commit) @constant (item) @markup.link.url (header) @tag -(rebase_command) @markup.raw (change kind: "new file" @diff.plus) (change kind: "deleted" @diff.minus) diff --git a/runtime/queries/git-commit/injections.scm b/runtime/queries/git-commit/injections.scm index bd96f1de..cf0657f7 100644 --- a/runtime/queries/git-commit/injections.scm +++ b/runtime/queries/git-commit/injections.scm @@ -3,8 +3,6 @@ (#set! injection.include-children) (#set! injection.language "diff")) -; once a rebase grammar is available, we can inject rebase highlighting into -; interactive rebase summary sections like so: -; -; ((rebase_command) @injection.content -; (#set! injection.language "git-rebase")) +((rebase_command) @injection.content + (#set! injection.include-children) + (#set! injection.language "git-rebase")) diff --git a/runtime/queries/git-rebase/highlights.scm b/runtime/queries/git-rebase/highlights.scm new file mode 100644 index 00000000..4f007037 --- /dev/null +++ b/runtime/queries/git-rebase/highlights.scm @@ -0,0 +1,11 @@ +(operation operator: ["p" "pick" "r" "reword" "e" "edit" "s" "squash" "m" "merge" "d" "drop" "b" "break" "x" "exec"] @keyword) +(operation operator: ["l" "label" "t" "reset"] @function) +(operation operator: ["f" "fixup"] @function.special) + +(option) @operator +(label) @string.special.symbol +(commit) @constant +"#" @punctuation.delimiter +(comment) @comment + +(ERROR) @error diff --git a/runtime/queries/git-rebase/injections.scm b/runtime/queries/git-rebase/injections.scm new file mode 100644 index 00000000..070129b6 --- /dev/null +++ b/runtime/queries/git-rebase/injections.scm @@ -0,0 +1,4 @@ +((operation + operator: ["x" "exec"] + (command) @injection.content) + (#set! injection.language "bash")) -- cgit v1.2.3-70-g09d2 From 8a019b423f5d51bcfc107da9cb50aa90eacff19d Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Fri, 31 Dec 2021 09:06:54 +0100 Subject: Detect workspace root using language markers (#1370) * Detect workspace root using language markers * Avoid allocating root_markers * Update helix-core/src/lib.rs Co-authored-by: Blaž Hrastnik * Update helix-core/src/lib.rs Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com> Co-authored-by: Blaž Hrastnik Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>--- helix-core/src/lib.rs | 32 ++++++++++++++++++++++++++------ helix-lsp/src/client.rs | 6 +++++- helix-lsp/src/lib.rs | 1 + helix-term/src/commands.rs | 3 ++- languages.toml | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) (limited to 'languages.toml') diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index 1c78e7c0..7fd23b97 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -39,8 +39,14 @@ pub fn find_first_non_whitespace_char(line: RopeSlice) -> Option { line.chars().position(|ch| !ch.is_whitespace()) } -/// Find `.git` root. -pub fn find_root(root: Option<&str>) -> Option { +/// Find project root. +/// +/// Order of detection: +/// * Top-most folder containing a root marker in current git repository +/// * Git repostory root if no marker detected +/// * Top-most folder containing a root marker if not git repository detected +/// * Current working directory as fallback +pub fn find_root(root: Option<&str>, root_markers: &[String]) -> Option { let current_dir = std::env::current_dir().expect("unable to determine current directory"); let root = match root { @@ -52,16 +58,30 @@ pub fn find_root(root: Option<&str>) -> Option { current_dir.join(root) } } - None => current_dir, + None => current_dir.clone(), }; + let mut top_marker = None; for ancestor in root.ancestors() { - // TODO: also use defined roots if git isn't found + for marker in root_markers { + if ancestor.join(marker).exists() { + top_marker = Some(ancestor); + break; + } + } + // don't go higher than repo if ancestor.join(".git").is_dir() { - return Some(ancestor.to_path_buf()); + // Use workspace if detected from marker + return Some(top_marker.unwrap_or(ancestor).to_path_buf()); } } - None + + // In absence of git repo, use workspace if detected + if top_marker.is_some() { + top_marker.map(|a| a.to_path_buf()) + } else { + Some(current_dir) + } } pub fn runtime_dir() -> std::path::PathBuf { diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 43804daa..c80f70b5 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -31,6 +31,7 @@ pub struct Client { pub(crate) capabilities: OnceCell, offset_encoding: OffsetEncoding, config: Option, + root_markers: Vec, } impl Client { @@ -39,6 +40,7 @@ impl Client { cmd: &str, args: &[String], config: Option, + root_markers: Vec, id: usize, ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc)> { let process = Command::new(cmd) @@ -68,6 +70,7 @@ impl Client { capabilities: OnceCell::new(), offset_encoding: OffsetEncoding::Utf8, config, + root_markers, }; Ok((client, server_rx, initialize_notify)) @@ -225,7 +228,8 @@ impl Client { pub(crate) async fn initialize(&self) -> Result { // TODO: delay any requests that are triggered prior to initialize - let root = find_root(None).and_then(|root| lsp::Url::from_file_path(root).ok()); + let root = find_root(None, &self.root_markers) + .and_then(|root| lsp::Url::from_file_path(root).ok()); if self.config.is_some() { log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap()); diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 8fb321bc..1eb1c151 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -326,6 +326,7 @@ impl Registry { &config.command, &config.args, language_config.config.clone(), + language_config.roots.clone(), id, )?; self.incoming.push(UnboundedReceiverStream::new(incoming)); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6259ecb2..ed728115 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3154,7 +3154,8 @@ fn command_mode(cx: &mut Context) { } fn file_picker(cx: &mut Context) { - let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); + // We don't specify language markers, root will be the root of the current git repo + let root = find_root(None, &[]).unwrap_or_else(|| PathBuf::from("./")); let picker = ui::file_picker(root, &cx.editor.config); cx.push_layer(Box::new(picker)); } diff --git a/languages.toml b/languages.toml index 3d9bac7b..f088a3aa 100644 --- a/languages.toml +++ b/languages.toml @@ -3,7 +3,7 @@ name = "rust" scope = "source.rust" injection-regex = "rust" file-types = ["rs"] -roots = [] +roots = ["Cargo.toml", "Cargo.lock"] auto-format = true comment-token = "//" language-server = { command = "rust-analyzer" } -- cgit v1.2.3-70-g09d2 From 8f2af713408b8b40cf71873bbc0ddc009a7b3da5 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Mon, 3 Jan 2022 02:57:55 +0100 Subject: Add LLVM TableGen highlighting (#1409) Add a tree-sitter grammar and highlights for TableGen files. TableGen and its grammar are described here: https://llvm.org/docs/TableGen/index.html Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-tablegen | 1 + languages.toml | 9 +++ runtime/queries/tablegen/highlights.scm | 90 +++++++++++++++++++++++++++++ runtime/queries/tablegen/indents.toml | 7 +++ runtime/queries/tablegen/injections.scm | 2 + runtime/queries/tablegen/textobjects.scm | 7 +++ 8 files changed, 121 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-tablegen create mode 100644 runtime/queries/tablegen/highlights.scm create mode 100644 runtime/queries/tablegen/indents.toml create mode 100644 runtime/queries/tablegen/injections.scm create mode 100644 runtime/queries/tablegen/textobjects.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 22f70c80..b617e60c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -178,6 +178,10 @@ path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-tablegen"] + path = helix-syntax/languages/tree-sitter-tablegen + url = https://github.com/Flakebi/tree-sitter-tablegen + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-rebase"] path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 09284d46..73712ff2 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -40,6 +40,7 @@ | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | | svelte | ✓ | | ✓ | `svelteserver` | +| tablegen | ✓ | ✓ | ✓ | | | toml | ✓ | | | | | tsq | ✓ | | | | | tsx | ✓ | | | `typescript-language-server` | diff --git a/helix-syntax/languages/tree-sitter-tablegen b/helix-syntax/languages/tree-sitter-tablegen new file mode 160000 index 00000000..568dd8a9 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-tablegen @@ -0,0 +1 @@ +Subproject commit 568dd8a937347175fd58db83d4c4cdaeb6069bd2 diff --git a/languages.toml b/languages.toml index f088a3aa..7a895a60 100644 --- a/languages.toml +++ b/languages.toml @@ -436,6 +436,15 @@ file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +[[language]] +name = "tablegen" +scope = "source.tablegen" +roots = [] +file-types = ["td"] +comment-token = "//" +indent = { tab-width = 2, unit = " " } +injection-regex = "tablegen" + [[language]] name = "markdown" scope = "source.md" diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm new file mode 100644 index 00000000..8ade5ba9 --- /dev/null +++ b/runtime/queries/tablegen/highlights.scm @@ -0,0 +1,90 @@ +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "#" + "-" + "..." + ":" +] @operator + +[ + "=" + "!cond" + (operator_keyword) +] @function + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "?" +] @constant.builtin + +(var) @variable + +(template_arg (identifier) @variable.parameter) + +(_ argument: (value (identifier) @variable.parameter)) + +(type) @type + +"code" @type.builtin + +(number) @constant.numeric.integer +[ + (string_string) + (code_string) +] @string + +(preprocessor) @keyword.directive + +[ + "class" + "field" + "let" + "defvar" + "def" + "defset" + "defvar" + "assert" +] @keyword + +[ + "let" + "in" + "foreach" + "if" + "then" + "else" +] @keyword.operator + +"include" @keyword.control.import + +[ + "multiclass" + "defm" +] @namespace + +(ERROR) @error diff --git a/runtime/queries/tablegen/indents.toml b/runtime/queries/tablegen/indents.toml new file mode 100644 index 00000000..43532f4d --- /dev/null +++ b/runtime/queries/tablegen/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "statement", +] + +outdent = [ + "}", +] diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/tablegen/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tablegen/textobjects.scm b/runtime/queries/tablegen/textobjects.scm new file mode 100644 index 00000000..2cb80268 --- /dev/null +++ b/runtime/queries/tablegen/textobjects.scm @@ -0,0 +1,7 @@ +(class + body: (_) @class.inside) @class.around + +(multiclass + body: (_) @class.inside) @class.around + +(_ argument: _ @parameter.inside) -- cgit v1.2.3-70-g09d2 From 641255ccc83648d164bf6e8e8e4e93460591830b Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 4 Jan 2022 02:52:34 +0100 Subject: Add llvm-mir highlighting (#1398) * Add injection regex for more languages To support embedding them in other languages like markdown. * Add llvm-mir highlighting LLVM Machine IR is dumped as yaml files that can embed LLVM IR and Machine IR. To support this, add a llvm-mir-yaml language that uses the yaml parser, but uses different injections to highlight IR and MIR. * Update submodule with fixed multiline comments Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + book/src/generated/lang-support.md | 2 + helix-core/src/indent.rs | 1 + helix-core/src/syntax.rs | 13 ++- helix-syntax/languages/tree-sitter-llvm-mir | 1 + languages.toml | 22 +++++ runtime/queries/llvm-mir-yaml/highlights.scm | 1 + runtime/queries/llvm-mir-yaml/indents.toml | 3 + runtime/queries/llvm-mir-yaml/injections.scm | 9 ++ runtime/queries/llvm-mir/highlights.scm | 136 +++++++++++++++++++++++++++ runtime/queries/llvm-mir/indents.toml | 7 ++ runtime/queries/llvm-mir/injections.scm | 2 + runtime/queries/llvm-mir/textobjects.scm | 3 + runtime/queries/yaml/injections.scm | 2 + 14 files changed, 203 insertions(+), 3 deletions(-) create mode 160000 helix-syntax/languages/tree-sitter-llvm-mir create mode 100644 runtime/queries/llvm-mir-yaml/highlights.scm create mode 100644 runtime/queries/llvm-mir-yaml/indents.toml create mode 100644 runtime/queries/llvm-mir-yaml/injections.scm create mode 100644 runtime/queries/llvm-mir/highlights.scm create mode 100644 runtime/queries/llvm-mir/indents.toml create mode 100644 runtime/queries/llvm-mir/injections.scm create mode 100644 runtime/queries/llvm-mir/textobjects.scm create mode 100644 runtime/queries/yaml/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index b617e60c..9297708a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -174,6 +174,10 @@ path = helix-syntax/languages/tree-sitter-git-commit url = https://github.com/the-mikedavis/tree-sitter-git-commit.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-llvm-mir"] + path = helix-syntax/languages/tree-sitter-llvm-mir + url = https://github.com/Flakebi/tree-sitter-llvm-mir.git + shallow = true [submodule "helix-syntax/languages/tree-sitter-git-diff"] path = helix-syntax/languages/tree-sitter-git-diff url = https://github.com/the-mikedavis/tree-sitter-git-diff.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 73712ff2..ee719b56 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -24,6 +24,8 @@ | latex | ✓ | | | | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | +| llvm-mir | ✓ | ✓ | ✓ | | +| llvm-mir-yaml | ✓ | | ✓ | | | lua | ✓ | | ✓ | | | markdown | ✓ | | | | | mint | | | | `mint` | diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 28066aa6..1fc2b8a5 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -436,6 +436,7 @@ where comment_token: None, auto_format: false, diagnostic_severity: Severity::Warning, + tree_sitter_library: None, language_server: None, indent: Some(IndentationConfiguration { tab_width: 4, diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index cdae0210..5d37c219 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -67,6 +67,8 @@ pub struct LanguageConfiguration { #[serde(default)] pub diagnostic_severity: Severity, + pub tree_sitter_library: Option, // tree-sitter library name, defaults to language_id + // content_regex #[serde(default, skip_serializing, deserialize_with = "deserialize_regex")] pub injection_regex: Option, @@ -192,9 +194,14 @@ impl LanguageConfiguration { if highlights_query.is_empty() { None } else { - let language = get_language(&crate::RUNTIME_DIR, &self.language_id) - .map_err(|e| log::info!("{}", e)) - .ok()?; + let language = get_language( + &crate::RUNTIME_DIR, + self.tree_sitter_library + .as_deref() + .unwrap_or(&self.language_id), + ) + .map_err(|e| log::info!("{}", e)) + .ok()?; let config = HighlightConfiguration::new( language, &highlights_query, diff --git a/helix-syntax/languages/tree-sitter-llvm-mir b/helix-syntax/languages/tree-sitter-llvm-mir new file mode 160000 index 00000000..06fabca1 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-llvm-mir @@ -0,0 +1 @@ +Subproject commit 06fabca19454b2dc00c1b211a7cb7ad0bc2585f1 diff --git a/languages.toml b/languages.toml index 7a895a60..e8329fe7 100644 --- a/languages.toml +++ b/languages.toml @@ -334,6 +334,7 @@ file-types = ["yml", "yaml"] roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } +injection-regex = "yml|yaml" # [[language]] # name = "haskell" @@ -386,6 +387,7 @@ roots = [] comment-token = "#" indent = { tab-width = 2, unit = " " } language-server = { command = "cmake-language-server" } +injection-regex = "cmake" [[language]] name = "glsl" @@ -394,6 +396,7 @@ file-types = ["glsl", "vert", "tesc", "tese", "geom", "frag", "comp" ] roots = [] comment-token = "//" indent = { tab-width = 4, unit = " " } +injection-regex = "glsl" [[language]] name = "perl" @@ -435,6 +438,25 @@ roots = [] file-types = ["ll"] comment-token = ";" indent = { tab-width = 2, unit = " " } +injection-regex = "llvm" + +[[language]] +name = "llvm-mir" +scope = "source.llvm_mir" +roots = [] +file-types = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } +injection-regex = "mir" + +[[language]] +name = "llvm-mir-yaml" +tree-sitter-library = "yaml" +scope = "source.yaml" +roots = [] +file-types = ["mir"] +comment-token = "#" +indent = { tab-width = 2, unit = " " } [[language]] name = "tablegen" diff --git a/runtime/queries/llvm-mir-yaml/highlights.scm b/runtime/queries/llvm-mir-yaml/highlights.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/highlights.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/llvm-mir-yaml/indents.toml b/runtime/queries/llvm-mir-yaml/indents.toml new file mode 100644 index 00000000..ddc3578b --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/indents.toml @@ -0,0 +1,3 @@ +indent = [ + "block_mapping_pair", +] diff --git a/runtime/queries/llvm-mir-yaml/injections.scm b/runtime/queries/llvm-mir-yaml/injections.scm new file mode 100644 index 00000000..b3243022 --- /dev/null +++ b/runtime/queries/llvm-mir-yaml/injections.scm @@ -0,0 +1,9 @@ +; inherits: yaml + +((document (block_node (block_scalar) @injection.content)) + (#set! injection.language "llvm")) + +((document (block_node (block_mapping (block_mapping_pair + key: (flow_node (plain_scalar (string_scalar))) ; "body" + value: (block_node (block_scalar) @injection.content))))) + (#set! injection.language "mir")) diff --git a/runtime/queries/llvm-mir/highlights.scm b/runtime/queries/llvm-mir/highlights.scm new file mode 100644 index 00000000..79234612 --- /dev/null +++ b/runtime/queries/llvm-mir/highlights.scm @@ -0,0 +1,136 @@ +[ + (label) + (bb_ref) +] @label + +[ + (comment) + (multiline_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + "," + ":" + "|" + "*" +] @punctuation.delimiter + +[ + "=" + "x" +] @operator + +[ + "true" + "false" +] @constant.builtin.boolean + +[ + "null" + "_" + "unknown-address" +] @constant.builtin + +[ + (stack_object) + (constant_pool_index) + (jump_table_index) + (var) + (physical_register) + (ir_block) + (external_symbol) + (global_var) + (ir_local_var) + (metadata_ref) + (mnemonic) +] @variable + +(low_level_type) @type + +[ + (immediate_type) + (primitive_type) +] @type.builtin + +(number) @constant.numeric.integer +(float) @constant.numeric.float +(string) @string + +(instruction name: _ @keyword.operator) + +[ + "successors" + "liveins" + "pre-instr-symbol" + "post-instr-symbol" + "heap-alloc-marker" + "debug-instr-number" + "debug-location" + "mcsymbol" + "tied-def" + "target-flags" + "CustomRegMask" + "same_value" + "def_cfa_register" + "restore" + "undefined" + "offset" + "rel_offset" + "def_cfa" + "llvm_def_aspace_cfa" + "register" + "escape" + "remember_state" + "restore_state" + "window_save" + "negate_ra_sign_state" + "intpred" + "floatpred" + "shufflemask" + "liveout" + "target-index" + "blockaddress" + "intrinsic" + "load" + "store" + "unknown-size" + "on" + "from" + "into" + "align" + "basealign" + "addrspace" + "call-entry" + "custom" + "constant-pool" + "stack" + "got" + "jump-table" + "syncscope" + "address-taken" + "landing-pad" + "inlineasm-br-indirect-target" + "ehfunclet-entry" + "bbsections" + + (intpred) + (floatpred) + (memory_operand_flag) + (atomic_ordering) + (register_flag) + (instruction_flag) + (float_keyword) +] @keyword + +(ERROR) @error diff --git a/runtime/queries/llvm-mir/indents.toml b/runtime/queries/llvm-mir/indents.toml new file mode 100644 index 00000000..6a70e5ad --- /dev/null +++ b/runtime/queries/llvm-mir/indents.toml @@ -0,0 +1,7 @@ +indent = [ + "basic_block", +] + +outdent = [ + "label", +] diff --git a/runtime/queries/llvm-mir/injections.scm b/runtime/queries/llvm-mir/injections.scm new file mode 100644 index 00000000..0b476f86 --- /dev/null +++ b/runtime/queries/llvm-mir/injections.scm @@ -0,0 +1,2 @@ +([ (comment) (multiline_comment)] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/llvm-mir/textobjects.scm b/runtime/queries/llvm-mir/textobjects.scm new file mode 100644 index 00000000..73f6f772 --- /dev/null +++ b/runtime/queries/llvm-mir/textobjects.scm @@ -0,0 +1,3 @@ +(basic_block) @function.around + +(argument) @parameter.inside diff --git a/runtime/queries/yaml/injections.scm b/runtime/queries/yaml/injections.scm new file mode 100644 index 00000000..39bda293 --- /dev/null +++ b/runtime/queries/yaml/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From a8fd33ac012a79069ef1409503a2edcf3a585153 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 6 Jan 2022 09:00:00 -0600 Subject: add tree-sitter-regex (#1362) * add tree-sitter-regex * adapt regex highlights from upstream * inject regex into elixir sigil_r/2 and sigil_R/2 * generate lang-support docs * capture interesting nodes in character-ranges * make $.character_class captures more consistent * fix fallthrough behavior for character classes * capture pattern characters as 'string' * use latest tree-sitter-regex * set elixir regex injections as combined * add link to upstream queries * inject regex in rust into 'Regex::new' raw string literals--- .gitmodules | 4 +++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-regex | 1 + languages.toml | 7 +++++ runtime/queries/elixir/injections.scm | 7 +++++ runtime/queries/regex/highlights.scm | 53 ++++++++++++++++++++++++++++++++ runtime/queries/rust/injections.scm | 14 +++++++++ 7 files changed, 87 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-regex create mode 100644 runtime/queries/regex/highlights.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 9297708a..f6a0fdc4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -190,3 +190,7 @@ path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-regex"] + path = helix-syntax/languages/tree-sitter-regex + url = https://github.com/tree-sitter/tree-sitter-regex.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a1fbf172..daf8b006 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -38,6 +38,7 @@ | protobuf | ✓ | | ✓ | | | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | +| regex | ✓ | | | | | ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | diff --git a/helix-syntax/languages/tree-sitter-regex b/helix-syntax/languages/tree-sitter-regex new file mode 160000 index 00000000..e1cfca3c --- /dev/null +++ b/helix-syntax/languages/tree-sitter-regex @@ -0,0 +1 @@ +Subproject commit e1cfca3c79896ff79842f057ea13e529b66af636 diff --git a/languages.toml b/languages.toml index e8329fe7..3e2e7b15 100644 --- a/languages.toml +++ b/languages.toml @@ -530,3 +530,10 @@ file-types = ["git-rebase-todo"] injection-regex = "git-rebase" comment-token = "#" indent = { tab-width = 2, unit = " " } + +[[language]] +name = "regex" +scope = "source.regex" +injection-regex = "regex" +file-types = ["regex"] +roots = [] diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm index 321c90ad..8370a0d8 100644 --- a/runtime/queries/elixir/injections.scm +++ b/runtime/queries/elixir/injections.scm @@ -1,2 +1,9 @@ ((comment) @injection.content (#set! injection.language "comment")) + +((sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content) + (#match? @_sigil_name "^(r|R)$") + (#set! injection.language "regex") + (#set! injection.combined)) diff --git a/runtime/queries/regex/highlights.scm b/runtime/queries/regex/highlights.scm new file mode 100644 index 00000000..9376caa9 --- /dev/null +++ b/runtime/queries/regex/highlights.scm @@ -0,0 +1,53 @@ +; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm + +[ + "(" + ")" + "(?" + "(?:" + "(?<" + ">" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "+" + "|" + "=" + "<=" + "!" + ", + pub language_id: Option, } #[derive(Debug, Serialize, Deserialize)] diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c7202feb..c376aefa 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -358,12 +358,8 @@ impl Application { // trigger textDocument/didOpen for docs that are already open for doc in docs { - // TODO: extract and share with editor.open - let language_id = doc - .language() - .and_then(|s| s.split('.').last()) // source.rust - .map(ToOwned::to_owned) - .unwrap_or_default(); + let language_id = + doc.language_id().map(ToOwned::to_owned).unwrap_or_default(); tokio::spawn(language_server.text_document_did_open( doc.url().unwrap(), diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 9652d7b3..579349ee 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -844,6 +844,24 @@ impl Document { .map(|language| language.scope.as_str()) } + /// Language ID for the document. Either the `language-id` from the + /// `language-server` configuration, or the document language if no + /// `language-id` has been specified. + pub fn language_id(&self) -> Option<&str> { + self.language + .as_ref() + .and_then(|config| config.language_server.as_ref()) + .and_then(|lsp_config| lsp_config.language_id.as_ref()) + .map_or_else( + || { + self.language() + .and_then(|s| s.rsplit_once('.')) + .map(|(_, language_id)| language_id) + }, + |language_id| Some(language_id.as_str()), + ) + } + /// Corresponding [`LanguageConfiguration`]. pub fn language_config(&self) -> Option<&LanguageConfiguration> { self.language.as_deref() diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index f4b0f73e..7406b475 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -307,11 +307,8 @@ impl Editor { if let Some(language_server) = doc.language_server() { tokio::spawn(language_server.text_document_did_close(doc.identifier())); } - let language_id = doc - .language() - .and_then(|s| s.split('.').last()) // source.rust - .map(ToOwned::to_owned) - .unwrap_or_default(); + + let language_id = doc.language_id().map(ToOwned::to_owned).unwrap_or_default(); // TODO: this now races with on_init code if the init happens too quickly tokio::spawn(language_server.text_document_did_open( diff --git a/languages.toml b/languages.toml index 2c870ab2..78447578 100644 --- a/languages.toml +++ b/languages.toml @@ -128,7 +128,7 @@ roots = [] comment-token = "//" # TODO: highlights-jsx, highlights-params -language-server = { command = "typescript-language-server", args = ["--stdio"] } +language-server = { command = "typescript-language-server", args = ["--stdio"], language-id = "javascript" } indent = { tab-width = 2, unit = " " } [[language]] @@ -140,7 +140,7 @@ shebangs = [] roots = [] # TODO: highlights-jsx, highlights-params -language-server = { command = "typescript-language-server", args = ["--stdio"] } +language-server = { command = "typescript-language-server", args = ["--stdio"], language-id = "typescript"} indent = { tab-width = 2, unit = " " } [[language]] @@ -151,7 +151,7 @@ file-types = ["tsx"] roots = [] # TODO: highlights-jsx, highlights-params -language-server = { command = "typescript-language-server", args = ["--stdio"] } +language-server = { command = "typescript-language-server", args = ["--stdio"], language-id = "typescriptreact" } indent = { tab-width = 2, unit = " " } [[language]] -- cgit v1.2.3-70-g09d2 From a7b0cc730c9d18d214ef194ff0cb5d2ccfa8b762 Mon Sep 17 00:00:00 2001 From: Kirawi Date: Sat, 15 Jan 2022 20:11:31 -0500 Subject: Re-enable haskell in languages.toml (#1520) --- book/src/generated/lang-support.md | 1 + languages.toml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'languages.toml') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 8b599f6b..87347819 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -17,6 +17,7 @@ | git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | +| haskell | ✓ | | | | | html | ✓ | | | | | java | ✓ | | | | | javascript | ✓ | | ✓ | `typescript-language-server` | diff --git a/languages.toml b/languages.toml index 78447578..e9d5af0e 100644 --- a/languages.toml +++ b/languages.toml @@ -337,15 +337,15 @@ comment-token = "#" indent = { tab-width = 2, unit = " " } injection-regex = "yml|yaml" -# [[language]] -# name = "haskell" -# scope = "source.haskell" -# injection-regex = "haskell" -# file-types = ["hs"] -# roots = [] -# comment-token = "--" -# -# indent = { tab-width = 2, unit = " " } +[[language]] +name = "haskell" +scope = "source.haskell" +injection-regex = "haskell" +file-types = ["hs"] +roots = [] +comment-token = "--" + +indent = { tab-width = 2, unit = " " } [[language]] name = "zig" -- cgit v1.2.3-70-g09d2 From 64d3e7b705341fef8af7f6cb5bbff5848489abd6 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 15 Jan 2022 19:26:09 -0600 Subject: add show_subtree command for viewing tree-sitter subtree in Popup (#1453) * add show_subtree command for viewing tree-sitter subtree in Popup * remove '.slice(..)' from show_subtree command * name docs and subtree Popups 'hover'--- helix-term/src/commands.rs | 35 +++++++++++++++++++++++++++++++++-- languages.toml | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'languages.toml') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 71ac8f09..1a53f14e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -400,6 +400,7 @@ impl MappableCommand { decrement, "Decrement", record_macro, "Record macro", replay_macro, "Replay macro", + show_subtree, "Show tree-sitter subtree under primary selection", ); } @@ -5388,8 +5389,8 @@ fn hover(cx: &mut Context) { // skip if contents empty let contents = ui::Markdown::new(contents, editor.syn_loader.clone()); - let popup = Popup::new("documentation", contents); - if let Some(doc_popup) = compositor.find_id("documentation") { + let popup = Popup::new("hover", contents); + if let Some(doc_popup) = compositor.find_id("hover") { *doc_popup = popup; } else { compositor.push(Box::new(popup)); @@ -6210,3 +6211,33 @@ fn replay_macro(cx: &mut Context) { }, )); } + +fn show_subtree(cx: &mut Context) { + let (view, doc) = current!(cx.editor); + + if let Some(syntax) = doc.syntax() { + let primary_selection = doc.selection(view.id).primary(); + let text = doc.text(); + let from = text.char_to_byte(primary_selection.from()); + let to = text.char_to_byte(primary_selection.to()); + if let Some(selected_node) = syntax + .tree() + .root_node() + .descendant_for_byte_range(from, to) + { + let contents = format!("```tsq\n{}\n```", selected_node.to_sexp()); + + cx.callback = Some(Box::new( + move |compositor: &mut Compositor, cx: &mut compositor::Context| { + let contents = ui::Markdown::new(contents, cx.editor.syn_loader.clone()); + let popup = Popup::new("hover", contents); + if let Some(doc_popup) = compositor.find_id("hover") { + *doc_popup = popup; + } else { + compositor.push(Box::new(popup)); + } + }, + )); + } + } +} diff --git a/languages.toml b/languages.toml index e9d5af0e..af15c654 100644 --- a/languages.toml +++ b/languages.toml @@ -378,6 +378,7 @@ scope = "source.tsq" file-types = ["scm"] roots = [] comment-token = ";" +injection-regex = "tsq" indent = { tab-width = 2, unit = " " } [[language]] -- cgit v1.2.3-70-g09d2 From 8ea5742b0899992cd7453c70a8a06cb76a703fdf Mon Sep 17 00:00:00 2001 From: Anders Christiansen Sørby Date: Mon, 17 Jan 2022 15:05:17 +0100 Subject: feat(languages): Lean experimental tree-sitter-lean (#1422) * Add experimental tree-sitter-lean * Run docgen * Copy over the queries from lean.nvim * Update .gitmodules Co-authored-by: Ivan Tham * Update lean highlights and run docgen * Update runtime/queries/lean/injections.scm Co-authored-by: Michael Davis * Lean: Move variable matcher to bottom * Update runtime/queries/lean/locals.scm Co-authored-by: Michael Davis Co-authored-by: Ivan Tham Co-authored-by: Michael Davis --- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-lean | 1 + languages.toml | 11 ++ runtime/queries/lean/folds.scm | 15 +++ runtime/queries/lean/highlights.scm | 217 ++++++++++++++++++++++++++++++++ runtime/queries/lean/injections.scm | 2 + runtime/queries/lean/locals.scm | 5 + 8 files changed, 256 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-lean create mode 100644 runtime/queries/lean/folds.scm create mode 100644 runtime/queries/lean/highlights.scm create mode 100644 runtime/queries/lean/injections.scm create mode 100644 runtime/queries/lean/locals.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 3442652a..1ccbe43b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -190,6 +190,10 @@ path = helix-syntax/languages/tree-sitter-git-rebase url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-lean"] + path = helix-syntax/languages/tree-sitter-lean + url = https://github.com/Julian/tree-sitter-lean + shallow = true [submodule "helix-syntax/languages/tree-sitter-regex"] path = helix-syntax/languages/tree-sitter-regex url = https://github.com/tree-sitter/tree-sitter-regex.git diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 87347819..fce14846 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -24,6 +24,7 @@ | json | ✓ | | ✓ | | | julia | ✓ | | | `julia` | | latex | ✓ | | | | +| lean | ✓ | | | `lean` | | ledger | ✓ | | | | | llvm | ✓ | ✓ | ✓ | | | llvm-mir | ✓ | ✓ | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-lean b/helix-syntax/languages/tree-sitter-lean new file mode 160000 index 00000000..d9842610 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-lean @@ -0,0 +1 @@ +Subproject commit d98426109258b266e1e92358c5f11716d2e8f638 diff --git a/languages.toml b/languages.toml index af15c654..2896dd32 100644 --- a/languages.toml +++ b/languages.toml @@ -241,6 +241,17 @@ comment-token = "%" indent = { tab-width = 4, unit = "\t" } +[[language]] +name = "lean" +scope = "source.lean" +injection-regex = "lean" +file-types = ["lean"] +roots = [ "lakefile.lean" ] +comment-token = "--" +language-server = { command = "lean", args = [ "--server" ] } + +indent = { tab-width = 2, unit = " " } + [[language]] name = "julia" scope = "source.julia" diff --git a/runtime/queries/lean/folds.scm b/runtime/queries/lean/folds.scm new file mode 100644 index 00000000..2c2bbb33 --- /dev/null +++ b/runtime/queries/lean/folds.scm @@ -0,0 +1,15 @@ +[ + (namespace) + (section) + + (instance) + (def) + (theorem) + (example) + + (product) + (array) + (list) + + (string) +] @fold diff --git a/runtime/queries/lean/highlights.scm b/runtime/queries/lean/highlights.scm new file mode 100644 index 00000000..a64feb1d --- /dev/null +++ b/runtime/queries/lean/highlights.scm @@ -0,0 +1,217 @@ +(open + namespace: (identifier) @namespace) +(namespace + name: (identifier) @namespace) +(section + name: (identifier) @namespace) + +;; Identifier naming conventions +((identifier) @type + (#match? @type "^[A-Z]")) + +(arrow) @type +(product) @type + +;; Declarations + +[ + "abbrev" + "def" + "theorem" + "constant" + "instance" + "axiom" + "example" + "inductive" + "structure" + "class" + + "deriving" + + "section" + "namespace" +] @keyword + +(attributes + (identifier) @function) + +(abbrev + name: (identifier) @type) +(def + name: (identifier) @function) +(theorem + name: (identifier) @function) +(constant + name: (identifier) @type) +(instance + name: (identifier) @function) +(instance + type: (identifier) @type) +(axiom + name: (identifier) @function) +(structure + name: (identifier) @type) +(structure + extends: (identifier) @type) + +(where_decl + type: (identifier) @type) + +(proj + name: (identifier) @field) + +(binders + type: (identifier) @type) + +["if" "then" "else"] @keyword.control.conditional + +["for" "in" "do"] @keyword.control.repeat + +(import) @include + +; Tokens + +[ + "!" + "$" + "%" + "&&" + "*" + "*>" + "+" + "++" + "-" + "/" + "::" + ":=" + "<" + "<$>" + "<*" + "<*>" + "<=" + "<|" + "<|>" + "=" + "==" + "=>" + ">" + ">" + ">=" + ">>" + ">>=" + "@" + "^" + "|>" + "|>." + "||" + "←" + "→" + "↔" + "∘" + "∧" + "∨" + "≠" + "≤" + "≥" +] @operator + +[ + "@&" +] @operator + +[ + "attribute" + "by" + "end" + "export" + "extends" + "fun" + "let" + "have" + "match" + "open" + "return" + "universe" + "variable" + "where" + "with" + "λ" + (hash_command) + (prelude) + (sorry) +] @keyword + +[ + "prefix" + "infix" + "infixl" + "infixr" + "postfix" + "notation" + "macro_rules" + "syntax" + "elab" + "builtin_initialize" +] @keyword + +[ + "noncomputable" + "partial" + "private" + "protected" + "unsafe" +] @keyword + +[ + "apply" + "exact" + "rewrite" + "rw" + "simp" + (trivial) +] @keyword + +[ + "catch" + "finally" + "try" +] @exception + +((apply + name: (identifier) @exception) + (#match? @exception "throw")) + +[ + "unless" + "mut" +] @keyword + +[(true) (false)] @boolean + +(number) @constant.numeric.integer +(float) @constant.numeric.float + +(comment) @comment +(char) @character +(string) @string +(interpolated_string) @string +; (escape_sequence) @string.escape + +; Reset highlighing in string interpolation +(interpolation) @none + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +["(" ")" "[" "]" "{" "}" "⟨" "⟩"] @punctuation.bracket + +["|" "," "." ":" ";"] @punctuation.delimiter + +(sorry) @error + +;; Error +(ERROR) @error + +; Variables +(identifier) @variable diff --git a/runtime/queries/lean/injections.scm b/runtime/queries/lean/injections.scm new file mode 100644 index 00000000..030714f1 --- /dev/null +++ b/runtime/queries/lean/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "markdown")) diff --git a/runtime/queries/lean/locals.scm b/runtime/queries/lean/locals.scm new file mode 100644 index 00000000..dd6c2036 --- /dev/null +++ b/runtime/queries/lean/locals.scm @@ -0,0 +1,5 @@ +[ + (module) + (namespace) + (section) +] @local.scope -- cgit v1.2.3-70-g09d2 From b2c8aa1ee709edcd5302b27f6d6467b7b624ca84 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Thu, 20 Jan 2022 07:47:23 -0800 Subject: feat(languages): Elm (#1514) * Add Elm language support * Fix docs gen * Updates based on PR feedback--- .gitmodules | 4 ++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-elm | 1 + languages.toml | 11 +++++ runtime/queries/elm/highlights.scm | 83 ++++++++++++++++++++++++++++++++++ runtime/queries/elm/injections.scm | 4 ++ runtime/queries/elm/locals.scm | 14 ++++++ runtime/queries/elm/tags.scm | 19 ++++++++ 8 files changed, 137 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-elm create mode 100644 runtime/queries/elm/highlights.scm create mode 100644 runtime/queries/elm/injections.scm create mode 100644 runtime/queries/elm/locals.scm create mode 100644 runtime/queries/elm/tags.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 1ccbe43b..118fa2d8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -206,3 +206,7 @@ path = helix-syntax/languages/tree-sitter-git-config url = https://github.com/the-mikedavis/tree-sitter-git-config.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-elm"] + path = helix-syntax/languages/tree-sitter-elm + url = https://github.com/elm-tooling/tree-sitter-elm + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index fce14846..bfaac97b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -10,6 +10,7 @@ | dart | ✓ | | ✓ | `dart` | | dockerfile | ✓ | | | `docker-langserver` | | elixir | ✓ | | | `elixir-ls` | +| elm | ✓ | | | `elm-language-server` | | fish | ✓ | ✓ | ✓ | | | git-commit | ✓ | | | | | git-config | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-elm b/helix-syntax/languages/tree-sitter-elm new file mode 160000 index 00000000..bd50ccf6 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-elm @@ -0,0 +1 @@ +Subproject commit bd50ccf66b42c55252ac8efc1086af4ac6bab8cd diff --git a/languages.toml b/languages.toml index 2896dd32..ea93df3a 100644 --- a/languages.toml +++ b/languages.toml @@ -567,3 +567,14 @@ file-types = [".gitmodules", ".gitconfig"] injection-regex = "git-config" comment-token = "#" indent = { tab-width = 4, unit = "\t" } + +[[language]] +name = "elm" +scope = "source.elm" +injection-regex = "elm" +file-types = ["elm"] +roots = ["elm.json"] +auto-format = true +comment-token = "--" +language-server = { command = "elm-language-server" } +indent = { tab-width = 4, unit = " " } diff --git a/runtime/queries/elm/highlights.scm b/runtime/queries/elm/highlights.scm new file mode 100644 index 00000000..3c8fd12d --- /dev/null +++ b/runtime/queries/elm/highlights.scm @@ -0,0 +1,83 @@ +; Keywords +[ + "if" + "then" + "else" + "let" + "in" + ] @keyword.control +(case) @keyword.control +(of) @keyword.control + +(colon) @keyword.operator +(backslash) @keyword +(as) @keyword +(port) @keyword +(exposing) @keyword +(alias) @keyword +(infix) @keyword + +(arrow) @keyword.operator +(dot) @keyword.operator + +(port) @keyword + +(type_annotation(lower_case_identifier) @function) +(port_annotation(lower_case_identifier) @function) +(file (value_declaration (function_declaration_left(lower_case_identifier) @function))) + +(field name: (lower_case_identifier) @attribute) +(field_access_expr(lower_case_identifier) @attribute) + +(operator_identifier) @keyword.operator +(eq) @keyword.operator.assignment + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"|" @keyword +"," @punctuation.delimiter + +[ + "|>" +] @keyword + + +(import) @keyword.contol.import +(module) @keyword.other + +(number_constant_expr) @constant.numeric + +(type) @type + +(type_declaration(upper_case_identifier) @type) +(type_ref) @type +(type_alias_declaration name: (upper_case_identifier) @type) + +(union_pattern constructor: (upper_case_qid (upper_case_identifier) @label (dot) (upper_case_identifier) @variable.other.member)) +(union_pattern constructor: (upper_case_qid (upper_case_identifier) @variable.other.member)) + +(union_variant(upper_case_identifier) @variable.other.member) +(value_expr name: (value_qid (upper_case_identifier) @label)) +(value_expr (upper_case_qid (upper_case_identifier) @label (dot) (upper_case_identifier) @variable.other.member)) +(value_expr(upper_case_qid(upper_case_identifier)) @variable.other.member) + +; comments +(line_comment) @comment +(block_comment) @comment + +; strings +(string_escape) @constant.character.escape + +(open_quote) @string +(close_quote) @string +(regular_string_part) @string + +(open_char) @constant.character +(close_char) @constant.character diff --git a/runtime/queries/elm/injections.scm b/runtime/queries/elm/injections.scm new file mode 100644 index 00000000..83f8245c --- /dev/null +++ b/runtime/queries/elm/injections.scm @@ -0,0 +1,4 @@ +; Parse glsl where defined + +((glsl_content) @injection.content + (#set! injection.language "glsl")) diff --git a/runtime/queries/elm/locals.scm b/runtime/queries/elm/locals.scm new file mode 100644 index 00000000..ab103115 --- /dev/null +++ b/runtime/queries/elm/locals.scm @@ -0,0 +1,14 @@ +(value_declaration) @local.scope +(type_alias_declaration) @local.scope +(type_declaration) @local.scope +(type_annotation) @local.scope +(port_annotation) @local.scope +(infix_declaration) @local.scope +(let_in_expr) @local.scope + +(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition) +(function_declaration_left (lower_case_identifier) @local.definition) + +(value_expr(value_qid(upper_case_identifier)) @local.reference) +(value_expr(value_qid(lower_case_identifier)) @local.reference) +(type_ref (upper_case_qid) @local.reference) diff --git a/runtime/queries/elm/tags.scm b/runtime/queries/elm/tags.scm new file mode 100644 index 00000000..03999fb1 --- /dev/null +++ b/runtime/queries/elm/tags.scm @@ -0,0 +1,19 @@ +(value_declaration (function_declaration_left (lower_case_identifier) @name)) @definition.function + +(function_call_expr (value_expr (value_qid) @name)) @reference.function +(exposed_value (lower_case_identifier) @name) @reference.function +(type_annotation ((lower_case_identifier) @name) (colon)) @reference.function + +(type_declaration ((upper_case_identifier) @name) ) @definition.type + +(type_ref (upper_case_qid (upper_case_identifier) @name)) @reference.type +(exposed_type (upper_case_identifier) @name) @reference.type + +(type_declaration (union_variant (upper_case_identifier) @name)) @definition.union + +(value_expr (upper_case_qid (upper_case_identifier) @name)) @reference.union + + +(module_declaration + (upper_case_qid (upper_case_identifier)) @name +) @definition.module -- cgit v1.2.3-70-g09d2 From 0b55b21f3069640d37d2fa34bd413986177c0cd7 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Fri, 21 Jan 2022 06:16:40 -0800 Subject: feat(languages): GraphQL (#1515) * Add Graphql language support * Fix docs gen * Add JS Graphql injection query * Updates based on PR feedback Co-authored-by: Blaž Hrastnik --- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-graphql | 1 + languages.toml | 8 ++ runtime/queries/graphql/highlights.scm | 163 +++++++++++++++++++++++++++++ runtime/queries/javascript/injections.scm | 8 ++ 6 files changed, 185 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-graphql create mode 100644 runtime/queries/graphql/highlights.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 118fa2d8..780d1b63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -206,6 +206,10 @@ path = helix-syntax/languages/tree-sitter-git-config url = https://github.com/the-mikedavis/tree-sitter-git-config.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-graphql"] + path = helix-syntax/languages/tree-sitter-graphql + url = https://github.com/bkegley/tree-sitter-graphql + shallow = true [submodule "helix-syntax/languages/tree-sitter-elm"] path = helix-syntax/languages/tree-sitter-elm url = https://github.com/elm-tooling/tree-sitter-elm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index bfaac97b..fa8aa3ef 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -18,6 +18,7 @@ | git-rebase | ✓ | | | | | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | +| graphql | ✓ | | | | | haskell | ✓ | | | | | html | ✓ | | | | | java | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-graphql b/helix-syntax/languages/tree-sitter-graphql new file mode 160000 index 00000000..5e66e961 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-graphql @@ -0,0 +1 @@ +Subproject commit 5e66e961eee421786bdda8495ed1db045e06b5fe diff --git a/languages.toml b/languages.toml index ea93df3a..f9362eac 100644 --- a/languages.toml +++ b/languages.toml @@ -568,6 +568,14 @@ injection-regex = "git-config" comment-token = "#" indent = { tab-width = 4, unit = "\t" } +[[language]] +name = "graphql" +scope = "source.graphql" +injection-regex = "graphql" +file-types = ["gql", "graphql"] +roots = [] +indent = { tab-width = 2, unit = " " } + [[language]] name = "elm" scope = "source.elm" diff --git a/runtime/queries/graphql/highlights.scm b/runtime/queries/graphql/highlights.scm new file mode 100644 index 00000000..9fab4051 --- /dev/null +++ b/runtime/queries/graphql/highlights.scm @@ -0,0 +1,163 @@ +; Types +;------ + +(scalar_type_definition + (name) @type) + +(object_type_definition + (name) @type) + +(interface_type_definition + (name) @type) + +(union_type_definition + (name) @type) + +(enum_type_definition + (name) @type) + +(input_object_type_definition + (name) @type) + +(directive_definition + (name) @type) + +(directive_definition + "@" @type) + +(scalar_type_extension + (name) @type) + +(object_type_extension + (name) @type) + +(interface_type_extension + (name) @type) + +(union_type_extension + (name) @type) + +(enum_type_extension + (name) @type) + +(input_object_type_extension + (name) @type) + +(named_type + (name) @type) + +(directive) @type + +; Properties +;----------- + +(field + (name) @variable.other.member) + +(field + (alias + (name) @variable.other.member)) + +(field_definition + (name) @variable.other.member) + +(object_value + (object_field + (name) @variable.other.member)) + +(enum_value + (name) @variable.other.member) + +; Variable Definitions and Arguments +;----------------------------------- + +(operation_definition + (name) @variable) + +(fragment_name + (name) @variable) + +(input_fields_definition + (input_value_definition + (name) @variable.parameter)) + +(argument + (name) @variable.parameter) + +(arguments_definition + (input_value_definition + (name) @variable.parameter)) + +(variable_definition + (variable) @variable.parameter) + +(argument + (value + (variable) @variable)) + +; Constants +;---------- + +(string_value) @string + +(int_value) @constants.numeric.integer + +(float_value) @constants.numeric.float + +(boolean_value) @constants.builtin.boolean + +; Literals +;--------- + +(description) @comment + +(comment) @comment + +(directive_location + (executable_directive_location) @type.builtin) + +(directive_location + (type_system_directive_location) @type.builtin) + +; Keywords +;---------- + +[ + "query" + "mutation" + "subscription" + "fragment" + "scalar" + "type" + "interface" + "union" + "enum" + "input" + "extend" + "directive" + "schema" + "on" + "repeatable" + "implements" +] @keyword + +; Punctuation +;------------ + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +"|" @punctuation.delimiter +"&" @punctuation.delimiter +":" @punctuation.delimiter + +"..." @punctuation.special +"!" @punctuation.special diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm index 5539241a..e8429111 100644 --- a/runtime/queries/javascript/injections.scm +++ b/runtime/queries/javascript/injections.scm @@ -9,6 +9,14 @@ ] arguments: (template_string) @injection.content) +; Parse the contents of gql template literals + +((call_expression + function: (identifier) @_template_function_name + arguments: (template_string) @injection.content) + (#eq? @_template_function_name "gql") + (#set! injection.language "graphql")) + ; Parse regex syntax within regex literals ((regex_pattern) @injection.content -- cgit v1.2.3-70-g09d2 From a8e69e12f414b77824af9db4b0631f83d665effd Mon Sep 17 00:00:00 2001 From: Kyra Date: Sun, 23 Jan 2022 01:22:31 -0600 Subject: Add haskell-language-server-wrapper --lsp to default `languages.toml` (#1556) After the changes to upgrade and reenable tree-sitter-haskell #1417 for the purpose of enabling Haskell syntax highlighting #1384, we might as well take the final step.--- book/src/generated/lang-support.md | 2 +- languages.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'languages.toml') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index fa8aa3ef..e4070117 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -19,7 +19,7 @@ | glsl | ✓ | | ✓ | | | go | ✓ | ✓ | ✓ | `gopls` | | graphql | ✓ | | | | -| haskell | ✓ | | | | +| haskell | ✓ | | | `haskell-language-server-wrapper` | | html | ✓ | | | | | java | ✓ | | | | | javascript | ✓ | | ✓ | `typescript-language-server` | diff --git a/languages.toml b/languages.toml index f9362eac..3c328610 100644 --- a/languages.toml +++ b/languages.toml @@ -355,7 +355,7 @@ injection-regex = "haskell" file-types = ["hs"] roots = [] comment-token = "--" - +language-server = { command = "haskell-language-server-wrapper", args = ["--lsp"] } indent = { tab-width = 2, unit = " " } [[language]] -- cgit v1.2.3-70-g09d2 From 7d510429c564d216b4f1419b37a37cf7384f49c0 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 23 Jan 2022 16:39:18 +0900 Subject: Enable tree-sitter for .zshrc and .bashrc Closes #1460 --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 3c328610..5d2bdff4 100644 --- a/languages.toml +++ b/languages.toml @@ -213,7 +213,7 @@ indent = { tab-width = 2, unit = " " } name = "bash" scope = "source.bash" injection-regex = "bash" -file-types = ["sh", "bash"] +file-types = ["sh", "bash", ".bashrc", ".zshrc"] shebangs = ["sh", "bash", "dash"] roots = [] comment-token = "#" -- cgit v1.2.3-70-g09d2 From a4fffaed9fed04c339c7a9d10075902575b22a40 Mon Sep 17 00:00:00 2001 From: chunghha Date: Sun, 23 Jan 2022 20:42:46 -0600 Subject: Enable tree-sitter for .bash_profile (#1571) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 5d2bdff4..661e31bf 100644 --- a/languages.toml +++ b/languages.toml @@ -213,7 +213,7 @@ indent = { tab-width = 2, unit = " " } name = "bash" scope = "source.bash" injection-regex = "bash" -file-types = ["sh", "bash", ".bashrc", ".zshrc"] +file-types = ["sh", "bash", ".bash_profile", ".bashrc", ".zshrc"] shebangs = ["sh", "bash", "dash"] roots = [] comment-token = "#" -- cgit v1.2.3-70-g09d2 From 0ad7561135cb53bdcb067e092fa1edaba96ffdad Mon Sep 17 00:00:00 2001 From: Eric Crosson Date: Mon, 24 Jan 2022 09:25:19 -0600 Subject: Enable tree-sitter for .zshenv and zsh files (#1574) This commit builds on #1460, #1571, and others, adding the .zshenv file and all files with the zsh extension to the file-types using bash syntax-highlighting.--- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'languages.toml') diff --git a/languages.toml b/languages.toml index 661e31bf..a589d7b8 100644 --- a/languages.toml +++ b/languages.toml @@ -213,7 +213,7 @@ indent = { tab-width = 2, unit = " " } name = "bash" scope = "source.bash" injection-regex = "bash" -file-types = ["sh", "bash", ".bash_profile", ".bashrc", ".zshrc"] +file-types = ["sh", "bash", "zsh", ".bash_login", ".bash_logout", ".bash_profile", ".bashrc", ".profile", ".zshenv", ".zlogin", ".zlogout", ".zprofile", ".zshrc"] shebangs = ["sh", "bash", "dash"] roots = [] comment-token = "#" -- cgit v1.2.3-70-g09d2 From 7bce91556afd2430c336f2fe4a6ce3f7ce555be2 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 25 Jan 2022 00:50:34 -0600 Subject: add tree-sitter-iex (#1576) * add tree-sitter-iex * run docgen task * fix url for iex submodule--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-iex | 1 + languages.toml | 7 +++++++ runtime/queries/iex/highlights.scm | 1 + runtime/queries/iex/injections.scm | 6 ++++++ 6 files changed, 20 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-iex create mode 100644 runtime/queries/iex/highlights.scm create mode 100644 runtime/queries/iex/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 780d1b63..247ac276 100644 --- a/.gitmodules +++ b/.gitmodules @@ -214,3 +214,7 @@ path = helix-syntax/languages/tree-sitter-elm url = https://github.com/elm-tooling/tree-sitter-elm shallow = true +[submodule "helix-syntax/languages/tree-sitter-iex"] + path = helix-syntax/languages/tree-sitter-iex + url = https://github.com/elixir-lang/tree-sitter-iex + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index e4070117..eff82226 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -21,6 +21,7 @@ | graphql | ✓ | | | | | haskell | ✓ | | | `haskell-language-server-wrapper` | | html | ✓ | | | | +| iex | ✓ | | | | | java | ✓ | | | | | javascript | ✓ | | ✓ | `typescript-language-server` | | json | ✓ | | ✓ | | diff --git a/helix-syntax/languages/tree-sitter-iex b/helix-syntax/languages/tree-sitter-iex new file mode 160000 index 00000000..3ec55082 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-iex @@ -0,0 +1 @@ +Subproject commit 3ec55082cf0be015d03148be8edfdfa8c56e77f9 diff --git a/languages.toml b/languages.toml index a589d7b8..02c64732 100644 --- a/languages.toml +++ b/languages.toml @@ -586,3 +586,10 @@ auto-format = true comment-token = "--" language-server = { command = "elm-language-server" } indent = { tab-width = 4, unit = " " } + +[[language]] +name = "iex" +scope = "source.iex" +injection-regex = "iex" +file-types = ["iex"] +roots = [] diff --git a/runtime/queries/iex/highlights.scm b/runtime/queries/iex/highlights.scm new file mode 100644 index 00000000..2847fbff --- /dev/null +++ b/runtime/queries/iex/highlights.scm @@ -0,0 +1 @@ +(prompt) @comment diff --git a/runtime/queries/iex/injections.scm b/runtime/queries/iex/injections.scm new file mode 100644 index 00000000..48863d9d --- /dev/null +++ b/runtime/queries/iex/injections.scm @@ -0,0 +1,6 @@ +((evaluation_block (prompt_line (expression) @injection.content)) + (#set! injection.language "elixir") + (#set! injection.combined)) + +((result) @injection.content + (#set! injection.language "elixir")) -- cgit v1.2.3-70-g09d2 From d6b6ad879e297ff786ce520acd3ce9c4ff3c2e8e Mon Sep 17 00:00:00 2001 From: Daniel S Poulin Date: Mon, 31 Jan 2022 22:35:07 -0500 Subject: epocsquadron/add tree sitter twig (#1602) * Add tree-sitter-twig grammer and highlights The gammar itself is quite basic, but is much better than nothing for working with real files consisting mostly of html. * Docgen for newly added grammar--- .gitmodules | 4 ++++ book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-twig | 1 + languages.toml | 9 +++++++++ runtime/queries/twig/highlights.scm | 16 ++++++++++++++++ runtime/queries/twig/injections.scm | 3 +++ 6 files changed, 34 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-twig create mode 100644 runtime/queries/twig/highlights.scm create mode 100644 runtime/queries/twig/injections.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index 247ac276..d35b0f33 100644 --- a/.gitmodules +++ b/.gitmodules @@ -218,3 +218,7 @@ path = helix-syntax/languages/tree-sitter-iex url = https://github.com/elixir-lang/tree-sitter-iex shallow = true +[submodule "helix-syntax/languages/tree-sitter-twig"] + path = helix-syntax/languages/tree-sitter-twig + url = https://github.com/eirabben/tree-sitter-twig.git + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 85371773..d10b56f1 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -54,6 +54,7 @@ | toml | ✓ | | | | | tsq | ✓ | | | | | tsx | ✓ | | | `typescript-language-server` | +| twig | ✓ | | | | | typescript | ✓ | | ✓ | `typescript-language-server` | | vue | ✓ | | | | | wgsl | ✓ | | | | diff --git a/helix-syntax/languages/tree-sitter-twig b/helix-syntax/languages/tree-sitter-twig new file mode 160000 index 00000000..b7444181 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-twig @@ -0,0 +1 @@ +Subproject commit b7444181fb38e603e25ea8fcdac55f9492e49c27 diff --git a/languages.toml b/languages.toml index 02c64732..74c01da5 100644 --- a/languages.toml +++ b/languages.toml @@ -231,6 +231,15 @@ roots = [] indent = { tab-width = 4, unit = " " } +[[language]] +name = "twig" +scope = "source.twig" +injection-regex = "twig" +file-types = ["twig"] +roots = [] + +indent = { tab-width = 2, unit = " " } + [[language]] name = "latex" scope = "source.tex" diff --git a/runtime/queries/twig/highlights.scm b/runtime/queries/twig/highlights.scm new file mode 100644 index 00000000..2c95ab63 --- /dev/null +++ b/runtime/queries/twig/highlights.scm @@ -0,0 +1,16 @@ +(comment_directive) @comment + +[ + "{%" + "{%-" + "{%~" + "%}" + "-%}" + "~%}" + "{{" + "{{-" + "{{~" + "}}" + "-}}" + "~}}" +] @keyword diff --git a/runtime/queries/twig/injections.scm b/runtime/queries/twig/injections.scm new file mode 100644 index 00000000..f0822734 --- /dev/null +++ b/runtime/queries/twig/injections.scm @@ -0,0 +1,3 @@ +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) -- cgit v1.2.3-70-g09d2 From f5b95beef69bbd8e627b6b0e7ea69317fd12b763 Mon Sep 17 00:00:00 2001 From: Jared Ramirez Date: Sat, 5 Feb 2022 21:24:01 -0800 Subject: feat(languages): rescript (#1616) * Add rescript language support * cargo xtask docgen * Add textobjects & file line ending * Fix text objects & rerun docgen * Fix textobjects queries--- .gitmodules | 4 + book/src/generated/lang-support.md | 1 + helix-syntax/languages/tree-sitter-rescript | 1 + languages.toml | 11 ++ runtime/queries/rescript/highlights.scm | 179 ++++++++++++++++++++++++++++ runtime/queries/rescript/injections.scm | 8 ++ runtime/queries/rescript/textobjects.scm | 9 ++ 7 files changed, 213 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-rescript create mode 100644 runtime/queries/rescript/highlights.scm create mode 100644 runtime/queries/rescript/injections.scm create mode 100644 runtime/queries/rescript/textobjects.scm (limited to 'languages.toml') diff --git a/.gitmodules b/.gitmodules index d35b0f33..55ed97b3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -222,3 +222,7 @@ path = helix-syntax/languages/tree-sitter-twig url = https://github.com/eirabben/tree-sitter-twig.git shallow = true +[submodule "helix-syntax/languages/tree-sitter-rescript"] + path = helix-syntax/languages/tree-sitter-rescript + url = https://github.com/jaredramirez/tree-sitter-rescript + shallow = true diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d10b56f1..64dab6d3 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -46,6 +46,7 @@ | python | ✓ | ✓ | ✓ | `pylsp` | | racket | | | | `racket` | | regex | ✓ | | | | +| rescript | ✓ | ✓ | | `rescript-language-server` | | ruby | ✓ | | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | scala | ✓ | | ✓ | `metals` | diff --git a/helix-syntax/languages/tree-sitter-rescript b/helix-syntax/languages/tree-sitter-rescript new file mode 160000 index 00000000..761eb912 --- /dev/null +++ b/helix-syntax/languages/tree-sitter-rescript @@ -0,0 +1 @@ +Subproject commit 761eb9126b65e078b1b5770ac296b4af8870f933 diff --git a/languages.toml b/languages.toml index 74c01da5..041d1564 100644 --- a/languages.toml +++ b/languages.toml @@ -602,3 +602,14 @@ scope = "source.iex" injection-regex = "iex" file-types = ["iex"] roots = [] + +[[language]] +name = "rescript" +scope = "source.rescript" +injection-regex = "rescript" +file-types = ["res"] +roots = ["bsconfig.json"] +auto-format = true +comment-token = "//" +language-server = { command = "rescript-language-server", args = ["--stdio"] } +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/rescript/highlights.scm b/runtime/queries/rescript/highlights.scm new file mode 100644 index 00000000..b9ab8ea6 --- /dev/null +++ b/runtime/queries/rescript/highlights.scm @@ -0,0 +1,179 @@ +(comment) @comment + +; Identifiers +;------------ + +; Escaped identifiers like \"+." +((value_identifier) @function.macro + (#match? @function.macro "^\\.*$")) + +[ + (type_identifier) + (unit_type) + "list" +] @type + +[ + (variant_identifier) + (polyvar_identifier) +] @constant + +(property_identifier) @variable.other.member +(module_identifier) @namespace + +(jsx_identifier) @tag +(jsx_attribute (property_identifier) @variable.parameter) + +; Parameters +;---------------- + +(list_pattern (value_identifier) @variable.parameter) +(spread_pattern (value_identifier) @variable.parameter) + +; String literals +;---------------- + +[ + (string) + (template_string) +] @string + +(template_substitution + "${" @punctuation.bracket + "}" @punctuation.bracket) @embedded + +(character) @constant.character +(escape_sequence) @constant.character.escape + +; Other literals +;--------------- + +[ + (true) + (false) +] @constant.builtin + +(number) @constant.numeric +(polyvar) @constant +(polyvar_string) @constant + +; Functions +;---------- + +[ + (formal_parameters (value_identifier)) + (positional_parameter (value_identifier)) + (labeled_parameter (value_identifier)) +] @variable.parameter + +(function parameter: (value_identifier) @variable.parameter) + +; Meta +;----- + +[ + "@" + "@@" + (decorator_identifier) +] @label + +(extension_identifier) @keyword +("%") @keyword + +; Misc +;----- + +(subscript_expression index: (string) @variable.other.member) +(polyvar_type_pattern "#" @constant) + +[ + ("include") + ("open") +] @keyword + +[ + "as" + "export" + "external" + "let" + "module" + "mutable" + "private" + "rec" + "type" + "and" +] @keyword + +[ + "if" + "else" + "switch" +] @keyword + +[ + "exception" + "try" + "catch" + "raise" +] @keyword + +[ + "." + "," + "|" +] @punctuation.delimiter + +[ + "++" + "+" + "+." + "-" + "-." + "*" + "*." + "/" + "/." + "<" + "<=" + "==" + "===" + "!" + "!=" + "!==" + ">" + ">=" + "&&" + "||" + "=" + ":=" + "->" + "|>" + ":>" + (uncurry) +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(polyvar_type + [ + "[" + "[>" + "[<" + "]" + ] @punctuation.bracket) + +[ + "~" + "?" + "=>" + "..." +] @punctuation + +(ternary_expression ["?" ":"] @operator) diff --git a/runtime/queries/rescript/injections.scm b/runtime/queries/rescript/injections.scm new file mode 100644 index 00000000..201cce75 --- /dev/null +++ b/runtime/queries/rescript/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((raw_js) @injection.content + (#set! injection.language "javascript")) + +((raw_gql) @injection.content + (#set! injection.language "graphql")) diff --git a/runtime/queries/rescript/textobjects.scm b/runtime/queries/rescript/textobjects.scm new file mode 100644 index 00000000..7ee8cd1a --- /dev/null +++ b/runtime/queries/rescript/textobjects.scm @@ -0,0 +1,9 @@ +; Classes (modules) +;------------------ + +(module_declaration definition: ((_) @class.inside)) @class.around + +; Functions +;---------- + +(function body: (_) @function.inside) @function.around -- cgit v1.2.3-70-g09d2