tabline-framework.nvim icon indicating copy to clipboard operation
tabline-framework.nvim copied to clipboard

How to add tab close button

Open j-xella opened this issue 2 years ago • 4 comments

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

j-xella avatar Nov 02 '22 10:11 j-xella

Hi @j-xella !

So I've added a few things to make this possible: https://github.com/rafcamlet/tabline-framework.nvim/commit/dae473260d577b6c2d975293e81c9b78d7716ec3 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.

rafcamlet avatar Nov 05 '22 15:11 rafcamlet

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.

farias-hecdin avatar Dec 31 '22 19:12 farias-hecdin

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

rafcamlet avatar Jan 04 '23 19:01 rafcamlet

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.!! 👍

farias-hecdin avatar Jan 09 '23 19:01 farias-hecdin