Fork me on GitHub
#vim
<
2021-10-21
>
Ty05:10:32

How do people typically handle formatting from within nvim? I'd like to set up autoformat on save using something like cljfmt, but without using vim-fireplace

dharrigan05:10:45

I tend to format as I just go along/visit a file, no hooks or anything

dharrigan05:10:10

Sometimes I run cljfmt from the prompt across a directory

dominicm11:10:38

The problem with format-on-write on linux is that it loses your marks, generally. https://github.com/vim-autoformat/vim-autoformat can call out to cljfmt presumably @tylertracey09. As that's likely to be slow, you might want to look at something async like https://github.com/lukas-reineke/format.nvim.

Proctor13:10:02

I have an autocommand that calls out to lsp to format the file

timo14:10:25

How did you solve this? Do you have a solution that formats a visual selection?

Proctor14:10:33

I have that too

Proctor14:10:26

in fennel, but these are the two settings: (xbufmap :<leader>fa "lua vim.lsp.buf.formatting_sync()") and (nvim.ex.autocmd :BufWritePre :<buffer> :lua "vim.lsp.buf.formatting_sync()") using neovim’s lsp

👍 1
Proctor14:10:58

but had this with vim-lsp before, just using the api for that one

Jason Paterson15:10:26

function _G.lsp_formatexr()
  vim.lsp.buf.range_formatting({}, { vim.v.lnum, 0 }, { vim.v.lnum + vim.v.count, 0 })
  return 0
end

if client.resolved_capabilities.document_range_formatting then
  vim.bo.formatexpr = 'v:lua.lsp_formatexr()'
end
I have this to format using gq

👍 1
dominicm21:10:01

That isn't built in @UF3DZS1DF? Travesty.