lua.lua 1.9 KB

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