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

unable to initialize vale-ls with custom config location #4

Open
augustomelo opened this issue Jul 14, 2023 · 2 comments
Open

unable to initialize vale-ls with custom config location #4

augustomelo opened this issue Jul 14, 2023 · 2 comments

Comments

@augustomelo
Copy link
Contributor

augustomelo commented Jul 14, 2023

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.

  • vale-ls/src/vale.rs

    Lines 167 to 178 in 5b4f792

    if filter != "" {
    args.push(format!("--filter={}", filter));
    }
    args.push(fp.to_string());
    let exe = self.exe_path(false)?;
    let out = Command::new(exe.as_os_str())
    .current_dir(cwd)
    .args(args)
    .output()?;
    self.parse_output(out)
  • let out = Command::new(exe.as_os_str()).arg("-v").output()?;

Edit: updated hypothesis

jdkato added a commit that referenced this issue Jul 21, 2023
fix(#4): run command use `--config` flag if passed
augustomelo added a commit to augustomelo/dotfiles that referenced this issue Jul 26, 2023
I am still waiting for a new relase of vale-ls, because

I am still waiting for a vale-ls release, because the current one doesn't contain the fix for the run command.

errata-ai/vale-ls#4
@chrisgrieser
Copy link

I also experience that issue. I found that as a workaround, setting VALE_CONFIG_PATH does work:

vim.env.VALE_CONFIG_PATH = "/path/vale.ini"

@chrisgrieser
Copy link

chrisgrieser commented Jan 10, 2024

since vale 3.0.0, VALE_CONFIG_PATH does not work anymore, so that my workaround above also does not work anymore. errata-ai/vale#750

edit: VALE_CONFIG_PATH issue has been fixed, works again

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

2 participants