Help converting a function to 0.10.0

Hey, I had this old function to confirm on close tab. I notice it broke, but it’s not exactly clear what is wrong.

I see one function is deprecated as well.

I’ve read through 0.10.0 briefly but I’m less familiar of what all these nvim functions are and atm i dont have time to really dig into it.

Is there a quick fix anyone could help me out with?

  local function close_tab(force)
    -- check if standard file buffer or a new unsaved buffer, otherwise do standard
    -- bd as barbar won't handle quickfix window, neotree, etc
    local bufid = vim.api.nvim_get_current_buf()
    local bufname = vim.fn.bufname(bufid)
    local buftype = vim.api.nvim_buf_get_option(bufid, "buftype")
    if (buftype == "" and bufname ~= "") then
      vim.cmd(force and "BufferClose!" or "BufferClose")
    else
      vim.cmd(force and "bd!" or "bd")
    end
  end

  local function confirm_close_tab()
    if buffer_modified() then
      local choice = vim.fn.confirm("Save changes?", "&Yes\n&No\n&Cancel")
      if choice == 2 then
        close_tab(true)
      end
    else
      close_tab(false)
    end
  end

Well, the error comes from line 80 of your config file, which is not included in the snippet you posted. That makes it hard for anyone to help. Based on the error message, all i can suggest is to check :h netrw-ml_get which seems to talk about ml_get errors. Can’t help more as I have always permanently disabled netrw:

    vim.g.loaded_netrw = 1
    vim.g.loaded_netrwPlugin = 1