2021-07-04 00:50:21 +02:00
-- Example configuations here: https://github.com/mattn/efm-langserver
-- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed.
local M = { }
M.setup = function ( )
2021-07-09 14:07:25 +02:00
local tsserver_args = { }
2021-07-04 00:50:21 +02:00
2021-07-11 15:36:35 +02:00
if O.lang . tsserver.linter == " eslint " or O.lang . tsserver.linter == " eslint_d " then
local eslint = {
2021-07-17 15:46:31 +02:00
lintCommand = O.lang . tsserver.linter .. " -f visualstudio --stdin --stdin-filename ${INPUT} " ,
2021-07-11 15:36:35 +02:00
lintStdin = true ,
2021-07-17 15:46:31 +02:00
lintFormats = {
" %f(%l,%c): %tarning %m " ,
" %f(%l,%c): %rror %m " ,
} ,
lintSource = O.lang . tsserver.linter ,
2021-07-11 15:36:35 +02:00
lintIgnoreExitCode = true ,
formatCommand = O.lang . tsserver.linter .. " --fix-to-stdout --stdin --stdin-filename=${INPUT} " ,
2021-07-09 14:07:25 +02:00
formatStdin = true ,
2021-07-04 00:50:21 +02:00
}
2021-07-11 15:36:35 +02:00
table.insert ( tsserver_args , eslint )
2021-07-09 14:07:25 +02:00
end
require ( " lspconfig " ) . efm.setup {
-- init_options = {initializationOptions},
cmd = { DATA_PATH .. " /lspinstall/efm/efm-langserver " } ,
init_options = { documentFormatting = true , codeAction = false } ,
2021-07-12 23:03:20 +02:00
root_dir = require ( " lspconfig " ) . util.root_pattern ( " .git/ " , " package.json " ) ,
2021-07-11 15:36:35 +02:00
filetypes = {
" vue " ,
" javascript " ,
" javascriptreact " ,
" typescript " ,
" typescriptreact " ,
" javascript.jsx " ,
" typescript.tsx " ,
} ,
2021-07-09 14:07:25 +02:00
settings = {
rootMarkers = { " .git/ " , " package.json " } ,
languages = {
2021-07-11 15:36:35 +02:00
vue = tsserver_args ,
javascript = tsserver_args ,
javascriptreact = tsserver_args ,
[ " javascript.jsx " ] = tsserver_args ,
typescript = tsserver_args ,
[ " typescript.tsx " ] = tsserver_args ,
typescriptreact = tsserver_args ,
2021-07-09 14:07:25 +02:00
} ,
} ,
}
2021-07-04 00:50:21 +02:00
end
return M