vale-ls icon indicating copy to clipboard operation
vale-ls copied to clipboard

unable to initialize vale-ls with custom config location

Open augustomelo opened this issue 2 years ago • 2 comments
trafficstars

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.

  • https://github.com/errata-ai/vale-ls/blob/5b4f79277ce1d21fa01eba8aafe1ac3de04dc181/src/vale.rs#L167-L178
  • https://github.com/errata-ai/vale-ls/blob/5b4f79277ce1d21fa01eba8aafe1ac3de04dc181/src/vale.rs#L183

Edit: updated hypothesis

augustomelo avatar Jul 14 '23 10:07 augustomelo

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 avatar Dec 07 '23 01:12 chrisgrieser

since vale 3.0.0, VALE_CONFIG_PATH does not work anymore, so that my workaround above also does not work anymore. https://github.com/errata-ai/vale/issues/750

edit: VALE_CONFIG_PATH issue has been fixed, works again

chrisgrieser avatar Jan 10 '24 14:01 chrisgrieser