diff options
author | Christian Chiarulli <[email protected]> | 2021-07-13 21:13:55 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-07-13 21:13:55 -0400 |
commit | a097fa4c04e6db34bb409e0dea302c20629da8ec (patch) | |
tree | fb1c5bdd14cac82a363ea6c25b03a475050305f2 /lua/lsp/ts-fmt-lint.lua | |
parent | 04f9f53914a7dd999117ed73c5fa0ab3b0dc95e4 (diff) |
LunarVim 0.4.8 (#919)0.4.8
Diffstat (limited to 'lua/lsp/ts-fmt-lint.lua')
-rw-r--r-- | lua/lsp/ts-fmt-lint.lua | 38 |
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, }, }, } |