lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
160 stars 21 forks source link

util.command_exists does not work on Windows #13

Closed takase1121 closed 3 years ago

takase1121 commented 3 years ago

Windows executables has .exe at the end.

jgmdev commented 3 years ago

Strange, I tested on linux by renaming one of my lsp servers from lspcommand to lspcommand.exe and it still works. Could it be that the PATH envar isn't been properly given to lite-xl/lua by windows? What would be the output in windows of the following snippet when run inside of lite-xl?

print(os.getenv("PATH"))

As a workaround one may also provide the absolute path of the lsp server executable.

takase1121 commented 3 years ago

no that's not the problem, the problem is util.command_exist, which tries to find the file in PATH. .exe isn't appended there.

jgmdev commented 3 years ago

No window machine to test since it is the first thing I remove when getting one :disappointed: but if that is the case then util.split may be at fault... but as I said I tested on linux by renaming or symlinking to a lsp server with a .exe appended to it and setting the command to point to it with lspconfig and it still worked.

Edit: pfff I reproduced the issue, the symlink test I did was dumb :smile: working on the fix

takase1121 commented 3 years ago

great to hear that :3 I was working on a repro since I'm not the one who discovered the issue. I was going to PR but don't really have time. Thanks!

jgmdev commented 3 years ago

Mmm, it works when launching from a shell but not from the .desktop file ...

jgmdev commented 3 years ago

Nope, I was wrong the thing is I have some additional paths added to my zsh rc file which aren't added globally so that is in my case why launching from shell works but not from the .desktop file. So in the end yes it works, can not reproduce the issue... Also was logging the path scanning and I don't see anything wrong:

2021-10-26_01:14:22

jgmdev commented 3 years ago

closing since could not reproduce

takase1121 commented 3 years ago

image

local lsp = require "plugins.lsp"
lsp.add_server {
  name = "powershell",
  language = "lua",
  file_patterns = { "%.lua$" },
  command = { "powershell" },
  verbose = false
}