Change format of --check output to look like compiler errors.
They'll look like this now: src/fennel-ls/compiler.fnl:123:15 unused definition: ?definition src/fennel-ls/compiler.fnl:5:52 unused definition: view src/fennel-ls/compiler.fnl:197:13 unused definition: i src/fennel-ls/compiler.fnl:271:25 unnecessary : call; use multisym src/fennel-ls/handlers.fnl:14:10 unused definition: view src/fennel-ls/handlers.fnl:170:3 unused definition: create-completion-item src/fennel-ls/language.fnl:187:3 unused definition: does-not-contain? src/fennel-ls/language.fnl:221:28 unused definition: i src/fennel-ls/language.fnl:4:51 unused definition: view src/fennel-ls/language.fnl:171:3 unused definition: past? src/fennel-ls/language.fnl:208:23 unused definition: i src/fennel-ls/searcher.fnl:12:4 unnecessary : call; use multisym src/fennel-ls/state.fnl:23:3 unused definition: get-by-path src/fennel-ls/state.fnl:12:2 unnecessary : call; use multisym src/fennel-ls/utils.fnl:15:16 unused definition: i This has the advantage of making it so that existing tooling will work with it; for example, Emacs can hyperlink these and jump right to the code causing the issue. Use 1-indexed line numbers instead of 0-indexing because Emacs and Vim expect this.
This commit is contained in:
parent
4a121f70b0
commit
765b3d784f
@ -13,9 +13,11 @@
|
||||
: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)))))
|
||||
(each [_ {: message :range {: start}} (ipairs file.diagnostics)]
|
||||
(print (: "%s:%s:%s %s" :format filename
|
||||
;; LSP line numbers are zero-indexed, but Emacs and Vim both use
|
||||
;; 1-indexing for this.
|
||||
(+ (or start.line 0) 1) (or start.character "?") message)))))
|
||||
|
||||
(λ main-loop [in out]
|
||||
(local send (partial json-rpc.write out))
|
||||
@ -27,7 +29,6 @@
|
||||
(λ main []
|
||||
(case arg
|
||||
["--check" & filenames] (each [_ filename (ipairs filenames)]
|
||||
(print "Checking" filename)
|
||||
(check filename))
|
||||
(where (or ["--server"] [nil])) (main-loop (io.input)
|
||||
(io.output))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user