Skip to content

Open nvdash when delete all buffer action and last empty buffer [no name] #2896

Closed Answered by siduck
asapdotid asked this question in Q&A
Discussion options

You must be logged in to vote

@asapdotid your method is alright but no need of vim.schedule in 2nd autocmd, and idk why we need the augroup or pattern

vim.api.nvim_create_autocmd({ "BufEnter", "BufDelete", "FileType" }, {
  callback = function(args)
    if args.event == "FileType" then
      vim.o.showtabline = vim.bo.ft == "nvdash" and 0 or 2
      return
    end

    local buf = args.buf

    if not vim.bo[buf].buflisted then
      return
    end

    vim.schedule(function()
      if #vim.t.bufs == 1 and vim.api.nvim_buf_get_name(buf) == "" then
        vim.cmd "Nvdash"
      end
    end)
  end,
})

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@asapdotid
Comment options

@siduck
Comment options

@asapdotid
Comment options

@siduck
Comment options

Answer selected by asapdotid
@asapdotid
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants