fennel-language-server
fennel-language-server copied to clipboard
Add support for comment special form
Hi! Thanks for this project - I've been using it daily for a couple of weeks now and it's been incredibly helpful.
I took a stab at adding support for the (comment ...)
special form. I was originally going to treat it the same way as syntax comments (the fennel compiler collects the body into a string, see here), but after starting I realised that in the context of a language server you might want to provide some IDE support within comments.
The usecase I have in mind is "REPL comments" that let you test code during interactive development:
(fn my-function [x] ...)
(comment
(local a :a)
(my-function a)) ;; should ideally provide completions for both `a` and `my-function`
Exactly how that should work is a bit unclear though. As a first draft, I ended up with something like:
-
(comment <body>)
introduces a new scope. This prevents local symbols defined inside the comment from leaking outside, but enables IDE support within the comment body. (TODO: globals may still leak) - The comment form suppresses all errors inside the body. This is to avoid conflicts with the more general usecase, i.e.
(comment this is just a comment)
What do you think?
Related: #1