Replace lsp/nullls format on save with conform.nvim
This commit is contained in:
parent
4ed2e26529
commit
8f912a52df
3 changed files with 26 additions and 39 deletions
|
|
@ -24,26 +24,6 @@ local format_on_save = function(client, bufnr)
|
|||
end
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if not client then return end
|
||||
|
||||
local LSP_CLIENT_NAMES_FORMAT_ON_SAVE = { "lua_ls", "jdtls", "gopls", "taplo", "yamlls" }
|
||||
for _, client_name_autoformat in ipairs(LSP_CLIENT_NAMES_FORMAT_ON_SAVE) do
|
||||
if client.name == client_name_autoformat and client.server_capabilities.documentFormattingProvider 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,
|
||||
})
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = false,
|
||||
virtual_text = false,
|
||||
|
|
@ -110,24 +90,11 @@ return {
|
|||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
local kulala_fmt = {
|
||||
method = null_ls.methods.FORMATTING,
|
||||
filetypes = { "http" },
|
||||
generator = null_ls.formatter({
|
||||
command = "kulala-fmt",
|
||||
args = { "format", "--stdin" },
|
||||
to_stdin = true,
|
||||
}),
|
||||
}
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
format_on_save(client, bufnr)
|
||||
end,
|
||||
sources = {
|
||||
null_ls.builtins.formatting.prettierd,
|
||||
kulala_fmt,
|
||||
|
||||
null_ls.builtins.diagnostics.dotenv_linter,
|
||||
null_ls.builtins.diagnostics.editorconfig_checker,
|
||||
null_ls.builtins.diagnostics.proselint,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue