rafcamlet/tabline-framework.nvim

How to add tab close button

j-xella opened this issue · 4 comments

Basically, it... How to add clickable text on the tab line, that, when clicked would call my function

Hi @j-xella !

So I've added a few things to make this possible: dae4732
These features are not yet documented, and the API may change, but should rather remain the same.

Here is an example:

local render = function(f)
  f.make_tabs(function(info)
    f.add(' ' .. info.index .. ' ')

    f.add_btn('click here', function()
      print('Hello from ' .. info.index .. ' tab!')
    end)

    f.add ' '

    f.add_btn({'or here', fg = '#e5c07b' }, function(data)
      print('You clicked ' .. data.clicks .. ' times with ' .. data.mouse_btn ..  ' mouse button' )
    end)

    f.close_tab_btn { ' x ', fg = '#e86671' }
  end)
end

Arguments are like in add function. The only difference is that the add_btn, accepts a function to be called as a second argument. Note that close_tab_btn is a native component for closing tabs, it will print a warning if you try to call it outside the make_tabs function.

I'm keeping this issue open for now. If you have any questions/suggestions fell free to comment.

Hello @rafcamlet, how are you?

I love your plugin 🤩, it's fun to be able to customize the tab bar.. But, it would be interesting if there was a function to create a button to close the buffers.

Hi @farias-hecdin !
I'm glad to hear that. ❤️

It already exists. The close_tab_btn function, mentioned in a comment above, is already on the master branch. Also, I've just added missing info to the readme https://github.com/rafcamlet/tabline-framework.nvim#fclose_tab_btn

Hi @farias-hecdin ! I'm glad to hear that. heart

It already exists. The close_tab_btn function, mentioned in a comment above, is already on the master branch. Also, I've just added missing info to the readme https://github.com/rafcamlet/tabline-framework.nvim#fclose_tab_btn

Great thanks.!! 👍