1
0
Fork 0

nvim: Formatter improvements

This commit is contained in:
Daniel Kempkens 2023-10-14 19:55:46 +02:00
parent 303bbd8294
commit 085a63313e
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM

View file

@ -12,7 +12,8 @@
(usercmd :FormatEnableBuffer mod.enable-for-buffer
{:desc "Enable Formatting for the current buffer"})
(aucmd :BufWritePre
{:callback #(mod.maybe-format-buffer $1.buf)
{:pattern "*"
:callback #(mod.maybe-format-buffer $1.buf)
:group augroup
:desc "Run Formatter before saving"})))
@ -38,6 +39,9 @@
(fn mod.maybe-format-buffer [bufnr]
(let [ft vim.bo.filetype]
(if (= b.nifoc_formatter_disabled 1) nil
(conform.format {: bufnr :lsp_fallback (format-with-lsp? ft)}))))
(conform.format {: bufnr
:async false
:timeout_ms 1000
:lsp_fallback (format-with-lsp? ft)}))))
mod)