Basic CommonLisp Treesitter Parsing #1730
Encryptoid
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
I do think this could work for highlighting/indenting/lsp. But whether it's needed is another question. Could be a fun project. Here is a command for testing, to put the current buffer to treesitter: (define-command treesitter-current-buffer () ()
(let* ((lines (uiop:read-file-string (lem/buffer/internal::buffer-%filename (current-buffer))))
(ts-lines (cl-tree-sitter:parse-string :common-lisp lines)))
(lem:message "TS LINES :: ~a" ts-lines))) Another example: ((start-col start-line) (end-col) (end-line)) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I was messing around with CommonLisp Treesitter in Lem. I just got the very basics working, reading some lisp code. I will probably have another look in future, but sharing for now in case anyone else wants to try it.
There isn't any official support for CL, both the parser and the grammar are taken from githubs.
Steps
Below are the steps needed to parse a basic lisp string:
Install CL Treesitter Parser
CommonLisp Parser
This will allow you to call any treesitter parser via CommonLisp(c, python, rust, etc.)
Install CL Treesitter Grammar
CommonLisp Grammar
This is the tricky bit. So if you download the above and
make
it, it will produce a file:libtree-sitter-commonlisp.so
. You will have to rename it totree_sitter_commonlisp.so
. I have no idea why this is, and if you don't, it complains thatlibtree_sitter_commonlisp
is missing(not the right name either?). I probably didn't read something.tree_sitter_commonlisp.so
worked for me.The same is true for the other language I tried, C. The make produced
libtree-sitter-c.so
, which had to be renamed totree-sitter-c.so
to work with the CL Parser.You might also need this:
Parse CommonLisp Code
Run this code in Lem to register the language,
Then you will get back the treesitter grammar for this. Someone might be interested in trying out certain lisp code in it and understanding the result. Here is the result from the above, you can see the list, and the number literals:
Beta Was this translation helpful? Give feedback.
All reactions