aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules4
-rw-r--r--book/src/generated/lang-support.md1
m---------helix-syntax/languages/tree-sitter-fish0
-rw-r--r--languages.toml11
-rw-r--r--runtime/queries/fish/highlights.scm156
-rw-r--r--runtime/queries/fish/indents.toml12
-rw-r--r--runtime/queries/fish/injections.scm2
-rw-r--r--runtime/queries/fish/textobjects.scm1
8 files changed, 187 insertions, 0 deletions
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
+Subproject 04e54ab6585dfd4fee6ddfe5849af56f101b6d4
diff --git a/languages.toml b/languages.toml
index 0695022e..61eb47ec 100644
--- a/languages.toml
+++ b/languages.toml
@@ -46,6 +46,17 @@ 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"
injection-regex = "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