acme-lsp

module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2023 License: MIT

README

GitHub Actions Status Go Reference Go Report Card

acme-lsp

Language Server Protocol tools for acme text editor.

The main tool is acme-lsp, which listens for commands from the L command. It also 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 an 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, go-langserver and pyls. Please report incompatibilities with those or other servers.

Installation

Install the latest release:

GO111MODULE=on go install github.com/fhs/acme-lsp/cmd/acme-lsp@latest
GO111MODULE=on go install github.com/fhs/acme-lsp/cmd/L@latest

gopls

First install the latest release of gopls:

GO111MODULE=on go install golang.org/x/tools/gopls@latest

Start acme-lsp like this:

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 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. The L assist command opens a window where completion, hover, or signature help output is shown for the current cursor position in the .go file being edited.

If you want to change gopls settings, 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:

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$"
  LanguageID = "go.mod"
  ServerKey = "gopls"

[[FilenameHandlers]]
  Pattern = "[/\\\\]go\\.sum$"
  LanguageID = "go.sum"
  ServerKey = "gopls"

[[FilenameHandlers]]
  Pattern = "\\.go$"
  LanguageID = "go"
  ServerKey = "gopls"

Hints & Tips

  • If a file gets out of sync in the LSP server (e.g. because you edited the file outside of acme), executing Get on the file will update it in the LSP server.

  • Create scripts like Ldef, Lrefs, Ltype, etc., so that you can easily execute those commands with a single middle click:

for(cmd in comp def fmt hov impls refs rn sig syms type assist ws ws+ ws-){
	> L^$cmd {
		echo '#!/bin/rc'
		echo exec L $cmd '$*'
	}
	chmod +x L^$cmd
}
  • Create custom keybindings that allow you to do completion (L comp -e) and show signature help (L sig) while you're typing. This can be achieved by using a general keybinding daemon (e.g. xbindkeys in X11) and running acmefocused.

See also

Directories

Path Synopsis
cmd
L
The program L sends messages to the Language Server Protocol proxy server acme-lsp.
The program L sends messages to the Language Server Protocol proxy server acme-lsp.
Lone
The program Lone is a standalone client for the acme text editor that interacts with a Language Server.
The program Lone is a standalone client for the acme text editor that interacts with a Language Server.
acme-lsp
The program acme-lsp is a client for the acme text editor that acts as a proxy for a set of Language Server Protocol servers.
The program acme-lsp is a client for the acme text editor that acts as a proxy for a set of Language Server Protocol servers.
acmefocused
Program acmefocused is a server that tells acme's focused window ID to clients.
Program acmefocused is a server that tells acme's focused window ID to clients.
internal
acme
Package acme is a simple interface for interacting with acme windows.
Package acme is a simple interface for interacting with acme windows.
acmeutil
Package acmeutil implements acme utility functions.
Package acmeutil implements acme utility functions.
gomod
Package gomod implements Go module related functions.
Package gomod implements Go module related functions.
lsp
Package lsp contains Language Server Protocol utility functions.
Package lsp contains Language Server Protocol utility functions.
lsp/acmelsp
Package acmelsp implements the core of acme-lsp commands.
Package acmelsp implements the core of acme-lsp commands.
lsp/acmelsp/config
Package config defines LSP tools configuration.
Package config defines LSP tools configuration.
lsp/cmd
Pakcage cmd contains utlity functions that help implement lsp related commands.
Pakcage cmd contains utlity functions that help implement lsp related commands.
lsp/proxy
Package proxy implements the protocol between acme-lsp and L commands.
Package proxy implements the protocol between acme-lsp and L commands.
lsp/text
Package text implements text editing helper routines for LSP.
Package text implements text editing helper routines for LSP.
p9service
Pakcage p9service help implement a plan9 service.
Pakcage p9service help implement a plan9 service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL