Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neogit breaks when using Noice.nvim #515

Closed
redyf opened this issue May 27, 2023 · 3 comments
Closed

Neogit breaks when using Noice.nvim #515

redyf opened this issue May 27, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@redyf
Copy link

redyf commented May 27, 2023

Description

Everytime after confirming a commit on neogit, it spams an error. I noticed that it only happens when noice.nvim plugin is enabled. LazyGit works fine with noice.

Neovim version

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

NixOS 23.11.20230523.d30

Steps to reproduce

  1. Enable noice.nvim and neogit
  2. Stage files and try to commit
  3. Confirm commit

Expected behavior

Message was succesfully commited after confirmation with no errors.

Actual behavior

image
Neogit spam an error after confirming the commit, it keeps showing up until I close neovim entirely!

Minimal config

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup({
    {
      "wbthomason/packer.nvim",
      {
        "TimUntersberger/neogit",
        requires = {
          { "nvim-lua/plenary.nvim" },
          { "sindrets/diffview.nvim" },
        },
        config = function()
          print("loaded neogit")
          require("neogit").setup()
        end,
      },
    },
   {
     "folke/noice.nvim",
     event = "VeryLazy",
     config = function()
       require("noice").setup {
         lsp = {
           hover = {
             enabled = false,
           },
           override = {
             ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
             ["vim.lsp.util.stylize_markdown"] = true,
             ["cmp.entry.get_documentation"] = true,
           },
           signature = {
             enabled = false,
           },
        },
  
         presets = {
           bottom_search = true,         -- use a classic bottom cmdline for search
           command_palette = true,       -- position the cmdline and popupmenu together
           long_message_to_split = true, -- long messages will be sent to a split
           inc_rename = false,           -- enables an input dialog for inc-rename.nvim
           lsp_doc_border = false,       -- add a border to hover docs and signature help
        },
       }
     end,
     dependencies = {
       "MunifTanjim/nui.nvim",
     },
   },

    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  })
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing neogit and dependencies.")
  vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
@redyf redyf added the bug Something isn't working label May 27, 2023
@ten3roberts
Copy link
Member

ten3roberts commented May 27, 2023

I also encountered the exact same issue when a confirmation dialogue popped up, though I haven't used noice in some time.

Seems to perhaps be an issue with vim.fn.confirm no longer blocking the editor as it is now async as it needs to display a floating window render it.

I am not sure how noice does it; the default vim behaviour of vimscript confirm() is to stop/freeze everything and render a special prompt in the echo area, and then resume the scripting engine from where it was, none the wiser of the time passed.

folke/noice.nvim#388
folke/noice.nvim#337
folke/noice.nvim#232
neovim/neovim#20416 (maybe)

Solution proposed: folke/noice.nvim#232 (comment)

PR in neogit #441 with some opinionated and breaking changes. I will resurrect the discussion there and see what we can do.

Thank you for your help in bringing this up.

@ten3roberts ten3roberts self-assigned this May 27, 2023
@IndianBoy42
Copy link
Contributor

IndianBoy42 commented Aug 13, 2023

If its a problem of vim.fn.confirm being called from BufUnload (and causing buffer switching due to the nui popup), then could a potential solution be to simply "save" the contents of the buffer (and whatever is needed) and defer doing the actual work to after BufUnload? Like using vim.schedule or vim.defer_fn.

@CKolkey
Copy link
Member

CKolkey commented Aug 13, 2023

I've got some ideas for this - might be able to get to it soon.

@CKolkey CKolkey mentioned this issue Apr 12, 2024
4 tasks
@CKolkey CKolkey closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants