mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 10:50:06 -04:00
Extend CL highlights
This commit is contained in:
parent
e197736061
commit
64f13eace5
5 changed files with 66 additions and 32 deletions
|
|
@ -140,6 +140,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||||
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @svermeulen)
|
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @svermeulen)
|
||||||
- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu)
|
- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu)
|
||||||
- [x] [comment](https://github.com/stsewd/tree-sitter-comment) (maintained by @stsewd)
|
- [x] [comment](https://github.com/stsewd/tree-sitter-comment) (maintained by @stsewd)
|
||||||
|
- [x] [commonlisp](https://github.com/theHamsta/tree-sitter-commonlisp) (maintained by @theHamsta)
|
||||||
- [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta)
|
- [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta)
|
||||||
- [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD)
|
- [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD)
|
||||||
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)
|
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ list.clojure = {
|
||||||
|
|
||||||
list.commonlisp = {
|
list.commonlisp = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "~/projects/tree-sitter-commonlisp",
|
url = "https://github.com/theHamsta/tree-sitter-commonlisp",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
filetype = 'lisp',
|
filetype = 'lisp',
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@
|
||||||
(sym_lit) @function.macro
|
(sym_lit) @function.macro
|
||||||
(#match? @function.macro "^(\\.|\\.\\.|\\->|\\->>|amap|and|areduce|as\\->|assert|binding|bound\\-fn|case|catch|comment|cond|cond\\->|cond\\->>|condp|delay|do|doseq|dosync|dotimes|doto|extend-protocol|extend-type|finally|fn|fn\\*|for|future|gen-class|gen-interface|if|if\\-let|if\\-not|if\\-some|import|io!|lazy\\-cat|lazy\\-seq|let|letfn|locking|loop|memfn|monitor\\-enter|monitor\\-exit|or|proxy|proxy-super|pvalues|quote|recur|refer\\-clojure|reify|set!|some\\->|some\\->>|sync|throw|time|try|unquote|unquote\\-splicing|var|vswap!|when|when\\-first|when\\-let|when\\-not|when\\-some|while|with\\-bindings|with\\-in\\-str|with\\-loading\\-context|with\\-local\\-vars|with\\-open|with\\-out\\-str|with\\-precision|with\\-redefs)$"))
|
(#match? @function.macro "^(\\.|\\.\\.|\\->|\\->>|amap|and|areduce|as\\->|assert|binding|bound\\-fn|case|catch|comment|cond|cond\\->|cond\\->>|condp|delay|do|doseq|dosync|dotimes|doto|extend-protocol|extend-type|finally|fn|fn\\*|for|future|gen-class|gen-interface|if|if\\-let|if\\-not|if\\-some|import|io!|lazy\\-cat|lazy\\-seq|let|letfn|locking|loop|memfn|monitor\\-enter|monitor\\-exit|or|proxy|proxy-super|pvalues|quote|recur|refer\\-clojure|reify|set!|some\\->|some\\->>|sync|throw|time|try|unquote|unquote\\-splicing|var|vswap!|when|when\\-first|when\\-let|when\\-not|when\\-some|while|with\\-bindings|with\\-in\\-str|with\\-loading\\-context|with\\-local\\-vars|with\\-open|with\\-out\\-str|with\\-precision|with\\-redefs)$"))
|
||||||
|
|
||||||
;;; clojure.core=> (cp/pprint (sort (keep (fn [[s v]] (when-not (:macro (meta v)) s)) (ns-publics *ns*))))
|
;; clojure.core=> (cp/pprint (sort (keep (fn [[s v]] (when-not (:macro (meta v)) s)) (ns-publics *ns*))))
|
||||||
;;; ...and then some manual filtering...
|
;; ...and then some manual filtering...
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
(sym_lit) @function.builtin
|
(sym_lit) @function.builtin
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
(sym_lit) @variable
|
||||||
|
|
||||||
|
;; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp
|
||||||
|
;(list_lit . (sym_lit) @function.builtin (#cl-standard-symbol? @function.builtin))
|
||||||
|
|
||||||
(dis_expr) @comment
|
(dis_expr) @comment
|
||||||
|
|
||||||
(defun_keyword) @function.macro
|
(defun_keyword) @function.macro
|
||||||
|
|
@ -10,9 +15,14 @@
|
||||||
lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @type)))
|
lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @type)))
|
||||||
(defun_header
|
(defun_header
|
||||||
lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_))))
|
lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_))))
|
||||||
|
(defun_header
|
||||||
|
specifier: (sym_lit) @type)
|
||||||
|
|
||||||
|
[":" "."] @punctuation.special
|
||||||
|
|
||||||
[
|
[
|
||||||
(accumulation_verb)
|
(accumulation_verb)
|
||||||
|
(for_clause_word)
|
||||||
"for"
|
"for"
|
||||||
"and"
|
"and"
|
||||||
"finally"
|
"finally"
|
||||||
|
|
@ -21,59 +31,51 @@
|
||||||
"when"
|
"when"
|
||||||
"if"
|
"if"
|
||||||
"unless"
|
"unless"
|
||||||
|
"else"
|
||||||
"do"
|
"do"
|
||||||
"loop"
|
"loop"
|
||||||
"below"
|
"below"
|
||||||
"in"
|
"in"
|
||||||
"from"
|
"from"
|
||||||
"across"
|
"across"
|
||||||
|
"repeat"
|
||||||
"being"
|
"being"
|
||||||
"into"
|
"into"
|
||||||
"with"
|
"with"
|
||||||
"as"
|
"as"
|
||||||
"while"
|
"while"
|
||||||
|
"until"
|
||||||
|
"return"
|
||||||
|
"initially"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
"=" @operator
|
"=" @operator
|
||||||
|
|
||||||
(include_reader_macro) @type
|
(include_reader_macro) @type
|
||||||
"#C" @number
|
["#C" "#c"] @number
|
||||||
|
|
||||||
(kwd_lit) @type
|
[(kwd_lit) (self_referential_reader_macro)] @type
|
||||||
|
|
||||||
|
(package_lit
|
||||||
|
package: (_) @namespace)
|
||||||
|
"cl" @namespace
|
||||||
|
|
||||||
(str_lit) @string
|
(str_lit) @string
|
||||||
|
|
||||||
(num_lit) @number
|
(num_lit) @number
|
||||||
|
|
||||||
((sym_lit) @boolean (#eq? @boolean "t"))
|
((sym_lit) @boolean (#match? @boolean "^(t|T)$"))
|
||||||
|
|
||||||
(nil_lit) @constant.builtin
|
(nil_lit) @constant.builtin
|
||||||
|
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
;; metadata experiment
|
|
||||||
(meta_lit
|
|
||||||
marker: "^" @punctuation.special)
|
|
||||||
|
|
||||||
;; dynamic variables
|
;; dynamic variables
|
||||||
((sym_lit) @variable.builtin
|
((sym_lit) @variable.builtin
|
||||||
(#match? @variable.builtin "^[*].+[*]$"))
|
(#match? @variable.builtin "^[*].+[*]$"))
|
||||||
|
|
||||||
;; gensym
|
|
||||||
((sym_lit) @variable
|
|
||||||
(#match? @variable "^.*#$"))
|
|
||||||
|
|
||||||
;; interop-ish
|
|
||||||
(list_lit
|
|
||||||
.
|
|
||||||
(sym_lit) @method
|
|
||||||
(#match? @method "^\\."))
|
|
||||||
|
|
||||||
;; other symbols with dots
|
|
||||||
((sym_lit) @variable
|
|
||||||
(#match? @variable "\\."))
|
|
||||||
|
|
||||||
;; quote
|
;; quote
|
||||||
"'" @string.escape
|
"'" @string.escape
|
||||||
|
(format_specifier) @string.escape
|
||||||
(quoting_lit) @string.escape
|
(quoting_lit) @string.escape
|
||||||
|
|
||||||
;; syntax quote
|
;; syntax quote
|
||||||
|
|
@ -89,6 +91,12 @@
|
||||||
|
|
||||||
(block_comment) @comment
|
(block_comment) @comment
|
||||||
|
|
||||||
|
|
||||||
|
(with_clause
|
||||||
|
type: (_) @type)
|
||||||
|
(for_clause
|
||||||
|
type: (_) @type)
|
||||||
|
|
||||||
;; defun-like things
|
;; defun-like things
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
|
|
@ -97,11 +105,12 @@
|
||||||
(sym_lit) @function
|
(sym_lit) @function
|
||||||
(#eq? @function.macro "deftest"))
|
(#eq? @function.macro "deftest"))
|
||||||
|
|
||||||
;; Macros
|
;;; Macros and Special Operators
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
(sym_lit) @function.macro
|
(sym_lit) @function.macro
|
||||||
(#match? @function.macro "^(let|progn|prog1|values|error|or|and|defvar|defparameter|loop|in-package|defpackage|[e]?(type)?case|defclass|if|if-let|when-let|when|unless|cond|switch|declaim|optimize)[*]?$"))
|
;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
|
||||||
|
(#match? @function.macro "^(let|function|the|unwind-protect|labels|flet|tagbody|go|(symbol-)?macrolet|progn|prog1|error|or|and|defvar|defparameter|in-package|defpackage|[e]?(type)?case|defstruct|defclass|if|if-let|when-let|when|unless|cond|switch|declaim|optimize)[*]?$"))
|
||||||
|
|
||||||
;; constant
|
;; constant
|
||||||
((sym_lit) @constant
|
((sym_lit) @constant
|
||||||
|
|
@ -111,15 +120,13 @@
|
||||||
marker: "#'" @type
|
marker: "#'" @type
|
||||||
value: (_) @type)
|
value: (_) @type)
|
||||||
|
|
||||||
"#" @type
|
["#" "#p" "#P"] @type
|
||||||
|
|
||||||
|
|
||||||
;;; clojure.core=> (cp/pprint (sort (keep (fn [[s v]] (when-not (:macro (meta v)) s)) (ns-publics *ns*))))
|
|
||||||
;;; ...and then some manual filtering...
|
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
(sym_lit) @function.builtin
|
(sym_lit) @function.builtin
|
||||||
(#match? @function.builtin "^(mapcar|reduce|remove-if-not|cons|car|last|nth|equal[p]?|cdr|first|rest|decf|incf|format)$"))
|
;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
|
||||||
|
(#match? @function.builtin "^(mapcar|reduce|remove-if-not|cons|car|last|nth|equal[p]?|cdr|first|rest|format)$"))
|
||||||
|
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
|
|
@ -130,4 +137,6 @@
|
||||||
((sym_lit) @type
|
((sym_lit) @type
|
||||||
(#match? @type "^[&]"))
|
(#match? @type "^[&]"))
|
||||||
|
|
||||||
[(array_dimension) "#0A"] @number
|
[(array_dimension) "#0A" "#0a"] @number
|
||||||
|
|
||||||
|
(char_lit) @number
|
||||||
|
|
|
||||||
|
|
@ -46,3 +46,27 @@
|
||||||
(sym_lit) @_let (#match? @_let "(cl:|alexandria)?(with-gensyms|dotimes|with-foreign-object)")
|
(sym_lit) @_let (#match? @_let "(cl:|alexandria)?(with-gensyms|dotimes|with-foreign-object)")
|
||||||
.
|
.
|
||||||
(list_lit . (sym_lit) @definition.var)) @scope
|
(list_lit . (sym_lit) @definition.var)) @scope
|
||||||
|
|
||||||
|
(list_lit
|
||||||
|
.
|
||||||
|
(kwd_lit) @_import_from (#eq? @_import_from ":import-from")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
(kwd_lit (kwd_symbol) @definition.import))
|
||||||
|
|
||||||
|
(list_lit
|
||||||
|
.
|
||||||
|
(kwd_lit) @_import_from (#eq? @_import_from ":import-from")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
(sym_lit) @definition.import)
|
||||||
|
|
||||||
|
(list_lit
|
||||||
|
.
|
||||||
|
(kwd_lit) @_use (#eq? @_use ":use")
|
||||||
|
(kwd_lit (kwd_symbol) @definition.import))
|
||||||
|
|
||||||
|
(list_lit
|
||||||
|
.
|
||||||
|
(kwd_lit) @_use (#eq? @_use ":use")
|
||||||
|
(sym_lit) @definition.import)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue