swift.lua 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. local M = {}
  2. M.config = function()
  3. O.lang.swift = {
  4. formatter = {
  5. exe = "swiftformat",
  6. args = {},
  7. stdin = true,
  8. },
  9. lsp = {
  10. path = "sourcekit-lsp",
  11. },
  12. }
  13. end
  14. M.format = function()
  15. -- TODO: implement formatter (if applicable)
  16. return "No formatter configured!"
  17. end
  18. M.lint = function()
  19. O.formatters.filetype["swift"] = {
  20. function()
  21. return {
  22. exe = O.lang.swift.formatter.exe,
  23. args = O.lang.swift.formatter.args,
  24. stdin = O.lang.swift.formatter.stdin,
  25. }
  26. end,
  27. }
  28. require("formatter.config").set_defaults {
  29. logging = false,
  30. filetype = O.formatters.filetype,
  31. }
  32. end
  33. M.lsp = function()
  34. if require("lv-utils").check_lsp_client_active "sourcekit" then
  35. return
  36. end
  37. require("lspconfig").sourcekit.setup {
  38. cmd = { "xcrun", O.lang.swift.lsp.path },
  39. on_attach = require("lsp").common_on_attach,
  40. filetypes = { "swift" },
  41. }
  42. end
  43. M.dap = function()
  44. -- TODO: implement dap
  45. return "No DAP configured!"
  46. end
  47. return M