Giter Site home page Giter Site logo

Comments (7)

willothy avatar willothy commented on June 29, 2024 1

Agreed! I'll look into this ASAP :)

EDIT: Not able to reproduce with my config, but I'll try your minimal config later today.

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024 1

Awesome, glad I could help!

from flatten.nvim.

Bekaboo avatar Bekaboo commented on June 29, 2024

@willothy Maybe it can be solved by changing the config of flattrn.nvim. I actually don't consider it bug since there's no errors nor warning, just the behavior is a little strange.

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024

@willothy Maybe it can be solved by changing the config of flattrn.nvim. I actually don't consider it bug since there's no errors nor warning, just the behavior is a little strange.

Yeah, likely can be resolved in the config but I'll still take a look. Might be worth adding the solution to the readme in case others experience this.

from flatten.nvim.

Bekaboo avatar Bekaboo commented on June 29, 2024

Not able to reproduce with my config

Mind sharing your config? Is it still the same as the config your shared in the READE? I tried to use that config but get errors when I save the gitrebase file, so I removed all the togglterm.toggle(0) calls -- then the errors are gone but I get the strange behavior in the screen recording.

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024

Not able to reproduce with my config

Mind sharing your config? Is it still the same as the config your shared in the READE? I tried to use that config but get errors when I save the gitrebase file, so I removed all the togglterm.toggle(0) calls -- then the errors are gone but I get the strange behavior in the screen recording.

My config is not the same anymore - here's the link.

I use a custom toggleterm terminal but hopefully it will still work? It may be related to the open setting.

Note that I also have $VISUAL set to nvim -b for blocking.

Let me know if that helps!

from flatten.nvim.

Bekaboo avatar Bekaboo commented on June 29, 2024

@willothy Thanks for sharing your config.

After some small modification it works like a charm -- the terminal now automatically reopens itself after blocking and no more error is thrown. Not sure how it functions exactly but for future references the following is a config that Just Woks:

local ok, toggleterm = pcall(require, 'toggleterm')
if not ok then
  print('flatten: toggleterm not found')
  toggleterm = {
    toggle = function(_) end,
  }
end

require('flatten').setup({
  window = {
    open = 'alternate',
  },
  callbacks = {
    should_block = function(argv)
      for _, arg in ipairs(argv) do
        if (arg:find('.git/rebase-merge', 1, true)) then
          return true
        end
      end
      return false
    end,
    post_open = function(bufnr, winnr, ft, is_blocking)
      if is_blocking or ft == 'gitcommit' or ft == 'gitrebase' then
        -- Hide the terminal while it's blocking
        toggleterm.toggle(0)
      else
        -- If it's a normal file, just switch to its window
        vim.api.nvim_set_current_win(winnr)
      end
      -- If the file is a git commit or git rebase, create one-shot autocmd to
      -- delete its buffer on write
      if ft == 'gitcommit' or ft == 'gitrebase' then
        vim.api.nvim_create_autocmd('BufWritePost', {
          buffer = bufnr,
          once = true,
          callback = function()
            -- This is a bit of a hack, but if you run bufdelete
            -- immediately the shell can occasionally freeze
            vim.defer_fn(function()
              vim.api.nvim_buf_delete(bufnr, {})
            end, 50)
          end,
        })
      end
    end,
    block_end = function()
      -- After blocking ends (for a git commit, etc), reopen the terminal
      vim.defer_fn(function()
        toggleterm.toggle(0)
      end, 50)
    end,
  },
})

from flatten.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.