go.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. local M = {}
  2. M.config = function()
  3. O.lang.go = {
  4. formatter = {
  5. exe = "gofmt",
  6. args = {},
  7. },
  8. }
  9. end
  10. M.format = function()
  11. O.formatters.filetype["go"] = {
  12. function()
  13. return {
  14. exe = O.lang.go.formatter.exe,
  15. args = O.lang.go.formatter.args,
  16. stdin = not (O.lang.go.formatter.stdin ~= nil),
  17. }
  18. end,
  19. }
  20. require("formatter.config").set_defaults {
  21. logging = false,
  22. filetype = O.formatters.filetype,
  23. }
  24. end
  25. M.lint = function()
  26. -- TODO: implement linters (if applicable)
  27. return "No linters configured!"
  28. end
  29. M.lsp = function()
  30. if not require("lv-utils").check_lsp_client_active "gopls" then
  31. require("lspconfig").gopls.setup {
  32. cmd = { DATA_PATH .. "/lspinstall/go/gopls" },
  33. settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } },
  34. root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"),
  35. init_options = { usePlaceholders = true, completeUnimported = true },
  36. on_attach = require("lsp").common_on_attach,
  37. }
  38. end
  39. end
  40. M.dap = function()
  41. -- TODO: implement dap
  42. return "No DAP configured!"
  43. end
  44. return M