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,6 +19,16 @@ if data_exists then
end end
end end
local run = 0
local data_exists, frmt = pcall(require, "custom.format_onsave")
if not data_exists then
run = 1
end
if frmt.disable == 0 then
run = 1
end
if run == 1 then
null_ls.setup({ null_ls.setup({
debug = false, debug = false,
sources = sources, sources = sources,
@ -36,20 +46,26 @@ null_ls.setup({
-- diagnostics.eslint_d, -- diagnostics.eslint_d,
--}, --},
-- on_attach = function(client, bufnr) on_attach = function(client, bufnr)
-- --if client.resolved_capabilities.document_formatting then --if client.resolved_capabilities.document_formatting then
-- --vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.format{async=true}") --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
-- 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(),