Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helix Editor #35

Open
PotatoesFall opened this issue Oct 30, 2023 · 5 comments
Open

Helix Editor #35

PotatoesFall opened this issue Oct 30, 2023 · 5 comments

Comments

@PotatoesFall
Copy link

Hi,

https://github.com/helix-editor/helix/ is a great editor and recently added support for multiple language servers. This should finally make it possible to use golangci-lint for diagnostics in the editor.

I'm wondering if anybody has been able to get this working. This is what I have in my languages.toml so far:

[[language]]
name = "go"
auto-format = true
formatter = { command = "goimports" }
language-servers = [
  { name = "golangci-lint-langserver", only-features = ["diagnostics"] },
  { name = "gopls", except-features = ["diagnostics"] },
]

[language-server.gopls]
command = "gopls"

[language-server.golangci-lint-langserver]
command = "golangci-lint-langserver"
config = { command = ["golangci-lint", "run", "--out-format", "json"] }

All my pre-existing config for gopls works just fine, but I'm not getting any diagnostics from golangci-lint.

Official Helix Docs

@kranurag7
Copy link

I copied my config from the following PR on helix repo.
helix-editor/helix#8656

I'm also not getting any diagnostic errors. To confirm I disabled gopls in my languages.toml file.

language-servers = [ "golangci-lint-lsp" ]

Now, when I opened a main.go file from one of my project and executed the following commands then I got these messages.

:lsp-workspace-command
No active language servers for this document support workspace commands
:lsp-restart
Language server exited

For full reference, here's what my languages.toml file looks like without adding gopls

[[language]]
name = "go"
scope = "source.go"
injection-regex = "go"
file-types = ["go"]
roots = ["go.work", "go.mod"]
auto-format = true
comment-token = "//"
language-servers = [ "golangci-lint-lsp" ]
# TODO: gopls needs utf-8 offsets?
indent = { tab-width = 4, unit = "\t" }

[language-server.gopls]
command = "gopls"

[language-server.gopls.config.hints]
assignVariableTypes = true
compositeLiteralFields = true
constantValues = true
functionTypeParameters = true
parameterNames = true
rangeVariableTypes = true

[language-server.golangci-lint-lsp]
command = "golangci-lint-langserver"

[language-server.golangci-lint-lsp.config]
command = ["golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1"]

@oschwald
Copy link

I also tried using this with helix and similarly did not receive the expected diagnostics. Looking at ~/.cache/helix/helix.log, I see errors such as:

2023-10-25T20:10:42.888 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "golangci-lint-langserver: connections opened\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "panic: runtime error: slice bounds out of range [1:0]\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "goroutine 18 [running]:\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "main.(*langHandler).lint(0xc00011c120, {0xc000152050?, 0x0?})\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "\t/home/greg/MaxMind/go/pkg/mod/github.com/nametake/golangci-lint-langser
ver@v0.0.8/handler.go:57 +0x8d1\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "main.(*langHandler).linter(0xc00011c120)\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "\t/home/greg/MaxMind/go/pkg/mod/github.com/nametake/golangci-lint-langser
ver@v0.0.8/handler.go:122 +0x78\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "created by main.NewHandler in goroutine 1\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err <- "\t/home/greg/MaxMind/go/pkg/mod/github.com/nametake/golangci-lint-langser
ver@v0.0.8/handler.go:20 +0xc9\n"
2023-10-25T20:10:42.891 helix_lsp::transport [ERROR] golangci-lint-langserver err: <- StreamClosed

@necromeo
Copy link

Is this still an issue? I have a language.toml that looks just like @kranurag7's and I am getting diagnostics. Enabled all linters for now until, still need to figure out which ones I really need.

Relevant excerpt

[language-server.golangci-lint-lsp]
command = "golangci-lint-langserver"

[language-server.golangci-lint-lsp.config]
command = [
  "golangci-lint",
  "run",
  "--enable-all",
  "--out-format",
  "json",
  "--issues-exit-code=1",
]

[[language]]
name = "go"
auto-format = false
text-width = 100
rulers = [100]
file-types = ["go"]
language-servers = ["gopls", "golangci-lint-lsp"]

Example:
image

@oschwald
Copy link

oschwald commented Jan 2, 2024

With a config similar to that, it seems to be working for me.

@David-Else
Copy link

golangci-lint-langserver is built into Helix by default now: helix-editor/helix#8656 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants