summaryrefslogtreecommitdiff
path: root/lua/lsp/ts-fmt-lint.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lsp/ts-fmt-lint.lua')
-rw-r--r--lua/lsp/ts-fmt-lint.lua38
1 files changed, 25 insertions, 13 deletions
diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua
index 8a6c366c..a73b817e 100644
--- a/lua/lsp/ts-fmt-lint.lua
+++ b/lua/lsp/ts-fmt-lint.lua
@@ -5,30 +5,42 @@ local M = {}
M.setup = function()
local tsserver_args = {}
- local prettier = {
- formatCommand = "prettier --stdin-filepath ${INPUT}",
- formatStdin = true,
- }
-
- if vim.fn.glob "node_modules/.bin/prettier" ~= "" then
- prettier = {
- formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}",
+ if O.lang.tsserver.linter == "eslint" or O.lang.tsserver.linter == "eslint_d" then
+ local eslint = {
+ lintCommand = O.lang.tsserver.linter .. " -f unix --stdin --stdin-filename {INPUT}",
+ lintStdin = true,
+ lintFormats = { "%f:%l:%c: %m" },
+ lintIgnoreExitCode = true,
+ formatCommand = O.lang.tsserver.linter .. " --fix-to-stdout --stdin --stdin-filename=${INPUT}",
formatStdin = true,
}
+ table.insert(tsserver_args, eslint)
end
require("lspconfig").efm.setup {
-- init_options = {initializationOptions},
cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
init_options = { documentFormatting = true, codeAction = false },
- filetypes = { "html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact" },
+ root_dir = require("lspconfig").util.root_pattern(".git/", "package.json"),
+ filetypes = {
+ "vue",
+ "javascript",
+ "javascriptreact",
+ "typescript",
+ "typescriptreact",
+ "javascript.jsx",
+ "typescript.tsx",
+ },
settings = {
rootMarkers = { ".git/", "package.json" },
languages = {
- html = { prettier },
- css = { prettier },
- json = { prettier },
- yaml = { prettier },
+ vue = tsserver_args,
+ javascript = tsserver_args,
+ javascriptreact = tsserver_args,
+ ["javascript.jsx"] = tsserver_args,
+ typescript = tsserver_args,
+ ["typescript.tsx"] = tsserver_args,
+ typescriptreact = tsserver_args,
},
},
}