Add --help and --version flags

This commit is contained in:
Michele Campeotto 2025-03-07 10:29:57 +01:00 committed by Phil Hagelberg
parent e229f93fc1
commit 3200483011
4 changed files with 25 additions and 4 deletions

View File

@ -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"`.

View File

@ -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)

View File

@ -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)

View File

@ -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