Git Product home page Git Product logo

Comments (6)

RobGThai avatar RobGThai commented on June 11, 2024 1

If someone looking for a workaround of this situation. I'm currently using nvim-bufdel to solve this.

I still think such foundation action should be consider alongside other "close" commands tho.

from bufferline.nvim.

danyelvarejao avatar danyelvarejao commented on June 11, 2024 1

Also, I don't understand the reason for this, I had to use a new function to work around the situation, something like:
I had some issues using the plugin with nvim-tree, so I had to resort to this.

function close_current_buffer()
  vim.api.nvim_command('NvimTreeClose')
  vim.api.nvim_command('bdelete')
  vim.api.nvim_command('NvimTreeOpen')
  vim.api.nvim_command('wincmd l')
end

vim.keymap.set('n', '<leader>q',     '<Cmd>lua close_current_buffer()<CR>', {})

It would be great to have that, especially since it's very common to close the current buffer.

from bufferline.nvim.

akinsho avatar akinsho commented on June 11, 2024 1

I've mentioned in previous issues. I don't intend to add this command, as to be honest, I did not want to add any buffer management commands. You have to understand that this plugin is mainly about seeing buffers not about closing them or opening them. There are so many plugins that people have worked on to add solutions for that like bufdel. This isn't a place where I'm going to add more of this and frankly I would deprecate what exists already if I could, but people now depend on it but I certainly won't look to add to it cuz it just adds more surface area for bugs and feature requests

from bufferline.nvim.

ThaiDuy12345 avatar ThaiDuy12345 commented on June 11, 2024 1

I use these simple tricks, no plugins needed. Alt + c for navigate to the left buffer then close the old one, Alt + Shift + C for the opposite way

  vim.keymap.set("n", "<A-c>", function()
    local buffer_id = vim.fn.bufnr()

    if buffer_id then
      vim.cmd("<cmd>BufferLineCyclePrev")
      vim.cmd("<cmd>bdelete "..buffer_id)
    end
  end)

  vim.keymap.set("n", "<A-C>", function()
    local buffer_id = vim.fn.bufnr()

    if buffer_id then
      vim.cmd("<cmd>BufferLineCycleNext")
      vim.cmd("<cmd>bdelete "..buffer_id)
    end
  end)

from bufferline.nvim.

bluss avatar bluss commented on June 11, 2024

lazyvim distribution includes https://github.com/echasnovski/mini.bufremove which solves this. I didn't realize it wasn't part of bufferline in fact.

from bufferline.nvim.

PabloPicose avatar PabloPicose commented on June 11, 2024

I use these simple tricks, no plugins needed. Alt + c for navigate to the left buffer then close the old one, Alt + Shift + C for the opposite way

  vim.keymap.set("n", "<A-c>", function()
    local buffer_id = vim.fn.bufnr()

    if buffer_id then
      vim.cmd("<cmd>BufferLineCyclePrev")
      vim.cmd("<cmd>bdelete "..buffer_id)
    end
  end)

  vim.keymap.set("n", "<A-C>", function()
    local buffer_id = vim.fn.bufnr()

    if buffer_id then
      vim.cmd("<cmd>BufferLineCycleNext")
      vim.cmd("<cmd>bdelete "..buffer_id)
    end
  end)

Great solution, but for me, the cmd function does not expect "cmd" text, so I fixed like this:

vim.keymap.set('n', '<A-c>', function()
  local buffer_id = vim.fn.bufnr()
  vim.cmd 'BufferLineCyclePrev'
  vim.cmd('bdelete ' .. buffer_id)
end, { desc = 'Close current buffer and go to previous' })

vim.keymap.set('n', '<A-C>', function()
  local buffer_id = vim.fn.bufnr()
  vim.cmd 'BufferLineCycleNext'
  vim.cmd('bdelete ' .. buffer_id)
end, { desc = 'Close current buffer and go to next' })


from bufferline.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.