add eslint and eslint_d to efm (#877)

This commit is contained in:
William Goulois 2021-07-11 15:36:35 +02:00 committed by GitHub
parent ed382dd488
commit 26c5c74303
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 14 deletions

View file

@ -266,7 +266,7 @@ O = {
},
terraform = {},
tsserver = {
-- @usage can be 'eslint'
-- @usage can be 'eslint' or 'eslint_d'
linter = "",
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },

View file

@ -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,
},
},
}