lua-ls.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
  2. USER = vim.fn.expand('$USER')
  3. local sumneko_root_path = ""
  4. local sumneko_binary = ""
  5. if vim.fn.has("mac") == 1 then
  6. sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/ls/lua-language-server"
  7. sumneko_binary = "/Users/" .. USER .. "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server"
  8. elseif vim.fn.has("unix") == 1 then
  9. sumneko_root_path = "/home/" .. USER .. "/.config/nvim/ls/lua-language-server"
  10. sumneko_binary = "/home/" .. USER .. "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server"
  11. else
  12. print("Unsupported system for sumneko")
  13. end
  14. require'lspconfig'.sumneko_lua.setup {
  15. cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
  16. settings = {
  17. Lua = {
  18. runtime = {
  19. -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
  20. version = 'LuaJIT',
  21. -- Setup your lua path
  22. path = vim.split(package.path, ';')
  23. },
  24. diagnostics = {
  25. -- Get the language server to recognize the `vim` global
  26. globals = {'vim'}
  27. },
  28. workspace = {
  29. -- Make the server aware of Neovim runtime files
  30. library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true}
  31. }
  32. }
  33. }
  34. }