2021-07-15 00:50:07 +02:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.config = function()
|
2021-07-18 20:36:08 +02:00
|
|
|
O.lang.vue = {
|
|
|
|
formatter = {
|
|
|
|
exe = "prettier",
|
|
|
|
args = {
|
|
|
|
"--stdin-filepath",
|
|
|
|
"${FILEPATH}",
|
|
|
|
},
|
|
|
|
stdin = true,
|
|
|
|
},
|
|
|
|
auto_import = true,
|
2021-07-20 21:33:15 +02:00
|
|
|
lsp = {
|
|
|
|
path = DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls",
|
|
|
|
},
|
2021-07-18 20:36:08 +02:00
|
|
|
}
|
2021-07-15 00:50:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
M.format = function()
|
2021-07-18 20:36:08 +02:00
|
|
|
vim.cmd "let proj = FindRootDirectory()"
|
|
|
|
local root_dir = vim.api.nvim_get_var "proj"
|
|
|
|
|
|
|
|
-- use the global formatter if you didn't find the local one
|
|
|
|
local formatter_instance = root_dir .. "/node_modules/.bin/" .. O.lang.vue.formatter.exe
|
|
|
|
if vim.fn.executable(formatter_instance) ~= 1 then
|
|
|
|
formatter_instance = O.lang.vue.formatter.exe
|
|
|
|
end
|
|
|
|
|
|
|
|
local ft = vim.bo.filetype
|
|
|
|
O.formatters.filetype[ft] = {
|
|
|
|
function()
|
|
|
|
local lv_utils = require "lv-utils"
|
|
|
|
return {
|
|
|
|
exe = formatter_instance,
|
|
|
|
args = lv_utils.gsub_args(O.lang.vue.formatter.args),
|
|
|
|
stdin = O.lang.vue.formatter.stdin,
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
require("formatter.config").set_defaults {
|
|
|
|
logging = false,
|
|
|
|
filetype = O.formatters.filetype,
|
|
|
|
}
|
2021-07-15 00:50:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
M.lint = function()
|
|
|
|
-- TODO: implement linters (if applicable)
|
|
|
|
return "No linters configured!"
|
|
|
|
end
|
|
|
|
|
2021-07-15 02:48:05 +02:00
|
|
|
M.lsp = function()
|
|
|
|
if require("lv-utils").check_lsp_client_active "vuels" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Vue language server configuration (vetur)
|
|
|
|
require("lspconfig").vuels.setup {
|
2021-07-20 21:33:15 +02:00
|
|
|
cmd = { O.lang.vue.lsp.path, "--stdio" },
|
2021-07-15 02:48:05 +02:00
|
|
|
on_attach = require("lsp").common_on_attach,
|
|
|
|
}
|
2021-07-18 20:36:08 +02:00
|
|
|
|
|
|
|
require("lsp.ts-fmt-lint").setup()
|
2021-07-15 02:48:05 +02:00
|
|
|
end
|
2021-07-15 00:50:07 +02:00
|
|
|
|
|
|
|
M.dap = function()
|
|
|
|
-- TODO: implement dap
|
|
|
|
return "No DAP configured!"
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|