fix(nvim): lsp formatting
This commit is contained in:
parent
f99900d196
commit
24b6fdb455
1 changed files with 7 additions and 4 deletions
|
|
@ -80,12 +80,15 @@ function M.on_attach(client, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.format(opts)
|
function M.format(opts)
|
||||||
local ok, guard = pcall(require, 'guard')
|
local ok, ft_handler = pcall(require, 'guard.filetype')
|
||||||
if ok then
|
if ok then
|
||||||
guard.fmt()
|
local conf = ft_handler[vim.bo.filetype]
|
||||||
else
|
if conf and conf.formatter and #conf.formatter > 0 then
|
||||||
vim.lsp.buf.format(opts or { async = true })
|
require('guard').fmt()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
vim.lsp.buf.format(opts or { async = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue