dart.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. stdin = true,
  9. },
  10. }
  11. end
  12. M.format = function()
  13. O.formatters.filetype["dart"] = {
  14. function()
  15. return {
  16. exe = O.lang.dart.formatter.exe,
  17. args = O.lang.dart.formatter.args,
  18. stdin = O.lang.dart.formatter.stdin,
  19. }
  20. end,
  21. }
  22. require("formatter.config").set_defaults {
  23. logging = false,
  24. filetype = O.formatters.filetype,
  25. }
  26. end
  27. M.lint = function()
  28. -- TODO: implement linters (if applicable)
  29. return "No linters configured!"
  30. end
  31. M.lsp = function()
  32. if require("lv-utils").check_lsp_client_active "dartls" then
  33. return
  34. end
  35. require("lspconfig").dartls.setup {
  36. cmd = { "dart", O.lang.dart.sdk_path, "--lsp" },
  37. on_attach = require("lsp").common_on_attach,
  38. init_options = {
  39. closingLabels = false,
  40. flutterOutline = false,
  41. onlyAnalyzeProjectsWithOpenFiles = false,
  42. outline = false,
  43. suggestFromUnimportedLibraries = true,
  44. },
  45. }
  46. end
  47. M.dap = function()
  48. -- TODO: implement dap
  49. return "No DAP configured!"
  50. end
  51. return M