Support --check for batch mode diagnostics.
Mostly taken from the separate fennel-lint.fnl file.
This commit is contained in:
parent
c8f9b71057
commit
802ff4ab17
@ -39,6 +39,14 @@ Generally this involves somehow configuring this information:
|
|||||||
|
|
||||||
If you get it working in any other environments, I'd love to know! It would be great to have instructions on how to set up other editors!
|
If you get it working in any other environments, I'd love to know! It would be great to have instructions on how to set up other editors!
|
||||||
|
|
||||||
|
## Batch mode
|
||||||
|
|
||||||
|
You can gather diagnostics without connecting your editor:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fennel-ls --check my-file.fnl f2.fnl # prints diagnostics for the files given
|
||||||
|
```
|
||||||
|
|
||||||
# Default Settings
|
# Default Settings
|
||||||
|
|
||||||
fennel-ls can be configured over LSP. Any setting that's not provided will be filled in with the defaults, which means that `{}` will be a valid configuration with default settings. You can provide different settings in the same shape as the default settings in order to override the defaults.
|
fennel-ls can be configured over LSP. Any setting that's not provided will be filled in with the defaults, which means that `{}` will be a valid configuration with default settings. You can provide different settings in the same shape as the default settings in order to override the defaults.
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
(local dispatch (require :fennel-ls.dispatch))
|
|
||||||
(local state (require :fennel-ls.state))
|
|
||||||
(local diagnostics (require :fennel-ls.diagnostics))
|
|
||||||
(local {: view} (require :fennel))
|
|
||||||
|
|
||||||
;; set up the state of fennel-ls into the `server` table
|
|
||||||
(local server {})
|
|
||||||
(dispatch.handle* server {:id 1
|
|
||||||
:jsonrpc "2.0"
|
|
||||||
:method "initialize"
|
|
||||||
:params {:capabilities {}
|
|
||||||
:clientInfo {:name "Neovim" :version "0.7.2"}
|
|
||||||
:initializationOptions {}
|
|
||||||
:rootPath "."
|
|
||||||
:rootUri "file://."
|
|
||||||
:trace "off"
|
|
||||||
:workspaceFolders [{:name "."
|
|
||||||
:uri "file://."}]}})
|
|
||||||
|
|
||||||
;; open the file specified by (. arg 1) from the command line
|
|
||||||
(local file (state.get-by-uri server (.. "file://" (. arg 1))))
|
|
||||||
;; run diagnostics to populate file.diagnostics field
|
|
||||||
(diagnostics.check server file)
|
|
||||||
;; print the output
|
|
||||||
(each [_ v (ipairs file.diagnostics)]
|
|
||||||
(print (view v)))
|
|
||||||
@ -1,5 +1,22 @@
|
|||||||
(local dispatch (require :fennel-ls.dispatch))
|
(local dispatch (require :fennel-ls.dispatch))
|
||||||
(local json-rpc (require :fennel-ls.json-rpc))
|
(local json-rpc (require :fennel-ls.json-rpc))
|
||||||
|
(local state (require :fennel-ls.state))
|
||||||
|
(local diagnostics (require :fennel-ls.diagnostics))
|
||||||
|
(local {: view} (require :fennel))
|
||||||
|
|
||||||
|
(λ check [filename]
|
||||||
|
(let [server (doto {}
|
||||||
|
(dispatch.handle* {:id 1
|
||||||
|
:jsonrpc "2.0"
|
||||||
|
:method "initialize"
|
||||||
|
:params {:capabilities {}
|
||||||
|
:clientInfo {:name "fennel-ls"}
|
||||||
|
:rootUri "file://"}}))
|
||||||
|
file (state.get-by-uri server (.. "file://" filename))]
|
||||||
|
(diagnostics.check server file)
|
||||||
|
(each [_ v (ipairs file.diagnostics)]
|
||||||
|
;; perhaps nicer formatting in the future?
|
||||||
|
(print (view v)))))
|
||||||
|
|
||||||
(λ main-loop [in out]
|
(λ main-loop [in out]
|
||||||
(local send (partial json-rpc.write out))
|
(local send (partial json-rpc.write out))
|
||||||
@ -9,8 +26,13 @@
|
|||||||
(dispatch.handle state send msg))))
|
(dispatch.handle state send msg))))
|
||||||
|
|
||||||
(λ main []
|
(λ main []
|
||||||
(main-loop
|
(case arg
|
||||||
(io.input)
|
["--check" & filenames] (each [_ filename (ipairs filenames)]
|
||||||
(io.output)))
|
(print "Checking" filename)
|
||||||
|
(check filename))
|
||||||
|
(where (or ["--server"] [nil])) (main-loop (io.input)
|
||||||
|
(io.output))
|
||||||
|
_args (do (io.stderr:write "USAGE: fennel-ls [--check file] [--server]\n")
|
||||||
|
(os.exit 1))))
|
||||||
|
|
||||||
(main)
|
(main)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user