Skip to content

Commit 63e5b99

Browse files
authored
feat: Add Fish support (#267)
* feat: Add Fish support * fix reg
1 parent 6f033b5 commit 63e5b99

File tree

5 files changed

+176
-0
lines changed

5 files changed

+176
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,3 +490,9 @@
490490
branch = main
491491
update = none
492492
ignore = dirty
493+
[submodule "repos/fish"]
494+
path = repos/fish
495+
url = https://github.com/ram02z/tree-sitter-fish
496+
branch = master
497+
update = none
498+
ignore = dirty

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- Add `Fish` support
45

56
## 0.12.69 - 2023-10-12
67
- Add `Tcl` support

queries/fish/highlights.scm

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
;; Fish highlighting
2+
3+
;; Operators
4+
5+
[
6+
"&&"
7+
"||"
8+
"|"
9+
"&"
10+
".."
11+
"!"
12+
(direction)
13+
(stream_redirect)
14+
] @operator
15+
16+
;; match operators of test command
17+
;(command
18+
; name: (word) @function.builtin (#eq? @function.builtin "test")
19+
; argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
20+
21+
;; match operators of [ command
22+
;(command
23+
; name: (word) @punctuation.bracket (#eq? @punctuation.bracket "[")
24+
; argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
25+
26+
[
27+
"not"
28+
"and"
29+
"or"
30+
] @keyword.operator
31+
32+
;; Conditionals
33+
34+
(if_statement
35+
[
36+
"if"
37+
"end"
38+
] @conditional)
39+
40+
(switch_statement
41+
[
42+
"switch"
43+
"end"
44+
] @conditional)
45+
46+
(case_clause
47+
[
48+
"case"
49+
] @conditional)
50+
51+
(else_clause
52+
[
53+
"else"
54+
] @conditional)
55+
56+
(else_if_clause
57+
[
58+
"else"
59+
"if"
60+
] @conditional)
61+
62+
;; Loops/Blocks
63+
64+
(while_statement
65+
[
66+
"while"
67+
"end"
68+
] @repeat)
69+
70+
(for_statement
71+
[
72+
"for"
73+
"end"
74+
] @repeat)
75+
76+
(begin_statement
77+
[
78+
"begin"
79+
"end"
80+
] @repeat)
81+
82+
;; Keywords
83+
84+
[
85+
"in"
86+
(break)
87+
(continue)
88+
] @keyword
89+
90+
"return" @keyword.return
91+
92+
;; Punctuation
93+
94+
[
95+
"["
96+
"]"
97+
"{"
98+
"}"
99+
"("
100+
")"
101+
] @punctuation.bracket
102+
103+
"," @punctuation.delimiter
104+
105+
;; Commands
106+
107+
;(command
108+
; argument: [
109+
; (word) @parameter (#lua-match? @parameter "^[-]")
110+
; ]
111+
;)
112+
113+
(command_substitution "$" @punctuation.bracket)
114+
115+
; non-builtin command names
116+
(command name: (word) @function.call)
117+
118+
; derived from builtin -n (fish 3.2.2)
119+
(command
120+
name: [
121+
(word) @function.builtin
122+
(#any-of? @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")
123+
]
124+
)
125+
126+
;; Functions
127+
128+
(function_definition ["function" "end"] @keyword.function)
129+
130+
(function_definition
131+
name: [
132+
(word) (concatenation)
133+
]
134+
@function)
135+
136+
;(function_definition
137+
; option: [
138+
; (word)
139+
; (concatenation (word))
140+
; ] @parameter (#lua-match? @parameter "^[-]")
141+
;)
142+
143+
;; Strings
144+
145+
[(double_quote_string) (single_quote_string)] @string
146+
(escape_sequence) @string.escape
147+
148+
;; Variables
149+
150+
(variable_name) @variable
151+
(variable_expansion) @constant
152+
153+
;; Nodes
154+
155+
[(integer) (float)] @number
156+
(comment) @comment
157+
(comment) @spell
158+
159+
((word) @boolean
160+
(#any-of? @boolean "true" "false"))
161+
162+
;((program . (comment) @preproc)
163+
; (#lua-match? @preproc "^#!/"))
164+
165+
;; Error
166+
167+
(ERROR) @error

repos/fish

Submodule fish added at f917690

tree-sitter-langs.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ See `tree-sitter-langs-repos'."
104104
(arduino-mode . arduino)
105105
(astro-mode . astro)
106106
(fasm-mode . asm)
107+
(fish-mode . fish)
107108
(masm-mode . asm)
108109
(nasm-mode . asm)
109110
(sh-mode . bash)

0 commit comments

Comments
 (0)