lua.lua 2.1 KB

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