mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-23 01:08:53 +02:00
update
This commit is contained in:
parent
e52b14c920
commit
90d02a0f5b
5 changed files with 28 additions and 26 deletions
|
@ -1,27 +1,22 @@
|
|||
local data_exists, frmt = pcall(require, "custom.format_onsave")
|
||||
if data_exists then
|
||||
if frmt.disable == 0 then
|
||||
function format_filter(client)
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require("null-ls")
|
||||
local s = require("null-ls.sources")
|
||||
local method = n.methods.FORMATTING
|
||||
local available_formatters = s.get_available(filetype, method)
|
||||
function format_filter(client)
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require("null-ls")
|
||||
local s = require("null-ls.sources")
|
||||
local method = n.methods.FORMATTING
|
||||
local available_formatters = s.get_available(filetype, method)
|
||||
|
||||
if #available_formatters > 0 then
|
||||
return client.name == "null-ls"
|
||||
elseif client.supports_method("textDocument/formatting") then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
vim.cmd([[
|
||||
if #available_formatters > 0 then
|
||||
return client.name == "null-ls"
|
||||
elseif client.supports_method("textDocument/formatting") then
|
||||
return true
|
||||
else
|
||||
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=1000 ,filter=format_filter}
|
||||
augroup end
|
||||
]])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue