diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-04-04 09:45:45 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-05-17 20:45:31 +0200 |
| commit | e197736061378b5ccc510241ebec0bb765d69fa7 (patch) | |
| tree | e73ebaccda89fca2fefd575160a6e867548fb7e3 /queries | |
| parent | highlights(latex): use any-of? (diff) | |
| download | nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar.gz nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar.bz2 nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar.lz nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar.xz nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.tar.zst nvim-treesitter-e197736061378b5ccc510241ebec0bb765d69fa7.zip | |
Add support for Common Lisp
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/clojure/highlights.scm | 14 | ||||
| -rw-r--r-- | queries/commonlisp/folds.scm | 1 | ||||
| -rw-r--r-- | queries/commonlisp/highlights.scm | 133 | ||||
| -rw-r--r-- | queries/commonlisp/locals.scm | 48 |
4 files changed, 189 insertions, 7 deletions
diff --git a/queries/clojure/highlights.scm b/queries/clojure/highlights.scm index 7a475294f..5789374f9 100644 --- a/queries/clojure/highlights.scm +++ b/queries/clojure/highlights.scm @@ -18,13 +18,13 @@ (meta_lit marker: "^" @punctuation.special) +;;; parameter-related +((sym_lit) @parameter +(#match? @parameter "^[&]")) + ;; dynamic variables ((sym_lit) @variable.builtin - (#match? @variable.builtin "^\\*.+\\*$")) - -;; parameter-related -((sym_lit) @parameter - (#match? @parameter "^&.*$")) + (#match? @variable.builtin "^[*].+[*]$")) ;; gensym ((sym_lit) @variable @@ -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 diff --git a/queries/commonlisp/folds.scm b/queries/commonlisp/folds.scm new file mode 100644 index 000000000..d54daade6 --- /dev/null +++ b/queries/commonlisp/folds.scm @@ -0,0 +1 @@ +(source (list_lit) @fold) diff --git a/queries/commonlisp/highlights.scm b/queries/commonlisp/highlights.scm new file mode 100644 index 000000000..f3f7935a7 --- /dev/null +++ b/queries/commonlisp/highlights.scm @@ -0,0 +1,133 @@ +(dis_expr) @comment + +(defun_keyword) @function.macro +(defun_header + function_name: (_) @function) +(defun_header + lambda_list: (list_lit (sym_lit) @parameter)) +(defun_header + keyword: (defun_keyword "defmethod") + lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @type))) +(defun_header + lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_)))) + +[ + (accumulation_verb) + "for" + "and" + "finally" + "thereis" + "always" + "when" + "if" + "unless" + "do" + "loop" + "below" + "in" + "from" + "across" + "being" + "into" + "with" + "as" + "while" +] @function.macro +"=" @operator + +(include_reader_macro) @type +"#C" @number + +(kwd_lit) @type + +(str_lit) @string + +(num_lit) @number + +((sym_lit) @boolean (#eq? @boolean "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 +(quoting_lit) @string.escape + +;; syntax quote +"`" @string.escape +"," @string.escape +",@" @string.escape +(syn_quoting_lit) @string.escape +(unquoting_lit) @none +(unquote_splicing_lit) @none + + +["(" ")"] @punctuation.bracket + +(block_comment) @comment + +;; defun-like things +(list_lit + . + (sym_lit) @function.macro + . + (sym_lit) @function + (#eq? @function.macro "deftest")) + +;; Macros +(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)[*]?$")) + +;; constant +((sym_lit) @constant + (#match? @constant "^[+].+[+]$")) + +(var_quoting_lit + marker: "#'" @type + value: (_) @type) + +"#" @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)$")) + +(list_lit + . + (sym_lit) @operator + (#match? @operator "^([+*-+=<>]|<=|>=|/=)$")) + + +((sym_lit) @type +(#match? @type "^[&]")) + +[(array_dimension) "#0A"] @number diff --git a/queries/commonlisp/locals.scm b/queries/commonlisp/locals.scm new file mode 100644 index 000000000..859b9c701 --- /dev/null +++ b/queries/commonlisp/locals.scm @@ -0,0 +1,48 @@ + +(defun_header + function_name: (sym_lit) @definition.function (#set! definition.function.scope "parent")) +(defun_header + lambda_list: (list_lit (sym_lit) @definition.parameter)) + +(defun_header + keyword: (defun_keyword "defmethod") + lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @definition.type))) +(defun_header + lambda_list: (list_lit (list_lit . (sym_lit) @definition.parameter . (_)))) + +(sym_lit) @reference + +(defun) @scope + +((list_lit . (sym_lit) @_defvar . (sym_lit) @definition.var) +(#match? @_defvar "^(cl:)?(defvar|defparameter)$")) + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @definition.function + (#match? @_deftest "^(deftest)$")) @scope + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @definition.function + (#match? @_deftest "^(deftest)$")) @scope + +(for_clause . (sym_lit) @definition.var) +(with_clause . (sym_lit) @definition.var) +(loop_macro) @scope + +(list_lit + . + (sym_lit) @_let (#match? @_let "(cl:|cffi:)?(with-accessors|with-foreign-objects|let[*]?)") + . + (list_lit (list_lit . (sym_lit) @definition.var))) @scope + +(list_lit + . + (sym_lit) @_let (#match? @_let "(cl:|alexandria)?(with-gensyms|dotimes|with-foreign-object)") + . + (list_lit . (sym_lit) @definition.var)) @scope |
