nvim-lspconfig icon indicating copy to clipboard operation
nvim-lspconfig copied to clipboard

lua-language-server: wrong cmd on Windows

Open xarthurx opened this issue 2 years ago • 1 comments

Description

On Windows, when using https://github.com/sumneko/lua-language-server, it always show the following error when opening a .lua file: image

After digging, it turns out that the correct name should be lua-language-server.cmd instead of lua-language-server: image

I think lspconfig should generate platform-based cmd for this package.

Neovim version

Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compiled by runneradmin@fv-az276-503

Nvim-lspconfig version

No response

Operating system and version

Windows 11 + PowerShell

Affected language servers

lua-language-server

Steps to reproduce

  1. open nvim
  2. open a .lua file

Actual behavior

lua-language-server cannot be found.

Expected behavior

lua-language-server should be found and used.

Minimal config

below.

LSP log

https://gist.github.com/xarthurx/262a5feba8f14cc0da55400d981552ca

xarthurx avatar Jul 27 '22 12:07 xarthurx

similar to https://github.com/neovim/nvim-lspconfig/pull/2013

justinmk avatar Jul 27 '22 13:07 justinmk

@xarthurx Do you happen to use mason.nvim? It will write .cmd executable shims on Windows systems, which doesn't play nicely with libuv (which Neovim's LSP client uses to spawn servers). If you download lua-language-server directly from their GitHub releases, you'll get an .exe, which will work fine. mason-lspconfig.nvim fixes these inconsistencies and is strongly recommended for Windows users.

The problem is with how libuv doesn't recognize .cmd (or .bat) executables in PATH on Windows regardless of how PATHEXT is configured (the reason is CreateProcess can start only .com and .exe files, only those extensions are tried.).

exepath() seems to solve this pretty nicely, as Neovim does respect PATHEXT. null-ls uses it and mason-lspconfig.nvim successfully patches cmds with it. I'd be happy to open a PR that patches commands with exepath() on Windows + normalizes all commands in server configs.

williamboman avatar Jul 31 '22 12:07 williamboman

@williamboman

That’ll be super helpful to patch the command. If I can help with anything, plz let me know.

xarthurx avatar Aug 01 '22 12:08 xarthurx

exepath() seems to solve this pretty nicely, as Neovim does respect PATHEXT. null-ls uses it and mason-lspconfig.nvim successfully patches cmds with it. I'd be happy to open a PR that patches commands with exepath() on Windows + normalizes all commands in server configs.

That sounds like a good idea. Might want to check the git logs / PRs to see if there was a reason that uv_spawn was used directly (only reason I know of: if called in a Lua callback then we can't "shell out" to Vimscript). I'm wondering myself why we don't use e.g. vim.fn.system() (exepath() also would work).

justinmk avatar Aug 01 '22 12:08 justinmk

closed by https://github.com/neovim/nvim-lspconfig/pull/2039

but I have opened https://github.com/neovim/nvim-lspconfig/issues/2130 to track the general solution

justinmk avatar Sep 11 '22 18:09 justinmk

Yes, I use Manson.vim

That’ll be super helpful to patch the command. If I can help with anything, plz let me know. On 31 Jul 2022, 14:19 +0200, William Boman @.***>, wrote:

@xarthurx Do you happen to use mason.nvim? It will write .cmd executable shims on Windows systems, which doesn't play nicely with libuv (which Neovim's LSP client uses to spawn servers). If you download lua-language-server directly from their GitHub releases, you'll get an .exe, which will work fine. mason-lspconfig.nvim fixes these inconsistencies and is strongly recommended for Windows users. The problem is with how libuv doesn't recognize .cmd (or .bat) executables in PATH on Windows regardless of how PATHEXT is configured (the reason is CreateProcess can start only .com and .exe files, only those extensions are tried.). exepath() seems to solve this pretty nicely, as Neovim does respect PATHEXT. null-ls uses it and mason-lspconfig.nvim successfully patches cmds with it. I'd be happy to open a PR that patches commands with exepath() on Windows + normalizes all commands in server configs. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

xarthurx avatar Oct 11 '22 07:10 xarthurx