j4ng5y / zed_golangci_lint

Zed Extension for Golangci Lint
5 stars 7 forks source link

no language server found matching 'golangci-lint-langserver' #2

Open xanderim opened 3 months ago

xanderim commented 3 months ago

Hi @j4ng5y, thanks for the extension. From my understanding this extension launches "golangci-lint-langserver" so Zed can utilize it for linting. Unfortunately, due to my limited knowledge I couldn't make it work. Can you please give a quick look and point me into the right direction? Thanks.

image
weastur commented 3 months ago

Fixed in #4

xanderim commented 3 months ago

thanks @weastur, I've tried following the steps in your commit but I have the same problem

image
weastur commented 3 months ago

@xanderim Unfortunately, there are also at lease two issues, which I fixed in #3 and #6. As a quick workaround you can:

  1. Install golangci-lint-langserver manually (for example, on macOS this could be done with brew install golangci-lint-langserver)
  2. Find the extensions directory on your system. Again, for macOS this is $HOME/Library/Application\ Support/Zed/extensions/, I'm not sure about other OS's
  3. Find extensions->golangci-lint->manifest->language_servers->golangci-lint->languages, and make the array equal to `["Go"]. So you get something like this
    {
    "extensions": {
    "golangci-lint": {
      "manifest": {
        "id": "golangci-lint",
        "name": "Golangci-Lint",
        "version": "0.1.0",
        "schema_version": 1,
        "description": "Golangci Lint support.",
        "repository": "https://github.com/j4ng5y/zed_golangci_lint",
        "authors": [
          "Jordan Gregory <jordan@j4ng5y.dev>"
        ],
        "lib": {
          "kind": "Rust",
          "version": null
        },
        "themes": [],
        "languages": [],
        "grammars": {},
        "language_servers": {
          "golangci-lint": {
            "language": "Golangci Lint",
            "languages": ["Go"],
            "language_ids": {},
            "code_action_kinds": null
          }
        },
        "slash_commands": {},
        "indexed_docs_providers": {},
        "snippets": null
      },
    ..............

But this file might be rewritten by Zed on any extension update/install etc.

jseiser commented 3 months ago

Even with the above changes, I get the same error. I am on linux, not a mac though

1.

❯ which golangci-lint-langserver
/home/justin/go/bin/golangci-lint-langserver

2.

  "lsp": {
    "zls": {
      "binary": {
        "path": "/home/justin/.local/bin/zls"
      }
    },
    "golangci-lint": {
      "initialization_options": {
        "command": [
          "golangci-lint",
          "run",
          "--enable-all",
          "--disable",
          "lll",
          "--out-format",
          "json",
          "--issues-exit-code=1"
        ]
      }
    }
  },
  "languages": {
    "Go": {
      "language_servers": ["gopls", "golangci-lint"]
    }
  }
id = "golangci-lint"
name = "Golangci-Lint"
description = "Golangci Lint support."
version = "0.1.0"
schema_version = 1
authors = ["Jordan Gregory <jordan@j4ng5y.dev>"]
repository = "https://github.com/j4ng5y/zed_golangci_lint"

[language_servers.golangci-lint]
name = "golangci-lint"
language = "Golangci Lint"
languages = ["Go"]
2024-08-27T21:11:54.55481555-04:00 [WARN] no language server found matching 'golangci-lint'
2024-08-27T21:11:54.55488198-04:00 [INFO] starting language servers for Go: gopls
thecskin commented 3 months ago

Even with the above changes, I get the same error. I am on linux, not a mac though

I was able to get it running by doing the fix above and manually replacing extension.wasm from the repository. They are quite different (188KB vs 499KB). I guess that's tied to #6.

jseiser commented 3 months ago

Even copying down his extension.wasm, the result is the same.

2024-08-28T22:37:29.809873837-04:00 [WARN] no language server found matching 'golangci-lint'
2024-08-28T22:37:29.809884908-04:00 [INFO] starting language servers for Go: gopls
2024-08-28T22:37:29.809898603-04:00 [WARN] no language server found matching 'golangci-lint'
mibesr commented 2 months ago

@jseiser $HOME/Library/Application\ Support/Zed/extensions/installed/golangci-lint/extension.toml

...
[language_servers.golangci-lint]
language = "Golangci Lint"
languages = ["Go"] // change this line
...
jseiser commented 2 months ago

Ya, its correct for me, but it still doesnt run. I assume its a Mac/Linux thing at this point?

❯ cat ~/.local/share/zed/extensions/installed/golangci-lint/extension.toml
id = "golangci-lint"
name = "Golangci-Lint"
version = "0.1.0"
schema_version = 1
description = "Golangci Lint support."
repository = "https://github.com/j4ng5y/zed_golangci_lint"
authors = ["Jordan Gregory <jordan@j4ng5y.dev>"]
themes = []
languages = ["Go"]

[lib]
kind = "Rust"
version = "0.0.6"

[grammars]

[language_servers.golangci-lint]
name = "golangci-lint"
language = "Golangci Lint"
languages = ["Go"]

[language_servers.golangci-lint.language_ids]

[slash_commands]
mibesr commented 2 months ago

@jseiser

  1. Install Zed Extension for Golangci-Lint 1.1 https://github.com/j4ng5y/zed_golangci_lint/issues/2#issuecomment-2338077672
  2. Install Golangci-Lint and Golangci-Lint-Langserver 2.1 MacOS / Brew brew install golangci-lint golangci-lint-langserver 2.2 Install from Source export PATH=~/go/bin:$PATH go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest go install github.com/nametake/golangci-lint-langserver@latest
jseiser commented 2 months ago

@mibesr

I removed it all, redid it all and same issue. If it wasnt clear, Im not on a Mac, so I assume there must be some difference there.

So both golangci-lint and golangci-lint-langserver are installed.

~/repos/test_echo [🐹 v1.23.0]
❯ golangci-lint-langserver                
golangci-lint-langserver: connections opened
^C

~/repos/test_echo [🐹 v1.23.0]
❯ golangci-lint           
Smart, fast linters runner.

Usage:
  golangci-lint [flags]
  golangci-lint [command]

Available Commands:
  cache       Cache control and information
  completion  Generate the autocompletion script for the specified shell
  config      Config file information
  custom      Build a version of golangci-lint with custom linters
  help        Help
  linters     List current linters configuration
  run         Run the linters
  version     Version

Flags:
      --color string   Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
  -h, --help           Help for a command
  -v, --verbose        Verbose output
      --version        Print version

Use "golangci-lint [command] --help" for more information about a command.

The extension is installed

❯ ls -l ~/.local/share/zed/extensions/installed
drwxrwxr-x justin justin 4.0 KB Tue Sep 17 21:39:40 2024  golangci-lint

Extension.toml is updated

[language_servers.golangci-lint]
language = "Golangci Lint"
languages = ["Go"]

Tried with and w/out the extension.wasm from the MR.

Still doesnt work.

Removed it all, reinstalled it all from this fork https://github.com/snicol/zed_golangci_lint

Same result.

SealTV commented 2 months ago

I have the same issue

snicol commented 2 months ago

Could you share some logging information?

If you open Command Palette and use zed: open log you should find some information.

On my end, I do see errors like [WARN] no language server found matching 'golangci-lint' only to then see [INFO] starting language server process. binary path: "/opt/homebrew/bin/golangci-lint-langserver", working directory:... later on and it works. Something to fix there.

If you are seeing it start but not working, check the LSP logs, by using debug: open language server logs then in the dropdown menu select golangci-lint's RPC messages. You should see some jsonrpc calls to the language server.

Screenshot 2024-09-30 at 17 26 47

Aside, I've had no luck using this extension in a monorepo, where the root of the project didn't contain a go.mod.

jseiser commented 2 months ago

OK, we are a monorepo, so I assume thats why i was broken. Using your fork, im able to work in a basic repo.