Add support for :intersection as lua version.
This will only accept globals which are present in every Lua version from 5.1-5.4. Using this for selflint currently fails, so let's fix that next.
This commit is contained in:
parent
93f6543e42
commit
78da9c2edc
@ -4,6 +4,7 @@
|
||||
|
||||
### Features
|
||||
* Settings file: `flsproject.fnl`. Settings are now editor agnostic.
|
||||
* Support `:intersection` as a Lua version; only includes globals present in every Lua.
|
||||
|
||||
### Bug Fixes
|
||||
* (set (. x y) z) wasn't being analyzed properly.
|
||||
|
||||
@ -22,9 +22,14 @@
|
||||
(when (not (. lua-versions version))
|
||||
(error (.. "fennel-ls doesn't know about lua version " version "\n"
|
||||
"The allowed versions are: "
|
||||
(fennel.view (doto (icollect [key (pairs lua-versions)] key) table.sort)))))
|
||||
(fennel.view (doto (icollect [key (pairs lua-versions)] key)
|
||||
table.sort)))))
|
||||
(. lua-versions version))
|
||||
|
||||
(set lua-versions.intersection
|
||||
(collect [k v (pairs lua-versions.lua51)]
|
||||
(if (. lua-versions.lua54 k) (values k v))))
|
||||
|
||||
(local libraries
|
||||
{:tic-80 (require :fennel-ls.docs.generated.tic80)})
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
(= e.range.end.character d.range.end.character))))
|
||||
i)))
|
||||
|
||||
(fn check [file-contents expected unexpected]
|
||||
(let [{: diagnostics} (create-client file-contents)]
|
||||
(fn check [file-contents expected unexpected ?opts]
|
||||
(let [{: diagnostics} (create-client file-contents nil ?opts)]
|
||||
(each [_ e (ipairs unexpected)]
|
||||
(let [i (find diagnostics e)]
|
||||
(faith.= nil i (.. "Lint matching " (view e) "\n"
|
||||
@ -120,12 +120,12 @@
|
||||
(print x +))"
|
||||
[{:message "expected condition and body"}
|
||||
{:message "tried to reference a special form without calling it"}] [])
|
||||
;; ;; recovers from missing condition (when)
|
||||
;; TODO: recovers from missing condition (when)
|
||||
;; (check "(let [x (when)]
|
||||
;; (print x +))"
|
||||
;; [{:message #($:find ".*macros.fnl:%d+: expected body")}
|
||||
;; {:message "tried to reference a special form without calling it"}] [])
|
||||
;; ;; recovers from missing body (when)
|
||||
;; TODO: recovers from missing body (when)
|
||||
;; (check "(let [x (when (< (+ 9 10) 21))]
|
||||
;; (print x +))"
|
||||
;; [;; {:message #($:find ".*macros.fnl:%d+: expected body")}
|
||||
@ -136,7 +136,21 @@
|
||||
{:message "tried to reference a special form without calling it"}] [])
|
||||
nil)
|
||||
|
||||
{: test-compile-error
|
||||
(fn test-lua-versions []
|
||||
(check "(local t (unpack []))"
|
||||
[] [{:message "unknown identifier: unpack"}]
|
||||
{:lua-version "lua51"})
|
||||
(check "(local t (unpack []))"
|
||||
[{:message "unknown identifier: unpack"}] []
|
||||
{:lua-version "lua52"})
|
||||
;; intersection should have only the things present in every version
|
||||
(check "(print (unpack [_VERSION]))"
|
||||
[{:message "unknown identifier: unpack"}]
|
||||
[{:message "unknown identifier: _VERSION"}]
|
||||
{:lua-version "intersection"}))
|
||||
|
||||
{: test-lua-versions
|
||||
: test-compile-error
|
||||
: test-parse-error
|
||||
: test-macro-error
|
||||
: test-multiple-errors}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
(set result.text text)
|
||||
result))
|
||||
|
||||
(fn create-client [file-contents ?opts]
|
||||
(fn create-client [file-contents ?opts ?config]
|
||||
;; TODO big function, split up
|
||||
(let [opts (or ?opts {})
|
||||
(provide-root-uri file-contents) (if (= (type file-contents) :table)
|
||||
@ -81,6 +81,8 @@
|
||||
:jsonrpc "2.0"
|
||||
:method "initialize"
|
||||
: params})
|
||||
_ (each [k v (pairs (or ?config []))]
|
||||
(tset server.configuration k v))
|
||||
[{:params {: diagnostics}}] (client:open-file! uri text)]
|
||||
{: client
|
||||
: server
|
||||
|
||||
Loading…
Reference in New Issue
Block a user