nvim-treesitter/runtime/queries/fish/highlights.scm

207 lines
4.8 KiB
Scheme
Raw Normal View History

2024-01-06 15:05:50 +09:00
; Fish highlighting
; Operators
[
2024-01-06 15:05:50 +09:00
"&&"
"||"
"|"
"&|"
"2>|"
2024-01-06 15:05:50 +09:00
"&"
".."
"!"
(direction)
(stream_redirect)
] @operator
2024-01-06 15:05:50 +09:00
; match operators of test command
(command
2024-01-06 15:05:50 +09:00
name: (word) @function.builtin
(#eq? @function.builtin "test")
argument: (word) @operator
(#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
2024-01-06 15:05:50 +09:00
; match operators of [ command
(command
2024-01-06 15:05:50 +09:00
name: (word) @punctuation.bracket
(#eq? @punctuation.bracket "[")
argument: (word) @operator
(#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
[
2024-01-06 15:05:50 +09:00
"not"
"and"
"or"
] @keyword.operator
2024-01-06 15:05:50 +09:00
; Conditionals
(if_statement
2024-01-06 15:05:50 +09:00
[
"if"
"end"
] @keyword.conditional)
(switch_statement
2024-01-06 15:05:50 +09:00
[
"switch"
"end"
] @keyword.conditional)
(case_clause
2024-01-06 15:05:50 +09:00
"case" @keyword.conditional)
2024-01-06 15:05:50 +09:00
(else_clause
"else" @keyword.conditional)
2024-01-06 15:05:50 +09:00
(else_if_clause
[
"else"
"if"
] @keyword.conditional)
2024-01-06 15:05:50 +09:00
; Loops/Blocks
(while_statement
2024-01-06 15:05:50 +09:00
[
"while"
"end"
] @keyword.repeat)
(for_statement
2024-01-06 15:05:50 +09:00
[
"for"
"end"
] @keyword.repeat)
(begin_statement
2024-01-06 15:05:50 +09:00
[
"begin"
"end"
] @keyword.repeat)
2024-01-06 15:05:50 +09:00
; Keywords
[
2024-01-06 15:05:50 +09:00
"in"
(break)
(continue)
] @keyword
"return" @keyword.return
2024-01-06 15:05:50 +09:00
; Punctuation
[
2024-01-06 15:05:50 +09:00
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
"," @punctuation.delimiter
2024-01-06 15:05:50 +09:00
; Commands
(command
argument: [
(word) @variable.parameter
(#lua-match? @variable.parameter "^[-]")
])
2024-01-06 15:05:50 +09:00
(command_substitution
"$" @punctuation.special)
2023-02-23 20:30:36 +01:00
; non-builtin command names
2024-01-06 15:05:50 +09:00
(command
name: (word) @function.call)
2026-01-19 05:34:27 -08:00
; derived from builtin -n (fish 4.3.3)
(command
name: [
(word) @function.builtin
(#any-of? @function.builtin
"." ":" "_" "abbr" "alias" "argparse" "bg" "bind" "block" "breakpoint" "builtin" "cd"
"command" "commandline" "complete" "contains" "count" "disown" "echo" "emit" "eval" "exec"
2026-01-19 05:34:27 -08:00
"exit" "fg" "fish_indent" "fish_key_reader" "functions" "history" "isatty" "jobs" "math"
"path" "printf" "pwd" "random" "read" "realpath" "set" "set_color" "source" "status" "string"
"test" "time" "type" "ulimit" "wait")
])
2024-01-06 15:05:50 +09:00
; Functions
(function_definition
2024-01-06 15:05:50 +09:00
[
"function"
"end"
] @keyword.function)
(function_definition
name: [
(word)
(concatenation)
] @function)
2024-01-06 15:05:50 +09:00
(function_definition
option: [
(word)
(concatenation
(word))
] @variable.parameter
2024-01-06 15:05:50 +09:00
(#lua-match? @variable.parameter "^[-]"))
; Strings
[
(double_quote_string)
(single_quote_string)
] @string
(escape_sequence) @string.escape
2024-01-06 15:05:50 +09:00
; Variables
(variable_name) @variable
2024-01-06 15:05:50 +09:00
(variable_expansion) @constant
(variable_expansion
"$" @punctuation.special) @none
; Reference: https://fishshell.com/docs/current/language.html#special-variables
((variable_name) @variable.builtin
(#any-of? @variable.builtin
2026-01-19 05:34:27 -08:00
"PATH" "CDPATH" "LANG" "LANGUAGE" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_MONETARY"
"LC_NUMERIC" "LC_TIME" "fish_color_normal" "fish_color_command" "fish_color_keyword"
"fish_color_keyword" "fish_color_redirection" "fish_color_end" "fish_color_error"
"fish_color_param" "fish_color_valid_path" "fish_color_option" "fish_color_comment"
"fish_color_selection" "fish_color_operator" "fish_color_escape" "fish_color_autosuggestion"
"fish_color_cwd" "fish_color_cwd_root" "fish_color_user" "fish_color_host"
"fish_color_host_remote" "fish_color_status" "fish_color_cancel" "fish_color_search_match"
"fish_color_history_current" "fish_pager_color_progress" "fish_pager_color_background"
"fish_pager_color_prefix" "fish_pager_color_completion" "fish_pager_color_description"
"fish_pager_color_selected_background" "fish_pager_color_selected_prefix"
"fish_pager_color_selected_completion" "fish_pager_color_selected_description"
"fish_pager_color_secondary_background" "fish_pager_color_secondary_prefix"
"fish_pager_color_secondary_completion" "fish_pager_color_secondary_description"
"fish_term24bit" "fish_term256" "fish_ambiguous_width" "fish_emoji_width"
"fish_autosuggestion_enabled" "fish_handle_reflow" "fish_key_bindings" "fish_escape_delay_ms"
"fish_sequence_key_delay_ms" "fish_complete_path" "fish_cursor_selection_mode"
"fish_cursor_default" "fish_cursor_insert" "fish_cursor_replace" "fish_cursor_replace_one"
"fish_cursor_visual" "fish_cursor_external" "fish_function_path" "fish_greeting" "fish_history"
"fish_trace" "FISH_DEBUG" "FISH_DEBUG_OUTPUT" "fish_user_paths" "umask" "BROWSER" "_" "argv"
"CMD_DURATION" "COLUMNS" "LINES" "fish_kill_signal" "fish_killring" "fish_read_limit" "fish_pid"
2026-01-19 05:34:27 -08:00
"fish_terminal_color_theme" "history" "HOME" "hostname" "IFS" "last_pid" "PWD" "pipestatus"
"SHLVL" "status" "status_generation" "TERM" "USER" "EUID" "version" "FISH_VERSION"))
2024-01-06 15:05:50 +09:00
; Nodes
[
(integer)
(float)
] @number
(comment) @comment
2024-01-06 15:05:50 +09:00
2022-09-11 11:22:29 +01:00
(comment) @spell
2021-06-06 19:55:38 +01:00
((word) @boolean
2024-01-06 15:05:50 +09:00
(#any-of? @boolean "true" "false"))
2024-01-06 15:05:50 +09:00
((program
.
(comment) @keyword.directive @nospell)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(#lua-match? @keyword.directive "^#!/"))