vue.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local M = {}
  2. M.config = function()
  3. O.lang.vue = {
  4. formatter = {
  5. exe = "prettier",
  6. args = {
  7. "--stdin-filepath",
  8. "${FILEPATH}",
  9. },
  10. stdin = true,
  11. },
  12. auto_import = true,
  13. }
  14. end
  15. M.format = function()
  16. vim.cmd "let proj = FindRootDirectory()"
  17. local root_dir = vim.api.nvim_get_var "proj"
  18. -- use the global formatter if you didn't find the local one
  19. local formatter_instance = root_dir .. "/node_modules/.bin/" .. O.lang.vue.formatter.exe
  20. if vim.fn.executable(formatter_instance) ~= 1 then
  21. formatter_instance = O.lang.vue.formatter.exe
  22. end
  23. local ft = vim.bo.filetype
  24. O.formatters.filetype[ft] = {
  25. function()
  26. local lv_utils = require "lv-utils"
  27. return {
  28. exe = formatter_instance,
  29. args = lv_utils.gsub_args(O.lang.vue.formatter.args),
  30. stdin = O.lang.vue.formatter.stdin,
  31. }
  32. end,
  33. }
  34. require("formatter.config").set_defaults {
  35. logging = false,
  36. filetype = O.formatters.filetype,
  37. }
  38. end
  39. M.lint = function()
  40. -- TODO: implement linters (if applicable)
  41. return "No linters configured!"
  42. end
  43. M.lsp = function()
  44. if require("lv-utils").check_lsp_client_active "vuels" then
  45. return
  46. end
  47. -- Vue language server configuration (vetur)
  48. require("lspconfig").vuels.setup {
  49. cmd = { DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", "--stdio" },
  50. on_attach = require("lsp").common_on_attach,
  51. }
  52. require("lsp.ts-fmt-lint").setup()
  53. end
  54. M.dap = function()
  55. -- TODO: implement dap
  56. return "No DAP configured!"
  57. end
  58. return M