Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fhs committed Oct 8, 2019
1 parent ca2d338 commit e966d73
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 29 deletions.
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ acme window. When `Put` is executed in an acme window, `acme-lsp`
also organizes import paths in the window and formats it.

Currently, `acme-lsp` has been tested with
[gopls](https://godoc.org/golang.org/x/tools/cmd/gopls),
[gopls](https://github.com/golang/tools/tree/master/gopls),
[go-langserver](https://github.com/sourcegraph/go-langserver) and
[pyls](https://github.com/palantir/python-language-server). Please report
incompatibilities with those or other servers.
Expand All @@ -38,7 +38,7 @@ First install the latest release of gopls:

Start acme-lsp like this:

acme-lsp -server '\.go$:gopls' -workspaces /path/to/mod1:/path/to/mod2
acme-lsp -server '([/\\]go\.mod)|([/\\]go\.sum)|(\.go)$:gopls serve' -workspaces /path/to/mod1:/path/to/mod2

where mod1 and mod2 are module directories with a `go.mod` file.
The set of workspace directories can be changed at runtime
Expand All @@ -47,9 +47,36 @@ by using the `L ws+` and `L ws-` sub-commands.
When `Put` is executed in an acme window editing `.go` file, acme-lsp
will update import paths and gofmt the window buffer if needed. It also
enables commands like `L def` (jump to defenition), `L refs` (list of
references), etc. within acme. Note: any output from these commands are
printed to stdout by `acme-lsp`, so it's beneficial to start `acme-lsp` from
within acme, where the output is written to `+Errors` window.
references), etc. within acme.

If you want to change `gopls`
[settings](https://github.com/golang/tools/blob/master/gopls/doc/settings.md),
you can create a configuration file at
`UserConfigDir/acme-lsp/config.toml` (the `-showconfig` flag prints
the exact location) and then run `acme-lsp` without any flags. Example
config file:
```toml
WorkspaceDirectories = [
"/path/to/mod1",
"/path/to/mod2",
]
FormatOnPut = true
CodeActionsOnPut = ["source.organizeImports"]

[Servers]
[Servers.gopls]
Command = ["gopls", "serve", "-rpc.trace"]
StderrFile = "gopls.stderr.log"
LogFile = "gopls.log"

# These settings gets passed to gopls
[Servers.gopls.Options]
hoverKind = "FullDocumentation"

[[FilenameHandlers]]
Pattern = '([/\\]go\.mod)|([/\\]go\.sum)|(\.go)$'
ServerKey = "gopls"
```

## Hints & Tips

Expand All @@ -59,7 +86,7 @@ in the LSP server.

* Create scripts like `Ldef`, `Lrefs`, `Ltype`, etc., so that you can
easily execute those commands with a single middle click:
```
```sh
for cmd in comp def fmt hov refs rn sig syms type assist ws ws+ ws-
do
cat > L${cmd} <<EOF
Expand Down
3 changes: 1 addition & 2 deletions cmd/L/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ proxy server acme-lsp.
L is usually run from within the acme text editor, where $winid
environment variable is set to the ID of currently focused window.
It sends this ID to acme-lsp, which uses it to compute the context for
LSP commands. Note: L merely asks acme-lsp to run an LSP command--any
output of the command is printed to stdout by acme-lsp, not L.
LSP commands.
If L is run outside of acme (therefore $winid is not set), L will
attempt to find the focused window ID by connecting to acmefocused
Expand Down
3 changes: 1 addition & 2 deletions cmd/L/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ proxy server acme-lsp.
L is usually run from within the acme text editor, where $winid
environment variable is set to the ID of currently focused window.
It sends this ID to acme-lsp, which uses it to compute the context for
LSP commands. Note: L merely asks acme-lsp to run an LSP command--any
output of the command is printed to stdout by acme-lsp, not L.
LSP commands.
If L is run outside of acme (therefore $winid is not set), L will
attempt to find the focused window ID by connecting to acmefocused
Expand Down
11 changes: 9 additions & 2 deletions cmd/Lone/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ List of sub-commands:
send the location to the plumber.
fmt
Format current window buffer.
Organize imports and format current window buffer.
hov
Show more information about the identifier under the cursor
Expand Down Expand Up @@ -61,12 +61,19 @@ List of sub-commands:
Note: this is a very experimental feature, and may not
be very useful in practice.
-acme.addr string
address where acme is serving 9P file system (default "/tmp/ns.fhs.:0/acme")
-acme.net string
network where acme is serving 9P file system (default "unix")
-debug
turn on debugging prints
turn on debugging prints (deprecated: use -v)
-dial value
language server address for filename match (e.g. '\.go$:localhost:4389')
-server value
language server command for filename match (e.g. '\.go$:gopls')
-showconfig
show configuration values and exit
-v Verbose output
-workspaces string
colon-separated list of initial workspace directories
*/
Expand Down
35 changes: 26 additions & 9 deletions cmd/acme-lsp/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,45 @@ Acme-lsp depends on one or more language servers already being
installed in the system. See this page of a list of language servers:
https://microsoft.github.io/language-server-protocol/implementors/servers/.
Acme-lsp executes or connects to a set of LSP servers specified using the
-server or -dial flags. It then listens for messages sent by the L command
to unix domain socket located at $NAMESPACE/acme-lsp.rpc. The messages
direct acme-lsp to run commands on the LSP servers and apply/show the
results in acme. The communication protocol used here is jsonrpc2 (same
as LSP) but it's an implementation detail that is subject to change.
Acme-lsp is optionally configured using a TOML-based configuration file
located at UserConfigDir/acme-lsp/config.toml (the -showconfig flag
prints the exact location). The command line flags will override the
configuration values. The configuration options are described here:
https://godoc.org/github.com/fhs/acme-lsp/internal/lsp/acmelsp/config#File
Acme-lsp executes or connects to a set of LSP servers described in the
configuration file or in the -server or -dial flags. It then listens for
messages sent by the L command, which direct acme-lsp to run commands
on the LSP servers and apply/show the results in acme. The communication
protocol used here is an implementation detail that is subject to change.
Acme-lsp watches for files created (New), loaded (Get), saved (Put), or
deleted (Del) in acme, and tells the LSP server about these changes. The
LSP server in turn responds by sending diagnostics information (compiler
errors, lint errors, etc.) which are shown in a "/LSP/Diagnostics" window.
Also, when Put is executed in an acme window, acme-lsp organizes import
paths in the window and formats it.
Also, when Put is executed in an acme window, acme-lsp will organize
import paths in the window and format it by default. This behavior can
be changed by the FormatOnPut and CodeActionsOnPut configuration options.
Usage: acme-lsp [flags]
-acme.addr string
address where acme is serving 9P file system (default "/tmp/ns.fhs.:0/acme")
-acme.net string
network where acme is serving 9P file system (default "unix")
-debug
turn on debugging prints
turn on debugging prints (deprecated: use -v)
-dial value
language server address for filename match (e.g. '\.go$:localhost:4389')
-proxy.addr string
address used for communication between acme-lsp and L (default "/tmp/ns.fhs.:0/acme-lsp.rpc")
-proxy.net string
network used for communication between acme-lsp and L (default "unix")
-server value
language server command for filename match (e.g. '\.go$:gopls')
-showconfig
show configuration values and exit
-v Verbose output
-workspaces string
colon-separated list of initial workspace directories
*/
Expand Down
22 changes: 14 additions & 8 deletions cmd/acme-lsp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ Acme-lsp depends on one or more language servers already being
installed in the system. See this page of a list of language servers:
https://microsoft.github.io/language-server-protocol/implementors/servers/.
Acme-lsp executes or connects to a set of LSP servers specified using the
-server or -dial flags. It then listens for messages sent by the L command
to unix domain socket located at $NAMESPACE/acme-lsp.rpc. The messages
direct acme-lsp to run commands on the LSP servers and apply/show the
results in acme. The communication protocol used here is jsonrpc2 (same
as LSP) but it's an implementation detail that is subject to change.
Acme-lsp is optionally configured using a TOML-based configuration file
located at UserConfigDir/acme-lsp/config.toml (the -showconfig flag
prints the exact location). The command line flags will override the
configuration values. The configuration options are described here:
https://godoc.org/github.com/fhs/acme-lsp/internal/lsp/acmelsp/config#File
Acme-lsp executes or connects to a set of LSP servers described in the
configuration file or in the -server or -dial flags. It then listens for
messages sent by the L command, which direct acme-lsp to run commands
on the LSP servers and apply/show the results in acme. The communication
protocol used here is an implementation detail that is subject to change.
Acme-lsp watches for files created (New), loaded (Get), saved (Put), or
deleted (Del) in acme, and tells the LSP server about these changes. The
LSP server in turn responds by sending diagnostics information (compiler
errors, lint errors, etc.) which are shown in a "/LSP/Diagnostics" window.
Also, when Put is executed in an acme window, acme-lsp organizes import
paths in the window and formats it.
Also, when Put is executed in an acme window, acme-lsp will organize
import paths in the window and format it by default. This behavior can
be changed by the FormatOnPut and CodeActionsOnPut configuration options.
Usage: acme-lsp [flags]
`
Expand Down

0 comments on commit e966d73

Please sign in to comment.