mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu)
|
||||
- [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] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD)
|
||||
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ list.clojure = {
|
|||
|
||||
list.commonlisp = {
|
||||
install_info = {
|
||||
url = "~/projects/tree-sitter-commonlisp",
|
||||
url = "https://github.com/theHamsta/tree-sitter-commonlisp",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
filetype = 'lisp',
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
(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)$"))
|
||||
|
||||
;;; clojure.core=> (cp/pprint (sort (keep (fn [[s v]] (when-not (:macro (meta v)) s)) (ns-publics *ns*))))
|
||||
;;; ...and then some manual filtering...
|
||||
;; 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
|
||||
.
|
||||
(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
|
||||
|
||||
(defun_keyword) @function.macro
|
||||
|
|
@ -10,9 +15,14 @@
|
|||
lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @type)))
|
||||
(defun_header
|
||||
lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_))))
|
||||
(defun_header
|
||||
specifier: (sym_lit) @type)
|
||||
|
||||
[":" "."] @punctuation.special
|
||||
|
||||
[
|
||||
(accumulation_verb)
|
||||
(for_clause_word)
|
||||
"for"
|
||||
"and"
|
||||
"finally"
|
||||
|
|
@ -21,59 +31,51 @@
|
|||
"when"
|
||||
"if"
|
||||
"unless"
|
||||
"else"
|
||||
"do"
|
||||
"loop"
|
||||
"below"
|
||||
"in"
|
||||
"from"
|
||||
"across"
|
||||
"repeat"
|
||||
"being"
|
||||
"into"
|
||||
"with"
|
||||
"as"
|
||||
"while"
|
||||
"until"
|
||||
"return"
|
||||
"initially"
|
||||
] @function.macro
|
||||
"=" @operator
|
||||
|
||||
(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
|
||||
|
||||
(num_lit) @number
|
||||
|
||||
((sym_lit) @boolean (#eq? @boolean "t"))
|
||||
((sym_lit) @boolean (#match? @boolean "^(t|T)$"))
|
||||
|
||||
(nil_lit) @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
;; metadata experiment
|
||||
(meta_lit
|
||||
marker: "^" @punctuation.special)
|
||||
|
||||
;; dynamic variables
|
||||
((sym_lit) @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
|
||||
"'" @string.escape
|
||||
(format_specifier) @string.escape
|
||||
(quoting_lit) @string.escape
|
||||
|
||||
;; syntax quote
|
||||
|
|
@ -89,6 +91,12 @@
|
|||
|
||||
(block_comment) @comment
|
||||
|
||||
|
||||
(with_clause
|
||||
type: (_) @type)
|
||||
(for_clause
|
||||
type: (_) @type)
|
||||
|
||||
;; defun-like things
|
||||
(list_lit
|
||||
.
|
||||
|
|
@ -97,11 +105,12 @@
|
|||
(sym_lit) @function
|
||||
(#eq? @function.macro "deftest"))
|
||||
|
||||
;; Macros
|
||||
;;; Macros and Special Operators
|
||||
(list_lit
|
||||
.
|
||||
(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
|
||||
((sym_lit) @constant
|
||||
|
|
@ -111,15 +120,13 @@
|
|||
marker: "#'" @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
|
||||
.
|
||||
(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
|
||||
.
|
||||
|
|
@ -130,4 +137,6 @@
|
|||
((sym_lit) @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)")
|
||||
.
|
||||
(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