lua-ls.lua 1.7 KB

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