dart.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. local M = {}
  2. M.config = function()
  3. O.lang.dart = {
  4. sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
  5. formatter = {
  6. exe = "dart",
  7. args = { "format" },
  8. },
  9. }
  10. end
  11. M.format = function()
  12. O.formatters.filetype["dart"] = {
  13. function()
  14. return {
  15. exe = O.lang.dart.formatter.exe,
  16. args = O.lang.dart.formatter.args,
  17. stdin = not (O.lang.dart.formatter.stdin ~= nil),
  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 "dartls" then
  32. return
  33. end
  34. require("lspconfig").dartls.setup {
  35. cmd = { "dart", O.lang.dart.sdk_path, "--lsp" },
  36. on_attach = require("lsp").common_on_attach,
  37. init_options = {
  38. closingLabels = false,
  39. flutterOutline = false,
  40. onlyAnalyzeProjectsWithOpenFiles = false,
  41. outline = false,
  42. suggestFromUnimportedLibraries = true,
  43. },
  44. }
  45. end
  46. M.dap = function()
  47. -- TODO: implement dap
  48. return "No DAP configured!"
  49. end
  50. return M