Skip to content

Commit

Permalink
fix: pattern according to new tree-sitter-r
Browse files Browse the repository at this point in the history
Signed-off-by: Shuguang Sun <[email protected]>
  • Loading branch information
ShuguangSun committed Nov 20, 2024
1 parent 9669c00 commit 9999f4e
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions tree-sitter-ess-r.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Shuguang Sun <[email protected]>
;; Created: 2021/11/30
;; Version: 1.0
;; Version: 1.1
;; URL: https://github.com/ShuguangSun/tree-sitter-ess-r
;; Package-Requires: ((emacs "26.1") (ess "18.10.1") (tree-sitter "0.12.1") (tree-sitter-langs "0.12.0"))
;; Keywords: tools
Expand Down Expand Up @@ -197,32 +197,26 @@

;; Some additional patterns.
(tree-sitter-hl-add-patterns 'r
[;; (arguments "=" @operator)
;; (formal_parameters "=" @operator)
(function_definition "function" @keyword.function)
(["<-" "<<-" "->" "->>"] @assignment)
(equals_assignment "=" @assignment)
;; (left_assignment name: (identifier) @varname)
;; (equals_assignment name: (identifier) @varname)
;; (right_assignment name: (identifier) @varname)
(dollar "$" @dollar)
(slot "@" @slot)
(unary operator: ["-" "+" "!" "~"] @operatorunary)
(binary operator: [
"<"
">"
"<="
">="
"=="
"!="
"||"
"|"
"&&"
"&"
] @operatorcomp)
(["|>"] @operatorpipe)
(binary operator: [":" "~"] @opspecial)
((special) @opspecial)
[(function_definition "function" @keyword.function)
(binary_operator operator: ["=" "<-" "<<-" "->" "->>"] @assignment)
(extract_operator operator: "$" @dollar)
(extract_operator operator: "@" @slot)
(unary_operator operator: ["-" "+" "!" "~"] @operatorunary)
(binary_operator operator: [
"<"
">"
"<="
">="
"=="
"!="
"||"
"|"
"&&"
"&"
] @operatorcomp)
(binary_operator operator: ["|>"] @operatorpipe)
(binary_operator operator: [":" "~"] @opspecial)
(binary_operator operator: "special" @opspecial)
(call function: (identifier) @modifier
(.match? @modifier "^(library|attach|detach|source|require|setwd|options|par|load|rm|message|warning|.Deprecated|signalCondition|withCallingHandlers)$"))
;; ((identifier) @modifier
Expand All @@ -240,15 +234,15 @@
(_ (intern (format "tree-sitter-ess-r-%s-face" capture-name)))))

(defun tree-sitter-ess-r-mode-activate ()
"Hook to turn on tree-sitter-hl-mode."
"Hook to turn on `tree-sitter-hl-mode'."
(setq-local tree-sitter-hl-face-mapping-function
#'tree-sitter-ess-r-hl-face-from-ess-scope)
(if (tree-sitter-require 'r)
(tree-sitter-hl-mode 1)))

;;;###autoload
(defun tree-sitter-ess-r-using-r-faces ()
"Turn on tree-sitter-hl-mode with ess-r-mode faces."
"Turn on `tree-sitter-hl-mode' with `ess-r-mode' faces."
(interactive)
(add-hook 'ess-r-mode-hook #'tree-sitter-ess-r-mode-activate)
(if (tree-sitter-require 'r)
Expand Down

0 comments on commit 9999f4e

Please sign in to comment.