diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-04-05 14:37:53 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-05-17 20:45:31 +0200 |
| commit | 64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad (patch) | |
| tree | ff6729054832a327eefac58e313aeb309f386fa6 | |
| parent | Add support for Common Lisp (diff) | |
| download | nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar.gz nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar.bz2 nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar.lz nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar.xz nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.tar.zst nvim-treesitter-64f13eace5c7fa3b2b99c05cadbbe46f1f3a0aad.zip | |
Extend CL highlights
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 2 | ||||
| -rw-r--r-- | queries/clojure/highlights.scm | 4 | ||||
| -rw-r--r-- | queries/commonlisp/highlights.scm | 67 | ||||
| -rw-r--r-- | queries/commonlisp/locals.scm | 24 |
5 files changed, 66 insertions, 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) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index d5aec787f..aa3665d2a 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -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', diff --git a/queries/clojure/highlights.scm b/queries/clojure/highlights.scm index 5789374f9..9e2668d9a 100644 --- a/queries/clojure/highlights.scm +++ b/queries/clojure/highlights.scm @@ -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/highlights.scm b/queries/commonlisp/highlights.scm index f3f7935a7..c56573cf3 100644 --- a/queries/commonlisp/highlights.scm +++ b/queries/commonlisp/highlights.scm @@ -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 diff --git a/queries/commonlisp/locals.scm b/queries/commonlisp/locals.scm index 859b9c701..d2159dfa1 100644 --- a/queries/commonlisp/locals.scm +++ b/queries/commonlisp/locals.scm @@ -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) |
