lua.lua 1.5 KB

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