diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index e718b15..a7e9fb8 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -23,6 +23,7 @@ identifiers are declared / referenced in which places." ;; words surrounded by - are symbols, ;; because fennel doesn't allow 'require in a runtime file (local -require- (sym :require)) +(local -include- (sym :include)) (local -fn- (sym :fn)) (local -lambda- (sym :lambda)) (local -λ- (sym :λ)) @@ -224,7 +225,8 @@ identifiers are declared / referenced in which places." ;; TODO check if hashfn needs to be here (where (or [(= -fn-)] [(= -lambda-)] [(= -λ-)])) (define-function ast scope) - (where [(= -require-) _modname]) + (where (or [(= -require-) _modname] + [(= -include-) _modname])) (tset require-calls ast true) ;; fennel expands multisym calls into the `:` special, so we need to reference the symbol while we still can (where [sym] (multisym? sym) (: (tostring sym) :find ":")) diff --git a/src/fennel-ls/language.fnl b/src/fennel-ls/language.fnl index b9238cf..9eaedb9 100644 --- a/src/fennel-ls/language.fnl +++ b/src/fennel-ls/language.fnl @@ -119,7 +119,7 @@ a user-written file. (if (< multival len) (search-val self file (. call (+ 1 multival)) stack opts) (search-multival self file (. call (+ len 1)) stack (+ multival (- len) 1) opts))) - :require + (where (or :require :include)) (let [mod (. call 2)] (if (= multival 1) (when (= :string (type mod)) diff --git a/test/diagnostic.fnl b/test/diagnostic.fnl index 9087a15..ef4e3b0 100644 --- a/test/diagnostic.fnl +++ b/test/diagnostic.fnl @@ -197,6 +197,8 @@ ;; steal as many lints as possible from cargo ;; unnecessary parens around single multival destructure +;; unused variable, when a function binding is only used in its body, and the function value is discarded + {: test-compile-error : test-parse-error : test-macro-error @@ -204,6 +206,7 @@ : test-unused : test-ampersand : test-no-warnings + : test-unknown-module-field : test-unnecessary-colon : test-unset-var : test-unpack-into-op diff --git a/test/goto-definition.fnl b/test/goto-definition.fnl index 894376d..d2361cf 100644 --- a/test/goto-definition.fnl +++ b/test/goto-definition.fnl @@ -160,13 +160,12 @@ :main.fnl "(local {: target} (require| :foo)) (target)"}) - ;; TODO make it work on include - ; (check - ; {:foo.fnl "(fn target [] - ; nil) - ; =={: target}==" - ; :main.fnl "(local {: target} (include| :foo)) - ; (target)"})) + (check + {:foo.fnl "(fn target [] + nil) + =={: target}==" + :main.fnl "(local {: target} (includ|e :foo)) + (target)"}) ;; TODO fix goto-definition on the module name string itself ; (check @@ -189,15 +188,13 @@ (fn test-no-crash [] -;; TODO convert the rest of goto - -; ;; (it "can go to a destructured function argument") (check "(macro cool [a b] `(let [,b 10] ,a))\n(cool |x ==x==)") (check "(macro cool [a b] `(let [,b 10] ,a))\n(cool x x|)") (check "|#$...")) +; ;; (it "can go to a destructured function argument") ; ;; (it "can go through more than one file") ; ;; (it "will give up instead of freezing on recursive requires") ; ;; (it "will give up instead of freezing on recursive tables constructed with (set)")