From 26c5c74303b1c7c05cbd3f64b3946b81440b6539 Mon Sep 17 00:00:00 2001 From: William Goulois <37271970+williamgoulois@users.noreply.github.com> Date: Sun, 11 Jul 2021 15:36:35 +0200 Subject: add eslint and eslint_d to efm (#877) --- lua/lsp/ts-fmt-lint.lua | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'lua/lsp') 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, }, }, } -- cgit v1.2.3