From 4771cc7ee49ebf59f837a6899a6b1d7e044c011a Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 14 Oct 2021 13:45:32 -0500 Subject: [PATCH] align highlight scopes with documented scopes --- book/src/themes.md | 2 ++ runtime/queries/elixir/highlights.scm | 45 +++++++++++++-------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index a99e3a59e..2d75ac576 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -120,6 +120,8 @@ We use a similar set of scopes as - `path` - `url` +- `symbol` - Elixir atoms, Ruby symbols, Clojure keywords + - `comment` - Code comments - `line` - Single line comments (`//`) - `block` - Block comments (e.g. (`/* */`) diff --git a/runtime/queries/elixir/highlights.scm b/runtime/queries/elixir/highlights.scm index a5b3884e0..82ef081db 100644 --- a/runtime/queries/elixir/highlights.scm +++ b/runtime/queries/elixir/highlights.scm @@ -23,29 +23,29 @@ ; * doc string (unary_operator - operator: "@" @comment.doc + operator: "@" @comment.block.documentation operand: (call - target: (identifier) @comment.doc.__attribute__ + target: (identifier) @comment.block.documentation.__attribute__ (arguments [ - (string) @comment.doc - (charlist) @comment.doc + (string) @comment.block.documentation + (charlist) @comment.block.documentation (sigil - quoted_start: _ @comment.doc - quoted_end: _ @comment.doc) @comment.doc - (boolean) @comment.doc + quoted_start: _ @comment.block.documentation + quoted_end: _ @comment.block.documentation) @comment.block.documentation + (boolean) @comment.block.documentation ])) - (#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$")) + (#match? @comment.block.documentation.__attribute__ "^(moduledoc|typedoc|doc)$")) ; * module attribute (unary_operator - operator: "@" @attribute + operator: "@" @variable.property operand: [ - (identifier) @attribute + (identifier) @variable.property (call - target: (identifier) @attribute) - (boolean) @attribute - (nil) @attribute + target: (identifier) @variable.property) + (boolean) @variable.property + (nil) @variable.property ]) ; * capture operand @@ -69,10 +69,9 @@ ; Literals -[ - (boolean) - (nil) -] @constant +(nil) @constant.builtin + +(boolean) @constant.builtin.boolean [ (integer) @@ -85,20 +84,20 @@ target: (dot left: (atom) @type)) -(char) @constant +(char) @constant.character ; Quoted content -(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded +(interpolation "#{" @escape "}" @escape) @embedded -(escape_sequence) @string.escape +(escape_sequence) @escape [ (atom) (quoted_atom) (keyword) (quoted_keyword) -] @tag +] @symbol [ (string) @@ -182,8 +181,8 @@ ; * unused ( - (identifier) @comment.unused - (#match? @comment.unused "^_") + (identifier) @comment + (#match? @comment "^_") ) ; * regular