fix: disable format if lsp undefined

This commit is contained in:
asep komarudin 2024-02-23 19:49:22 +07:00
parent 8dee08aca6
commit 9fd84a85f3
6 changed files with 30 additions and 5 deletions

View file

@ -7,8 +7,13 @@ if frmt.format_on_save == 1 then
run = 1
end
local buf_clients = vim.lsp.buf_get_clients()
if next(buf_clients) == nil then
run = 0
end
if run == 1 then
function format_filter(client)
function FORMAT_FILTER(client)
local filetype = vim.bo.filetype
local n = require("null-ls")
local s = require("null-ls.sources")
@ -23,11 +28,12 @@ if run == 1 then
return false
end
end
vim.cmd([[
augroup _lsp
autocmd!
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=2000 ,filter=format_filter}
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=2000 ,filter=FORMAT_FILTER}
augroup end
]])
end

View file

@ -51,5 +51,8 @@ tokyonight.setup({
bg = colors.none,
fg = "#e0af68",
}
highlights.Underlined = {
underline = false,
}
end,
})

View file

@ -113,6 +113,12 @@ material_icon.setup({
web_devicons.setup({
override = material_icon.get_icons(),
override_by_filename = {
[".htaccess"] = {
icon = "󰛓",
color = "#C63C17",
cterm_color = "240",
name = "htaccess",
},
[".huskyrc"] = {
icon = "󰩃",
color = "#ffffff",