";; fennel-ls: macro-file" for macro files
Temporary quick fix for editing macro files, since I've been doing a lot of work in macro files recently. I hope that in the future there will be better ways to do this than magic comments. I think there are probably much better heuristics that could be used.
This commit is contained in:
parent
3eeebdbf11
commit
06d3787f66
@ -3,6 +3,8 @@ A language server for fennel-ls.
|
|||||||
Uses static analysis, and doesn't actually run your code, which makes it perfect for analyzing your (os.execute "rm -rf") code.
|
Uses static analysis, and doesn't actually run your code, which makes it perfect for analyzing your (os.execute "rm -rf") code.
|
||||||
If you want live analysis of your code as it runs, consider using a REPL.
|
If you want live analysis of your code as it runs, consider using a REPL.
|
||||||
|
|
||||||
|
For now, you can ask fennel-ls to treat your file as a macro file if the very first characters in the file exactly match `;; fennel-ls: macro-file`. Expect this to break at some point in the future when I come up with a better way to specify which files are meant to be macro files.
|
||||||
|
|
||||||
Features / To Do List / Things I would enjoy patches for:
|
Features / To Do List / Things I would enjoy patches for:
|
||||||
([X] = complete, [ ] = planned)
|
([X] = complete, [ ] = planned)
|
||||||
|
|
||||||
|
|||||||
@ -90,10 +90,10 @@ later by fennel-ls.language to answer requests from the client."
|
|||||||
(let [def {:binding name :definition ast}]
|
(let [def {:binding name :definition ast}]
|
||||||
(if (multisym? name)
|
(if (multisym? name)
|
||||||
(match (utils.multi-sym-split name)
|
(match (utils.multi-sym-split name)
|
||||||
[ref field nil]
|
[ref field nil] ;; TODO more powerful function name metadata
|
||||||
(let [target (find-definition ref scope)]
|
(let [target (find-definition ref scope)]
|
||||||
(set target.fields (or target.fields {}))
|
(set target.fields (or target.fields {}))
|
||||||
(tset target.fields field def))) ;; TODO more complicated function name metadata
|
(tset target.fields field def)))
|
||||||
|
|
||||||
(tset (. definitions-by-scope scope)
|
(tset (. definitions-by-scope scope)
|
||||||
(tostring name)
|
(tostring name)
|
||||||
@ -106,7 +106,7 @@ later by fennel-ls.language to answer requests from the client."
|
|||||||
(where [_fn args] (fennel.sequence? args)) args
|
(where [_fn args] (fennel.sequence? args)) args
|
||||||
(where [_fn _name args] (fennel.sequence? args)) args))
|
(where [_fn _name args] (fennel.sequence? args)) args))
|
||||||
(each [_ argument (ipairs args)]
|
(each [_ argument (ipairs args)]
|
||||||
(define nil argument scope))) ;; we say function arguments are set to nil
|
(define (sym :nil) argument scope))) ;; we say function arguments are set to nil
|
||||||
|
|
||||||
(λ define-function [ast scope]
|
(λ define-function [ast scope]
|
||||||
;; handle the definitions of a function
|
;; handle the definitions of a function
|
||||||
@ -172,7 +172,8 @@ later by fennel-ls.language to answer requests from the client."
|
|||||||
|
|
||||||
;; TODO clean up this code. It's awful now that there is error handling
|
;; TODO clean up this code. It's awful now that there is error handling
|
||||||
(let
|
(let
|
||||||
[plugin
|
[macro-file? (= (: file.text :sub 1 24) ";; fennel-ls: macro-file")
|
||||||
|
plugin
|
||||||
{:name "fennel-ls"
|
{:name "fennel-ls"
|
||||||
:versions ["1.3.0"]
|
:versions ["1.3.0"]
|
||||||
:symbol-to-expression reference
|
:symbol-to-expression reference
|
||||||
@ -190,7 +191,10 @@ later by fennel-ls.language to answer requests from the client."
|
|||||||
: scope}
|
: scope}
|
||||||
parser (partial pcall (fennel.parser file.text file.uri opts))
|
parser (partial pcall (fennel.parser file.text file.uri opts))
|
||||||
ast (icollect [ok ok2 ast parser &until (not (and ok ok2))] ast)
|
ast (icollect [ok ok2 ast parser &until (not (and ok ok2))] ast)
|
||||||
_compile-output (icollect [_i form (ipairs ast)]
|
_compile-output (icollect [_i form (ipairs
|
||||||
|
(if macro-file? [(fennel.list (sym :eval-compiler)
|
||||||
|
((or table.unpack _G.unpack) ast))]
|
||||||
|
ast))]
|
||||||
(match (pcall fennel.compile form opts)
|
(match (pcall fennel.compile form opts)
|
||||||
(where (nil err) (not= err "__NOT_AN_ERROR"))
|
(where (nil err) (not= err "__NOT_AN_ERROR"))
|
||||||
(table.insert diagnostics
|
(table.insert diagnostics
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user