lukas-reineke / lsp-format.nvim

A wrapper around Neovims native LSP formatting.
559 stars 27 forks source link

feat: add "on_save" option #66

Open adoyle-h opened 1 year ago

adoyle-h commented 1 year ago

User can disable formatting on save.

adoyle-h commented 1 year ago

If there are more than 1 LSP attached to the buffer, they will overwrite each other. If there is one LSP with on_save = false, and one with on_save = true, the autocommand will still be created. And on save, even the first LSP with on_save = false will format the buffer. We need to check if on_save is true for each client that is attached to the buffer.

This won't happen. Because format_options is relative to buffer filetype, not LSP client. The format_options are same for same filetype, even on_attach invoked with different client.

local format_options = vim.tbl_deep_extend('keep', M.format_options[vim.bo.filetype] or {}, { on_save = true })
lukas-reineke commented 1 year ago

This won't happen. Because format_options is relative to buffer filetype, not LSP client

Right, sorry. It's been a while since I worked on this. Ignore what I said