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 doesn't trigger onDidSave event in diagnostic-languageserver #9034

Closed
akhilman opened this issue Dec 8, 2023 · 1 comment · Fixed by #9101
Closed

Helix doesn't trigger onDidSave event in diagnostic-languageserver #9034

akhilman opened this issue Dec 8, 2023 · 1 comment · Fixed by #9101
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@akhilman
Copy link

akhilman commented Dec 8, 2023

Summary

I have got diagnostic-languageserver working with Helix.
Everything works fine except linters with the onSaveOnly option set to true.

I did some research and found that the onDidSave handler right here is never being called.

In NeoVIM onSaveOnly works as expected and onDidSave is being called.

Reproduction Steps

I tried this:

  1. Install diagnostic-languageserver;
  2. Modify languages.toml (see below);
  3. Run helix test.md;
  4. Add some text;
  5. Hit :w to start linter;

No warning is reported. But it should.

  1. Comment onSaveOnly in languages.toml;
  2. Run helix test.md.

Warning will appear on first line.

Same with NeoVIM:

  1. Install diagnostic-languageserver if not yet installed;
  2. Install lspconfig module;
  3. Modify ~/.config/neovim/init.lua (see below);
  4. Run nvim test.md;
  5. Add some text;
  6. Hit :w to start linter.

Warning will appear on first line.

Minimal languages.toml:

[[language]]
name = "markdown"
language-servers = ["markman", "dls"]

[language-server.dls]
command = "diagnostic-languageserver"
args = ["--stdio", "--log-level=4"]

[language-server.dls.config.filetypes]
"*" = "itworks"

[language-server.dls.config.linters.itworks]
command = "echo"
args = [":1:1: warning: It works!"]
sourceName = "itworks"
debounce = 1000
onSaveOnly = true  # Does not work with this.
formatLines = 1
formatPattern = [
  "^:(\\d+):(\\d+): ([^:]+): (.*)$",
  { line = 1, column = 2, security = 3, message = [4] }
]

Minimal nvim's init.lua:

require("lspconfig").diagnosticls.setup {
  filetypes = { "markdown" },
  cmd = { "diagnostic-languageserver", "--stdio", "--log-level=4" },
  init_options = {
    filetypes = {
      ["*"] = "itworks",
    },
    linters = {
      itworks = {
        command = "echo",
        args = { ":1:1: warning: It works!" },
        sourceName = "itworks",
        debounce = 1000,
        onSaveOnly = true,
        formatLines = 1,
        formatPattern = {
          "^:(\\d+):(\\d+): ([^:]+): (.*)$",
          { line = 1, column = 2, security = 3, message = { 4 } }
        }
      }
    }
  }
}

Helix log

~/.cache/helix/helix.log
2023-12-08T11:23:05.434 helix_view::editor [ERROR] Failed to initialize the language servers for `source.md` - `markman` { Language server 'markman' not defined }

Platform

Linux / Manjaro and OpenSUSE

Terminal Emulator

gnome-console / tmux

Installation Method

pacman / zypper and buit from source

Helix Version

helix 23.10 (f6021dd) / helix 23.10 (b81aacc)

@akhilman akhilman added the C-bug Category: This is a bug label Dec 8, 2023
@gabydd
Copy link
Member

gabydd commented Dec 8, 2023

yeah we don't handle the text document sync capabilities correctly and don't send didSave see: #8305 (comment), specifically this table: microsoft/language-server-protocol#288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants