fitrh / init.nvim

What nvim talk about when they talk about configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not setup lua-language-server

thieung opened this issue · comments

Hi @fitrh
Could you please show me the value of LUA_LS variable?
I installed lua-language-server via homebrew on MacOS, run which is lua-language-server show me the path is /usr/local/bin/lua-language-server.

According to the following code:

local bin = ("%s/bin/lua-language-server"):format(LUA_LS)
local main = ("%s/main.lua"):format(LUA_LS)

Should I set LUA_LS is /usr/local?

This configuration uses the build from source version of lua-language-server,
so won't work if you use the package manager version since they ship
lua-language-server with a wrapper script

As long as lua-language-server is on your PATH, all you need to do is
remove the LUA_LS check and set cmd to lua-language-server

diff --git a/lua/config/lsp/server/sumneko_lua.lua b/lua/config/lsp/server/sumneko_lua.lua
index 5ade0fa..a97b6ef 100644
--- a/lua/config/lsp/server/sumneko_lua.lua
+++ b/lua/config/lsp/server/sumneko_lua.lua
@@ -1,16 +1,9 @@
-local LUA_LS = os.getenv("LUA_LS")
-if not LUA_LS then
-  return false
-end
-
-local bin = ("%s/bin/lua-language-server"):format(LUA_LS)
-local main = ("%s/main.lua"):format(LUA_LS)
 local runtime_path = vim.split(package.path, ";")
 runtime_path[#runtime_path + 1] = "lua/?.lua"
 runtime_path[#runtime_path + 1] = "lua/?/init.lua"
 
-return require("config.lsp.server").with(bin, {
-  cmd = { bin, "-E", main },
+return require("config.lsp.server").with("lua-language-server", {
+  cmd = { "lua-language-server" },
   settings = {
     Lua = {
       completion = {

I thought I'd update this configuration to use lua-language-server wrapper script as it is easy enough to create a wrapper script even with the build from source version

Yes, agree @fitrh
I updated and it works perfectly now.
And according to this issue, I think it would be nice if you can add mason.nvim + mason lsp to manage all lsp servers.

I do understand that some user enjoy using something like mason.nvim,
but that just not my cup of tea, you know? something-something-automatic-manage-all-installation

IMO, something like that (yes, it makes the UX easier for some users, but) can
add extra complexity to something that tend to be manage by a single person

For now, if something goes wrongs, we may guess (or trace) the source, it can be
the LSP client, the LSP binary, or the user config, we may debug the LSP binary
by running it outside neovim or runnig it in another editor to see what wrong

Adding another unnecessary layer mean adding the source of problem we need to guess

I'm not against something like mason.nvim, I know the benefits, but I enjoy how
I manage my configuration

I apologize, but I'm not interesting for something like mason.nvim,
I kind of build from source guys, hahaha, my long term goal is to remove
lspconfig and using vim.lsp.start in ftplugin once I have a time to deep dive into it

Thanks for sharing your thoughts.
After using many pre-configurations and reference some awesome configs. I found your config is fit to me and easy to understand how nvim work. Thanks for that.