diff --git a/changelog.md b/changelog.md index 7ad3524..1d15b74 100644 --- a/changelog.md +++ b/changelog.md @@ -4,7 +4,9 @@ ### Features -* Support highlighting references to the symbol under the cursor in the current scope. +* Add --help and --version command line flags. +* Support providing improved completion kinds to clients. +* Support highlighting references to the symbol under the cursor in the current file. * Support loading external docsets from disk. * Extract TIC-80 docs to external docset. * Support `:lua-version` settings like `"lua5.4"` rather than requiring `"lua54"`. diff --git a/src/fennel-ls.fnl b/src/fennel-ls.fnl index beb4986..bbafe4b 100644 --- a/src/fennel-ls.fnl +++ b/src/fennel-ls.fnl @@ -51,12 +51,28 @@ (let [msg (json-rpc.read in)] (dispatch.handle server send msg)))) +(local {: version} (require :fennel-ls.utils)) +(local help "Usage: fennel-ls [FLAG] [FILES] + +Run fennel-ls, the Fennel language server and linter. + + --lint FILES : Run the linter on the provided files + a single dash (-) can be used to read from stdin + --server : Start the language server (stdio mode only) + optional, this is the default with no arguments + + --help : Display this text + --version : Show version") + (λ main [] (case arg + ["--help"] (print help) + ["--version"] (print version) ["--lint" & filenames] (lint filenames) (where (or ["--server"] [nil])) (main-loop (io.input) (io.output)) - _args (do (io.stderr:write "USAGE: fennel-ls [--lint file] [--server]\n") + _args (do (io.stderr:write help) + (io.stderr:write "\n") (os.exit 1)))) (main) diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index 6cea6f3..b9f7ca9 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -78,7 +78,7 @@ Every time the client sends a message, it gets handled by a function in the corr ;; :willDelete nil}} ;; :experimental nil) {: capabilities - :serverInfo {:name "fennel-ls" :version "0.1.0"}})) + :serverInfo {:name "fennel-ls" :version utils.version}})) (λ requests.textDocument/definition [server _send {: position :textDocument {: uri}}] (let [file (files.get-by-uri server uri) diff --git a/src/fennel-ls/utils.fnl b/src/fennel-ls/utils.fnl index c99c288..eff3787 100644 --- a/src/fennel-ls/utils.fnl +++ b/src/fennel-ls/utils.fnl @@ -5,6 +5,8 @@ These functions are all pure functions, which makes me happy." (local fennel (require :fennel)) +(local version :0.2.0-dev) + (λ next-line [str ?from] "Find the start of the next line from a given byte offset, or from the start of the string." (let [from (or ?from 1)] @@ -209,7 +211,8 @@ WARNING: this is only used in the test code, not in the real language server" (fn find [t x ?k] (match (next t ?k) (k x) k (k y_) (find t x k))) -{: uri->path +{: version + : uri->path : path->uri : pos->position : byte->position