diff options
| author | Omar Zeghouani <omarzeghouanii@gmail.com> | 2021-05-01 23:24:34 +0100 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-05-07 10:12:31 +0200 |
| commit | 83f7739071855fda38e500cc46e6e05c52fe9140 (patch) | |
| tree | d2430d1799182367266b2b3ae11ebb4f8f5f1689 | |
| parent | [docgen] Update README.md (diff) | |
| download | nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar.gz nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar.bz2 nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar.lz nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar.xz nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.tar.zst nvim-treesitter-83f7739071855fda38e500cc46e6e05c52fe9140.zip | |
Add fish queries
Add isatty as builtin
Update function_definition option
Update highlights.scm per review
Fix list indentation
Add maintainer names
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 1 | ||||
| -rw-r--r-- | queries/fish/folds.scm | 8 | ||||
| -rw-r--r-- | queries/fish/highlights.scm | 155 | ||||
| -rw-r--r-- | queries/fish/indents.scm | 16 | ||||
| -rw-r--r-- | queries/fish/injections.scm | 1 | ||||
| -rw-r--r-- | queries/fish/locals.scm | 10 |
6 files changed, 191 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 369178f42..42cc825b8 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -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 = { diff --git a/queries/fish/folds.scm b/queries/fish/folds.scm new file mode 100644 index 000000000..6075e2e04 --- /dev/null +++ b/queries/fish/folds.scm @@ -0,0 +1,8 @@ +[ + (function_definition) + (if_statement) + (switch_statement) + (for_statement) + (while_statement) + (begin_statement) +] @fold diff --git a/queries/fish/highlights.scm b/queries/fish/highlights.scm new file mode 100644 index 000000000..1d090639a --- /dev/null +++ b/queries/fish/highlights.scm @@ -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 + diff --git a/queries/fish/indents.scm b/queries/fish/indents.scm new file mode 100644 index 000000000..cf8d62658 --- /dev/null +++ b/queries/fish/indents.scm @@ -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 diff --git a/queries/fish/injections.scm b/queries/fish/injections.scm new file mode 100644 index 000000000..4ff116fce --- /dev/null +++ b/queries/fish/injections.scm @@ -0,0 +1 @@ +(comment) @comment @combined diff --git a/queries/fish/locals.scm b/queries/fish/locals.scm new file mode 100644 index 000000000..75d9cafa1 --- /dev/null +++ b/queries/fish/locals.scm @@ -0,0 +1,10 @@ +;; Scopes +(function_definition) @scope + +;; Definitions +(function_definition + name: (word) @definition.function) + +;; References +(variable_name) @reference +(word) @reference |
