9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

Config not read #49

Closed ebengt closed 2 years ago

ebengt commented 2 years ago

Greetings, How should I find out why the config file is not read? It is such a basic thing that it is unlikely to be acme-lsp that is at fault. However, how do I find out what I am doing wrong?

$ acme-lsp  
2022/02/06 14:20:13 no servers found in the configuration file or command line flags

$ acme-lsp -showconfig
# Configuration file location: /home/bengt/.config/acme-lsp/config.toml

ProxyNetwork = "unix"
ProxyAddress = "/tmp/ns.bengt.:0/acme-lsp.rpc"
AcmeNetwork = "unix"
AcmeAddress = "/tmp/ns.bengt.:0/acme"
RootDirectory = "/"
HideDiagnostics = false
FormatOnPut = true
RPCTrace = false
FilenameHandlers = []

[Servers]
  [Servers.gopls]
    Command = ["gopls", "serve", "-rpc.trace"]
    Address = ""
    StderrFile = "/home/bengt/.cache/acme-lsp/gopls.stderr.log"
    LogFile = "/home/bengt/.cache/acme-lsp/gopls.log"
    [Servers.gopls.Options]
      hoverKind = "FullDocumentation"

Config file (renamed to work with attaching file, it is called config.toml) config.txt

fhs commented 2 years ago

The error is misleading. You need to add some filename handlers, like this:

[[FilenameHandlers]]
  Pattern = "\\.go$"
  ServerKey = "gopls"
ebengt commented 2 years ago

Thank you. Yes, it might have been helpful if the error message had been about filename handlers. Now that I know, I can see from the example of how to start without config file, that file name handlers are needed.

ebengt commented 2 years ago

Is the format of the config documented? I would like to add the .mod and .sum files from the cli example.

fhs commented 2 years ago

The config file is defined by this struct: https://pkg.go.dev/github.com/fhs/acme-lsp@v0.10.0/internal/lsp/acmelsp/config#File The README has an example of how to add go.mod and go.sum: https://github.com/fhs/acme-lsp#gopls

ebengt commented 2 years ago

Thank you very much. I apologise for missing that in the README.