vue.lua 1.6 KB

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