This commit is contained in:
Nikos Papadakis 2023-08-19 00:12:43 +03:00
parent 38fc909733
commit 0f6fc5bd2f
Signed by untrusted user who does not match committer: nikos
GPG key ID: 78871F9905ADFF02

View file

@ -4,6 +4,14 @@ if not ok then
return
end
local root_dir
for dir in vim.fs.parents(vim.api.nvim_buf_get_name(0)) do
if vim.fn.isdirectory(dir .. "/.git") == 1 then
root_dir = dir
break
end
end
local border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
@ -64,8 +72,16 @@ local on_attach = function(client, bufnr)
end
end
local function prettier_command()
if vim.fs.basename(root_dir .. "node_modules/prettier") then
return "npx prettier"
else
return "prettier"
end
end
local prettier = {
formatCommand = [[prettier --stdin-filepath ${INPUT} ${--tab-width:tab_width}]],
formatCommand = prettier_command() .. [[ --stdin-filepath ${INPUT} ${--tab-width:tab_width}]],
formatStdin = true,
}
@ -92,7 +108,7 @@ local shellcheck = {
local servers = {
efm = {
filetypes = { "typescript", "typescriptreact", "sh" },
filetypes = { "typescript", "typescriptreact", "sh", "php" },
init_options = { documentFormatting = true },
settings = {
rootMarkers = { ".git/" },
@ -100,6 +116,7 @@ local servers = {
typescript = { prettier, eslint },
typescriptreact = { prettier, eslint },
sh = { shellcheck },
php = { prettier },
},
},
},