Hello!
I am trying to implement an lspconfig for vale, which is a customizable syntax-aware prose linter. The only thing I want it to do for now is to have the textDocument/publishDiagnostics
LSP request.
My approach so far:
- vale provides both a server and a CLI (see their Creating a plugin guide, the output can also be inspected there). I am going with the CLI approach since it looks simpler, so I set the cmd to output JSON:
configs.vale = {
default_config = {
cmd = { "vale --output=JSON" },
-- ...
- Since vale does not follow the LSP specification, I think I have to implement a handler:
-- ...
handlers = {
["textDocument/Diagnostic"] = vale_handler,
},
- Now, I copied the handler from the denols config:
local function vale_handler(err, method, result)
if not result or vim.tbl_isempty(result) then
return nil
end
for _, res in pairs(result) do
-- I have to handle uris somehow
-- I have to map lines and spans to a range.
-- I have to map Message to message
end
lsp.handlers[method](err, method, result)
end
I have a lot of questions (I am not used to developing stuff in neovim, so reading :h lsp
was a bit hard):
- Is this the way to go?
- Inside the handler function, what is the input passed as arguments exactly? Is each thing in results a (uri, cmd-output) pair or something? If so, is cmd-output a raw string that I have to parse?
- What is
lsp.handlers[method](err, method, result)
expecting asresult
? I guess it is something in the LSP specification, but what type, a string, a table?
I hope I got something right about this. Also, let me know if someone is working in a prose linter integration like this one, like proselint or whatever, it is a functionality that Iβd really like for my TEX and MD editing.