diff options
| author | Connor Lay (Clay) <connorlay@users.noreply.github.com> | 2021-08-13 10:09:16 -0700 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-09-17 21:06:36 +0200 |
| commit | 6d1a06fd9c9587b2c30082a34b0c40906f44c3cf (patch) | |
| tree | f250207fcbb394650ae0f1fac59110877ab8a653 /queries/elixir | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar.gz nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar.bz2 nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar.lz nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar.xz nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.tar.zst nvim-treesitter-6d1a06fd9c9587b2c30082a34b0c40906f44c3cf.zip | |
Fix: Improve Elixir highlighting performance (#1682)
Diffstat (limited to 'queries/elixir')
| -rw-r--r-- | queries/elixir/highlights.scm | 240 |
1 files changed, 107 insertions, 133 deletions
diff --git a/queries/elixir/highlights.scm b/queries/elixir/highlights.scm index 51c57494d..413ae6cc8 100644 --- a/queries/elixir/highlights.scm +++ b/queries/elixir/highlights.scm @@ -1,180 +1,154 @@ -(identifier) @variable - -; _unused variables -(unused_identifier) @comment - -; __MODULE__ and friends -(special_identifier) @constant.builtin - -(module) @type - -[(atom) (keyword)] @symbol - -(integer) @number -(float) @float - -[(true) (false)] @boolean - -(nil) @constant.builtin - -(comment) @comment - -[ - "," - "." -] @punctuation.delimiter +(ERROR) @error [ "(" ")" + "<<" + ">>" "[" "]" "{" "}" - "<<" - ">>" ] @punctuation.bracket -(interpolation - "#{" @punctuation.special - "}" @punctuation.special) @none - [ - (heredoc_content) - (sigil_content) - (string_content) - (string_end) - (string_start) -] @string + "," + "->" + "." +] @punctuation.delimiter [ - (heredoc_end) - (heredoc_start) - (sigil_end) (sigil_start) -] @string.special + (sigil_end) + (heredoc_start) + (heredoc_end) +] @punctuation.special -(escape_sequence) @string.escape +(interpolation ["#{" "}"] @punctuation.special) [ "after" + "and" + "catch" "do" + "else" "end" -] @keyword - -[ - "and" + "fn" "in" - "not" "not in" + "not" "or" -] @keyword.operator - -; Call to a local function -(call (function_identifier) @method) + "rescue" + "when" +] @keyword -; Call to a remote (or external) function -(dot_call - remote: [(atom) (module)] @type - function: (function_identifier) @method) +[ + (comment) + (unused_identifier) +] @comment -(dot_call - remote: (identifier) @variable - function: (function_identifier) @method) +[ + (heredoc_content) + (sigil_content) + (string) +] @string -"fn" @keyword.function +; __MODULE__ and friends +(special_identifier) @constant.builtin -; def, defp, defguard, ... everything that starts with def -(call (function_identifier) @keyword.function - (#lua-match? @keyword.function "^def%a*$")) +(map ["%{" "}"] @constructor) -(call (function_identifier) @keyword.function - (#any-of? @keyword.function "describe" "doctest" "on_exit" "setup" "setup_all" "test")) +(struct ["%" "{" "}"] @constructor) -"else" @conditional +(binary_op operator: _ @operator) -(call (function_identifier) @conditional - (#any-of? @conditional "case" "cond" "if" "unless" "with")) +(unary_op operator: _ @operator) -(call (function_identifier) @repeat - (#eq? @repeat "for")) +(atom) @symbol -(call (function_identifier) @include - (#any-of? @include "alias" "import" "require" "use")) +(keyword) @parameter [ - "catch" - "rescue" -] @exception + (true) + (false) +] @boolean -(call (function_identifier) @exception - (#any-of? @exception "raise" "try")) +(nil) @constant.builtin -; Regex sigil -(sigil - (sigil_start) @_sigil-type - [(sigil_content) (escape_sequence)] @string.regex - (sigil_end) - (#lua-match? @_sigil-type "^~r")) +(sigil) @string.special -"->" @operator +(identifier) @variable -(unary_op - operator: _ @operator) +(module) @type -(binary_op - operator: _ @operator) +(function_identifier) @function -(unary_op - operator: "@" @attribute - [(call - function: (function_identifier) @attribute) - (identifier) @attribute]) +(integer) @number -(unary_op - operator: "@" - (call (function_identifier) @attribute - (heredoc - [(heredoc_start) - (heredoc_content) - (heredoc_end)] @string)) - (#any-of? @attribute "doc" "moduledoc")) +(float) @float + +[ + (sigil_start) + (sigil_end) +] @string.special -(unary_op - operator: "@" - (call (function_identifier) @attribute - (binary_op - left: (identifier) @method)) - (#eq? @attribute "spec")) +; Module attributes as "attributes" +(unary_op operator: "@" @attribute [ + (call function: (function_identifier) @attribute) + (identifier) @attribute +]) -; Definition without arguments -(call (function_identifier) @keyword.function - (identifier) @function - (#lua-match? @keyword.function "^def%a*$")) +; Erlang modules (when they are the remote of a function call) are highlighted as Elixir modules +(dot_call remote: (atom) @type) -; Definition with (some) arguments and (optional) defaults -(call (function_identifier) @keyword.function - (call - function: (function_identifier) @function - (arguments)) - (#lua-match? @keyword.function "^def%a*$")) +(call (function_identifier) @keyword.function (#any-of? @keyword.function + "def" + "defdelegate" + "defexception" + "defguard" + "defguardp" + "defimpl" + "defmacro" + "defmacrop" + "defmodule" + "defoverridable" + "defp" + "defprotocol" + "defstruct" +) [(identifier) @function (_)]) ; 0-arity function def without parens -; Definition with (some) arguments and guard(s) -(call (function_identifier) @keyword.function - (binary_op - left: - (call - function: (function_identifier) @function - (arguments)) - operator: "when") - (#lua-match? @keyword.function "^def%a*$")) +(call (function_identifier) @include (#any-of? @include + "alias" + "import" + "require" + "use" +)) -; Definition of custom binary operator(s) -(call (function_identifier) @keyword.function - (binary_op - left: (identifier) @parameter - operator: _ @function - right: (identifier) @parameter) - (#any-of? @keyword.function "def" "defp")) +(call (function_identifier) @conditional (#any-of? @conditional + "case" + "cond" + "else" + "if" + "unless" + "with" + "receive" +)) -(ERROR) @error +(call (function_identifier) @exception (#any-of? @exception + "raise" + "reraise" + "throw" + "try" +)) + +(call (function_identifier) @repeat (#any-of? @repeat + "for" +)) + +(call (function_identifier) @keyword.function (#any-of? @keyword.function + "describe" + "setup" + "setup_all" + "test" + "using" +)) |
