errata-ai / vale-ls Goto Github PK
View Code? Open in Web Editor NEW:zap: An implementation of the Language Server Protocol (LSP) for the Vale command-line tool.
License: MIT License
:zap: An implementation of the Language Server Protocol (LSP) for the Vale command-line tool.
License: MIT License
I have vale
installed on my machine and the config are on $XDG_CONFIG_HOME
, since vale only looks for vale.ini
under $HOME
the usual way that run vale is for example vale sync --config='$XDG_CONFIG_HOME/vale/vale.ini'
.
So I am currently trying to run vale-ls and say that the way to pass the config location is through initializationOptions.configPath
and I am doing so (example bellow with neovim lspconfig)
require('lspconfig').vale_ls.setup{
capabilities = capabilities,
filetypes = { 'gitcommit', 'markdown', 'text' },
init_options = {
configPath = vim.env.XDG_CONFIG_HOME .. '/vale/vale.ini'
},
}
I also tried to pass a path (vim.env.XDG_CONFIG_HOME .. '/vale/
) on the configPath, but I keep getting the following error (log from nvim):
[DEBUG][2023-07-14 09:07:14] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "initialized!", type = 3 }}
[TRACE][2023-07-14 09:07:14] .../lua/vim/lsp.lua:1053 "notification" "window/logMessage" { message = "initialized!", type = 3}
[TRACE][2023-07-14 09:07:14] ...lsp/handlers.lua:618 "default_handler" "window/logMessage" { ctx = '{\n client_id = 1,\n method = "window/logMessage"\n}', result = { message = "initialized!", type = 3 }}
[INFO][2023-07-14 09:07:14] ...lsp/handlers.lua:539 "initialized!"
[DEBUG][2023-07-14 09:07:15] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = 'Parsing error: Msg("{\\n \\"Code\\": \\"E100\\",\\n \\"Text\\": \\"E100 [.vale.ini not found] Runtime error\\\\n\\\\nopen : no such file or directory\\\\n\\\\nExecution stopped with code 1.\\"\\n}\\n")', type = 1 }}
[TRACE][2023-07-14 09:07:15] .../lua/vim/lsp.lua:1053 "notification" "window/logMessage" { message = 'Parsing error: Msg("{\\n \\"Code\\": \\"E100\\",\\n \\"Text\\": \\"E100 [.vale.ini not found] Runtime error\\\\n\\\\nopen : no such file or directory\\\\n\\\\nExecution stopped with code 1.\\"\\n}\\n")', type = 1}
[TRACE][2023-07-14 09:07:15] ...lsp/handlers.lua:618 "default_handler" "window/logMessage" { ctx = '{\n client_id = 1,\n method = "window/logMessage"\n}', result = { message = 'Parsing error: Msg("{\\n \\"Code\\": \\"E100\\",\\n \\"Text\\": \\"E100 [.vale.ini not found] Runtime error\\\\n\\\\nopen : no such file or directory\\\\n\\\\nExecution stopped with code 1.\\"\\n}\\n")', type = 1 }}
[ERROR][2023-07-14 09:07:15] ...lsp/handlers.lua:535 'Parsing error: Msg("{\\n \\"Code\\": \\"E100\\",\\n \\"Text\\": \\"E100 [.vale.ini not found] Runtime error\\\\n\\\\nopen : no such file or directory\\\\n\\\\nExecution stopped with code 1.\\"\\n}\\n")'
[DEBUG][2023-07-14 09:07:15] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "window/showMessage", params = { message = "missing field `Path` at line 4 column 1", type = 1 }}
[TRACE][2023-07-14 09:07:15] .../lua/vim/lsp.lua:1053 "notification" "window/showMessage" { message = "missing field `Path` at line 4 column 1", type = 1}
[TRACE][2023-07-14 09:07:15] ...lsp/handlers.lua:618 "default_handler" "window/showMessage" { ctx = '{\n client_id = 1,\n method = "window/showMessage"\n}', result = { message = "missing field `Path` at line 4 column 1", type = 1 }}
I believe the error is coming form a couple a functions that runs the vale command without taking the --config
into consideration.
Edit: updated hypothesis
I've set up vale-ls on my machine for nvim
. I get the diagnostics but code actions aren't there. Am I missing something?
uri.path()
will return /C:/file.txt
on windows and call to vale.exe will fail.
uri.path()
is returning uri component called "path" (not what we want), i think it's better to use uri.to_file_path()
to get file path in correct format.
diff --git a/src/server.rs b/src/server.rs
index c84f874..a3242c0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -380,7 +380,7 @@ impl Backend {
self.update(params.clone());
if self.cli.is_installed() {
- match self.cli.run(uri.path(), self.config_path(), self.config_filter()) {
+ match self.cli.run(uri.to_file_path().unwrap().to_str().unwrap(), self.config_path(), self.config_filter()) {
Ok(result) => {
let mut diagnostics = Vec::new();
for (_, v) in result.iter() {
A line that raises an error with 'fileA.txt' won't raise an error if the line is pasted into 'file A.txt'. It works as expected if run with vale directly.
It would be nice to have a quick fix solution to add error terms to the Vocab for projects that use Vale Vocabularies. This feature existed for Vale server I believe.
Looking at the latest release:
https://github.com/errata-ai/vale-ls/blob/v0.3.5/Cargo.toml
Why in Cargo.toml, do I see this:
[package]
edition = "2021"
version = "0.1.0"
instead of this?
[package]
edition = "2023"
version = "0.3.5"
Shouldn't those values align with the version of vale-ls?
Background of how this came to my attention:
I'm using mason.nvim inside neovim to install LSP servers for me, and it is clearly downloading v0.3.5:
https://github.com/mason-org/mason-registry/blob/main/packages/vale-ls/package.yaml#L14
However when it reports upon the version of value-ls, 0.1.0 gets returned. This is very misleading, and makes you think you're using an ancient version of vale-ls.
In some cases, the diagnostics are updated correctly (move the line up/down), in other cases like deleting the line, the diagnostics stays there even though it is already obsolete.
edit: this also occurs when adding an ignore comment:
<!-- vale Google.FirstPerson = NO -->
The Vale LSP on Neovim is peculiar in that it only updates diagnostics in the buffer after modified files are saved to disk.
Other LSP servers on Neovim usually update diagnostics in near real-time, or when the Editor exits Insert
mode.
Vale's LSP behavior breaks things like autosave
or autoformat
, which are often configured to run when no diagnostic errors are found in the buffer.
It'd be nice to have real-time diagnostics on Neovim to prevent the issue above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.