lua.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. if not require("lv-utils").check_lsp_client_active "sumneko_lua" then
  2. -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
  3. local sumneko_root_path = DATA_PATH .. "/lspinstall/lua"
  4. local sumneko_binary = sumneko_root_path .. "/sumneko-lua-language-server"
  5. require("lspconfig").sumneko_lua.setup {
  6. cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" },
  7. on_attach = require("lsp").common_on_attach,
  8. settings = {
  9. Lua = {
  10. runtime = {
  11. -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
  12. version = "LuaJIT",
  13. -- Setup your lua path
  14. path = vim.split(package.path, ";"),
  15. },
  16. diagnostics = {
  17. -- Get the language server to recognize the `vim` global
  18. globals = { "vim" },
  19. },
  20. workspace = {
  21. -- Make the server aware of Neovim runtime files
  22. library = {
  23. [vim.fn.expand "$VIMRUNTIME/lua"] = true,
  24. [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
  25. },
  26. maxPreload = 100000,
  27. preloadFileSize = 1000,
  28. },
  29. },
  30. },
  31. }
  32. end
  33. if O.lang.lua.autoformat then
  34. require("lv-utils").define_augroups {
  35. _lua_autoformat = {
  36. {
  37. "BufWritePre",
  38. "*.lua",
  39. "lua vim.lsp.buf.formatting_sync(nil, 1000)",
  40. },
  41. },
  42. }
  43. end
  44. vim.cmd "setl ts=2 sw=2"