zig.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. local M = {}
  2. M.config = function()
  3. O.lang.zig = {
  4. formatter = {
  5. exe = "zig",
  6. args = { "fmt" },
  7. stdin = false,
  8. },
  9. }
  10. end
  11. M.format = function()
  12. O.formatters.filetype["zig"] = {
  13. function()
  14. return {
  15. exe = O.lang.zig.formatter.exe,
  16. args = O.lang.zig.formatter.args,
  17. stdin = O.lang.zig.formatter.stdin,
  18. }
  19. end,
  20. }
  21. require("formatter.config").set_defaults {
  22. logging = false,
  23. filetype = O.formatters.filetype,
  24. }
  25. end
  26. M.lint = function()
  27. -- TODO: implement linters (if applicable)
  28. return "No linters configured!"
  29. end
  30. M.lsp = function()
  31. if require("lv-utils").check_lsp_client_active "zls" then
  32. return
  33. end
  34. -- Because lspinstall don't support zig yet,
  35. -- So we need zls preset in global lib
  36. -- Further custom install zls in
  37. -- https://github.com/zigtools/zls/wiki/Downloading-and-Building-ZLS
  38. require("lspconfig").zls.setup {
  39. root_dir = require("lspconfig").util.root_pattern(".git", "build.zig", "zls.json"),
  40. on_attach = require("lsp").common_on_attach,
  41. }
  42. end
  43. M.dap = function()
  44. -- TODO: implement dap
  45. return "No DAP configured!"
  46. end
  47. return M