Skip to content

Commit

Permalink
feat: Add Fish support (#267)
Browse files Browse the repository at this point in the history
* feat: Add Fish support

* fix reg
  • Loading branch information
jcs090218 authored Oct 12, 2023
1 parent 6f033b5 commit 63e5b99
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,9 @@
branch = main
update = none
ignore = dirty
[submodule "repos/fish"]
path = repos/fish
url = https://github.com/ram02z/tree-sitter-fish
branch = master
update = none
ignore = dirty
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Add `Fish` support

## 0.12.69 - 2023-10-12
- Add `Tcl` support
Expand Down
167 changes: 167 additions & 0 deletions queries/fish/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
;; Fish highlighting

;; Operators

[
"&&"
"||"
"|"
"&"
".."
"!"
(direction)
(stream_redirect)
] @operator

;; match operators of test command
;(command
; name: (word) @function.builtin (#eq? @function.builtin "test")
; argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))

;; match operators of [ command
;(command
; name: (word) @punctuation.bracket (#eq? @punctuation.bracket "[")
; argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))

[
"not"
"and"
"or"
] @keyword.operator

;; Conditionals

(if_statement
[
"if"
"end"
] @conditional)

(switch_statement
[
"switch"
"end"
] @conditional)

(case_clause
[
"case"
] @conditional)

(else_clause
[
"else"
] @conditional)

(else_if_clause
[
"else"
"if"
] @conditional)

;; Loops/Blocks

(while_statement
[
"while"
"end"
] @repeat)

(for_statement
[
"for"
"end"
] @repeat)

(begin_statement
[
"begin"
"end"
] @repeat)

;; Keywords

[
"in"
(break)
(continue)
] @keyword

"return" @keyword.return

;; Punctuation

[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket

"," @punctuation.delimiter

;; Commands

;(command
; argument: [
; (word) @parameter (#lua-match? @parameter "^[-]")
; ]
;)

(command_substitution "$" @punctuation.bracket)

; non-builtin command names
(command name: (word) @function.call)

; derived from builtin -n (fish 3.2.2)
(command
name: [
(word) @function.builtin
(#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")
]
)

;; Functions

(function_definition ["function" "end"] @keyword.function)

(function_definition
name: [
(word) (concatenation)
]
@function)

;(function_definition
; option: [
; (word)
; (concatenation (word))
; ] @parameter (#lua-match? @parameter "^[-]")
;)

;; Strings

[(double_quote_string) (single_quote_string)] @string
(escape_sequence) @string.escape

;; Variables

(variable_name) @variable
(variable_expansion) @constant

;; Nodes

[(integer) (float)] @number
(comment) @comment
(comment) @spell

((word) @boolean
(#any-of? @boolean "true" "false"))

;((program . (comment) @preproc)
; (#lua-match? @preproc "^#!/"))

;; Error

(ERROR) @error
1 change: 1 addition & 0 deletions repos/fish
Submodule fish added at f91769
1 change: 1 addition & 0 deletions tree-sitter-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ See `tree-sitter-langs-repos'."
(arduino-mode . arduino)
(astro-mode . astro)
(fasm-mode . asm)
(fish-mode . fish)
(masm-mode . asm)
(nasm-mode . asm)
(sh-mode . bash)
Expand Down

0 comments on commit 63e5b99

Please sign in to comment.