lukas-reineke / lsp-format.nvim

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

If two files are edited and saved at the same time (:wa), the contents of one file will be overwritten by the contents of the other #74

Closed ryoppippi closed 1 year ago

ryoppippi commented 1 year ago

If two files are edited and saved at the same time (:wa), the contents of one file will be overwritten by the contents of the other

https://github.com/lukas-reineke/lsp-format.nvim/assets/1560508/71157391-e86e-4675-bdef-a76c5f7d3f00

Here is my config for lsp-format

local spec = {
  "lukas-reineke/lsp-format.nvim",
  opts = { sync = true },
  enabled = true,
  init = function()
    local on_attach = require("core.plugin").on_attach
    on_attach(function(client, _)
      local enableFormat = client.server_capabilities.documentFormattingProvider
      if enableFormat then
        require("lsp-format").on_attach(client)
        -- vim.cmd([[
        --       cabbrev wq execute "Format sync" <bar> wq
        --       cabbrev wqa bufdo execute "Format sync" <bar> wa <bar> q
        --     ]])
      end
    end)
  end,
}
return spec
lukas-reineke commented 1 year ago

I cannot reproduce this. Can you make a minimal config and steps to cause the issue?

ryoppippi commented 1 year ago

Thanks. I made minimal config, but I also cannot reproduce. I will investigate the cause a little more.

towry commented 1 year ago

@lukas-reineke While attempting to save two tsx files today, I ran into this same issue!

I use the neovim head version.

towry commented 1 year ago

branch bug/writing-inactive-buffer not work.

FelipeLema commented 1 year ago

forked here with a fix... seems to be working

lukas-reineke commented 1 year ago

Thanks,

I think I probably had already fixed this in #59 but I forgot to merge the PR :man_facepalming:

I made a nicer version now in #75 Can someone check if this does actually fix it?

ryoppippi commented 1 year ago

Looks good!

lukas-reineke commented 1 year ago

Made a new release

Please open the issue again if it is still broken

Invertisment commented 1 year ago

Today I updated my plugins and it fails with an error of get_clients because my function doesn't allow that. How do I debug this? I downgraded this plugin to v2.5.1 and it doesn't fail anymore :shrug:

lukas-reineke commented 1 year ago

Sorry, get_clients is nightly only. I released a fix.

ryoppippi commented 10 months ago

Hi! I still got this error.

madhermit commented 10 months ago

Getting this error as well with commit version 31fc