formating
This commit is contained in:
parent
0eea4c8dab
commit
16e0df81f4
5 changed files with 23 additions and 13 deletions
|
|
@ -30,14 +30,17 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if not client then return end
|
||||
|
||||
if vim.bo.filetype == "lua" or client.name == "jdtls" then
|
||||
-- Format the current buffer on save
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
|
||||
end,
|
||||
})
|
||||
local LSP_CLIENT_NAMES_FORMAT_ON_SAVE = { "lua_ls", "jdtls" }
|
||||
for _, client_name_autoformat in ipairs(LSP_CLIENT_NAMES_FORMAT_ON_SAVE) do
|
||||
if client.name == client_name_autoformat then
|
||||
-- Format the current buffer on save
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
@ -56,7 +59,8 @@ return {
|
|||
tools_to_install = {
|
||||
"lua-language-server", "vtsls", "ruff", "mypy", "black",
|
||||
"pyright", "tailwindcss-language-server",
|
||||
"eslint-lsp", "lemminx", "gopls"
|
||||
"eslint-lsp", "lemminx", "gopls", "prettierd", "dotenv-linter",
|
||||
"editorconfig-checker", "proselint"
|
||||
}
|
||||
},
|
||||
config = function(_, opts)
|
||||
|
|
@ -82,7 +86,11 @@ return {
|
|||
format_on_save(client, bufnr)
|
||||
end,
|
||||
sources = {
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.formatting.prettierd,
|
||||
|
||||
null_ls.builtins.diagnostics.dotenv_linter,
|
||||
null_ls.builtins.diagnostics.editorconfig_checker,
|
||||
null_ls.builtins.diagnostics.proselint
|
||||
},
|
||||
})
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue