fix null-ls format onsave

This commit is contained in:
asep komarudin 2023-03-01 22:16:37 +07:00
parent 3a8ccb5ffb
commit 0c12f6e382
2 changed files with 61 additions and 33 deletions

View file

@ -19,37 +19,53 @@ if data_exists then
end end
end end
null_ls.setup({ local run = 0
debug = false, local data_exists, frmt = pcall(require, "custom.format_onsave")
sources = sources, if not data_exists then
--sources = { run = 1
--formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), end
--formatting.prettier, if frmt.disable == 0 then
-- formatting.prettierd, run = 1
-- formatting.black.with({ extra_args = { "--fast" } }), end
-- formatting.stylua,
-- formatting.eslint_d,
-- formatting.google_java_format,
-- formatting.phpcbf,
-- formatting.clang_format,
-- diagnostics.flake8
-- diagnostics.eslint_d,
--},
-- on_attach = function(client, bufnr) if run == 1 then
-- --if client.resolved_capabilities.document_formatting then null_ls.setup({
-- --vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.format{async=true}") debug = false,
-- --end sources = sources,
-- if client.supports_method("textDocument/formatting") then --sources = {
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) --formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
-- vim.api.nvim_create_autocmd("BufWritePre", { --formatting.prettier,
-- group = augroup, -- formatting.prettierd,
-- buffer = bufnr, -- formatting.black.with({ extra_args = { "--fast" } }),
-- callback = function() -- formatting.stylua,
-- vim.lsp.buf.format({ bufnr = bufnr }) -- formatting.eslint_d,
-- -- vim.lsp.buf.formatting_sync() -- formatting.google_java_format,
-- end, -- formatting.phpcbf,
-- }) -- formatting.clang_format,
-- end -- diagnostics.flake8
-- end, -- diagnostics.eslint_d,
}) --},
on_attach = function(client, bufnr)
--if client.resolved_capabilities.document_formatting then
--vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.format{async=true}")
--end
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
-- vim.lsp.buf.formatting_sync()
end,
})
end
end,
})
else
null_ls.setup({
debug = false,
sources = sources,
})
end

View file

@ -7,6 +7,18 @@ local material_icon_ok, material_icon = pcall(require, "nvim-material-icon")
if not material_icon_ok then if not material_icon_ok then
return return
end end
material_icon.setup({
override = {
["mjs"] = {
icon = "",
color = "#efd81d",
cterm_color = "220",
name = "Mjs",
},
},
color_icons = true,
default = true,
})
web_devicons.setup({ web_devicons.setup({
override = material_icon.get_icons(), override = material_icon.get_icons(),