lukas-reineke / lsp-format.nvim

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

Infinite loop of formatting #77

Closed MaximilianGaedig closed 10 months ago

MaximilianGaedig commented 10 months ago

After some update when I have autosave enabled and do :w it infinitely loops, once it gets indented in the one way, eslint shows an error, then it gets indented in the other way, and it is an infinite loop until I exit neovim, this happens when opening neovim, opening some (1 or more) random file with formatting support, doing :w and that's it, this might be something with my configuration or with the plugin, I would greatly appreciate if you can point me into the right direction

lukas-reineke commented 10 months ago

Please share your configuration and steps to reproduce the issue.

suconakh commented 10 months ago

Same, infinite loop of file writing starting at dfa0ada326e6b5038c8efb152e9e88f4ad12b14b. I am using lsp-zero.

Minimal reproducible example ```lua local lazypath = vim.fn.stdpath'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system{ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=main', -- latest stable release lazypath, } end vim.opt.rtp:prepend(lazypath) require'lazy'.setup{ { 'VonHeikemen/lsp-zero.nvim', branch = 'v2.x', lazy = false, dependencies = { { 'neovim/nvim-lspconfig' }, { 'lukas-reineke/lsp-format.nvim' }, { 'williamboman/mason.nvim', build = function() pcall(vim.cmd, 'MasonUpdate') end, }, { 'williamboman/mason-lspconfig.nvim' }, }, config = function() local format = require'lsp-format' local lsp = require'lsp-zero' lsp.preset'recommended' format.setup{} lsp.on_attach(function(client, bufnr) if client.supports_method'textDocument/formatting' then format.on_attach(client) end end) lsp.setup() lsp.ensure_installed{ 'lua_ls' } end, }, } ```
Video Here at the end i am pressing `u` to show how many writes were done https://github.com/lukas-reineke/lsp-format.nvim/assets/6158938/e758fc9b-c8b9-47a7-a4a3-a900106c2994
lukas-reineke commented 10 months ago

Released a fix, please check. If it's still broken, reopen the issue.

MaximilianGaedig commented 10 months ago

Yes! it works, thank you very much!! Didn't check on the issue until now, amazing that you released a fix on the same day! Now I realized how important this extension is to me