Add fish queries

Add isatty as builtin

Update function_definition option

Update highlights.scm per review

Fix list indentation

Add maintainer names
This commit is contained in:
Omar Zeghouani 2021-05-01 23:24:34 +01:00 committed by Thomas Vigouroux
parent 509bc1a8e1
commit 83f7739071
6 changed files with 191 additions and 0 deletions

View file

@ -145,6 +145,7 @@ list.fish = {
url = "https://github.com/krnik/tree-sitter-fish",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = {"@krnik", "@ram02z"},
}
list.php = {

8
queries/fish/folds.scm Normal file
View file

@ -0,0 +1,8 @@
[
(function_definition)
(if_statement)
(switch_statement)
(for_statement)
(while_statement)
(begin_statement)
] @fold

155
queries/fish/highlights.scm Normal file
View file

@ -0,0 +1,155 @@
;; Fish highlighting
;; Operators
[
"&&"
"||"
"|"
"&"
"="
"!="
".."
"!"
(direction)
(stream_redirect)
] @operator
[
"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"
"return"
(break)
(continue)
] @keyword
;; Punctuation
[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
"," @punctuation.delimiter
;; Commands
(command
argument: [
(word) @parameter (#match? @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)$")
]
)
;; Functions
(function_definition ["function" "end"] @keyword.function)
(function_definition
name: [
(word) (concatenation)
]
@function)
(function_definition
option: [
(word)
(concatenation (word))
] @parameter (#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
(test_option) @string
((word) @boolean
(#match? @boolean "^(true|false)$"))
;; Error
(ERROR) @error

16
queries/fish/indents.scm Normal file
View file

@ -0,0 +1,16 @@
[
(function_definition)
(while_statement)
(for_statement)
(if_statement)
(begin_statement)
(switch_statement)
] @indent
[
(else_if_clause)
(else_clause)
"end"
] @branch
(comment) @ignore

View file

@ -0,0 +1 @@
(comment) @comment @combined

10
queries/fish/locals.scm Normal file
View file

@ -0,0 +1,10 @@
;; Scopes
(function_definition) @scope
;; Definitions
(function_definition
name: (word) @definition.function)
;; References
(variable_name) @reference
(word) @reference