lua-ls.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 ..
  7. "/.config/nvim/ls/lua-language-server"
  8. sumneko_binary = "/Users/" .. USER ..
  9. "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server"
  10. elseif vim.fn.has("unix") == 1 then
  11. sumneko_root_path = "/home/" .. USER ..
  12. "/.config/nvim/ls/lua-language-server"
  13. sumneko_binary = "/home/" .. USER ..
  14. "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server"
  15. else
  16. print("Unsupported system for sumneko")
  17. end
  18. require'lspconfig'.sumneko_lua.setup {
  19. cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
  20. settings = {
  21. Lua = {
  22. runtime = {
  23. -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
  24. version = 'LuaJIT',
  25. -- Setup your lua path
  26. path = vim.split(package.path, ';')
  27. },
  28. diagnostics = {
  29. -- Get the language server to recognize the `vim` global
  30. globals = {'vim'}
  31. },
  32. workspace = {
  33. -- Make the server aware of Neovim runtime files
  34. library = {
  35. [vim.fn.expand('$VIMRUNTIME/lua')] = true,
  36. [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
  37. }
  38. }
  39. }
  40. }
  41. }