Alloyed / lua-lsp

A Lua language server
MIT License
288 stars 21 forks source link

How would I configure this with nvim built-in LSP client? #43

Open mrjones2014 opened 3 years ago

mrjones2014 commented 3 years ago

Any idea how I'd integrate this with the neovim built-in LSP?

I'm using lspconfig, but they only have a config for the sumneko Lua lsp, which IMHO is far too complex to set up just to get an LSP (you have to install several dependencies and build from source).

I'd much prefer to use this one, but I'm not sure how to configure it with the neovim built-in LSP?

Alloyed commented 3 years ago

So just as a caveat, I haven't been updating this package that often, or even using it more than on weekends! Sumneko's package is better maintained, has more features, and all that good stuff.

That said: I looked really quickly at how the native LSP system works and supporting it seems pretty easy, even without making upstream changes. The official docs make use of a "cmd" parameter, since we don't use any weird configs and neither does sumneko's server, this means they are totally interchangeable on that level. just swap out the sumneko binary with a call to your lua-lsp command.

so in this example:

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#sumneko_lua

we can just swap the entire cmd to something like so

local lua_lsp_binary = "<>" -- call `which lua-lsp` on your machine and paste the result here, or do something more complicated like the original example
require'lspconfig'.sumneko_lua.setup {
  cmd = {lua_lsp_binary};
  settings = {},
  },
}

In terms of other things that example configures, like package.path, we use a .luacompleterc file to provide the same environment info: https://github.com/dapetcu21/atom-autocomplete-lua#configuration

mrvon commented 2 years ago

I switch to lua-lsp since Sumneko's version haven't respected luacheck. Your tips is really helpful, Thank you @Alloyed