summaryrefslogtreecommitdiff
path: root/lua/lsp/ts-fmt-lint.lua
diff options
context:
space:
mode:
authorWilliam Goulois <[email protected]>2021-07-11 15:36:35 +0200
committerGitHub <[email protected]>2021-07-11 09:36:35 -0400
commit26c5c74303b1c7c05cbd3f64b3946b81440b6539 (patch)
tree4ba488614789c4f67665df347c1e48afe2f66c6e /lua/lsp/ts-fmt-lint.lua
parented382dd488cfa7e2f2c9fd907f096397e7fc644d (diff)
add eslint and eslint_d to efm (#877)
Diffstat (limited to 'lua/lsp/ts-fmt-lint.lua')
-rw-r--r--lua/lsp/ts-fmt-lint.lua37
1 files changed, 24 insertions, 13 deletions
diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua
index 8a6c366c..f6b37136 100644
--- a/lua/lsp/ts-fmt-lint.lua
+++ b/lua/lsp/ts-fmt-lint.lua
@@ -5,30 +5,41 @@ 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" },
+ 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,
},
},
}