feature to rename tabs (#574)
* (feat) add rename * remove tabname if LualineRenameTab is ran without args * document LualineRenameTab Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>
This commit is contained in:
parent
2bddaf0508
commit
d52ff470de
18
README.md
18
README.md
|
@ -617,6 +617,24 @@ tabline = {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Buffers
|
||||||
|
Shows currently open buffers. Like bufferline . See
|
||||||
|
[buffers options](#buffers-component-options)
|
||||||
|
for all builtin behaviors of buffers component.
|
||||||
|
|
||||||
|
#### Tabs
|
||||||
|
Shows currently open tab. Like usual tabline. See
|
||||||
|
[tabs options](#tabs-component-options)
|
||||||
|
for all builtin behaviors of tabs component.
|
||||||
|
You can also use `:LualineRenameTab` to set a name for a tabpage.
|
||||||
|
For example:
|
||||||
|
```vim
|
||||||
|
:LualineRenameTab Project_K
|
||||||
|
````
|
||||||
|
It's useful when you're using rendering mode 2/3 in tabs.
|
||||||
|
To unname a tablage run `:LualineRenameTab` without argument.
|
||||||
|
|
||||||
|
#### Tabline as statusline
|
||||||
You can also completely move your statusline to a tabline by configuring
|
You can also completely move your statusline to a tabline by configuring
|
||||||
`lualine.tabline` and disabling `lualine.sections` and `lualine.inactive_sections`:
|
`lualine.tabline` and disabling `lualine.sections` and `lualine.inactive_sections`:
|
||||||
|
|
||||||
|
|
|
@ -645,9 +645,39 @@ more traditional tabline/bufferline.
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
You can also completely move your statusline to a tabline by configuring
|
*lualine-Buffers*
|
||||||
`lualine.tabline` and disabling `lualine.sections` and
|
|
||||||
`lualine.inactive_sections`:
|
Buffers Shows currently open buffers. Like
|
||||||
|
bufferline. See
|
||||||
|
|lualine-buffers-options| for all
|
||||||
|
builtin behaviors of buffers component.
|
||||||
|
|
||||||
|
|
||||||
|
*lualine-Tabs*
|
||||||
|
|
||||||
|
Tabs Shows currently open tab. Like usual
|
||||||
|
tabline. See |lualine-tabs-options| for
|
||||||
|
all builtin behaviors of tabs component.
|
||||||
|
You can also use `:LualineRenameTab` to
|
||||||
|
set a name for a tabpage. For example:
|
||||||
|
|
||||||
|
|
||||||
|
>
|
||||||
|
:LualineRenameTab Project_K
|
||||||
|
<
|
||||||
|
|
||||||
|
|
||||||
|
It’s useful when you’re using rendering mode 2/3 in tabs. To unname a
|
||||||
|
tablage run `:LualineRenameTab` without argument.
|
||||||
|
|
||||||
|
*lualine-Tabline-as-statusline*
|
||||||
|
|
||||||
|
Tabline as statusline You can also completely move your
|
||||||
|
statusline to a tabline by configuring
|
||||||
|
`lualine.tabline` and disabling
|
||||||
|
`lualine.sections` and
|
||||||
|
`lualine.inactive_sections`:
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
tabline = {
|
tabline = {
|
||||||
|
|
|
@ -167,6 +167,17 @@ vim.cmd([[
|
||||||
function! LualineSwitchTab(tabnr, mouseclicks, mousebutton, modifiers)
|
function! LualineSwitchTab(tabnr, mouseclicks, mousebutton, modifiers)
|
||||||
execute a:tabnr . "tabnext"
|
execute a:tabnr . "tabnext"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! LualineRenameTab(...)
|
||||||
|
if a:0 == 1
|
||||||
|
let t:tabname = a:1
|
||||||
|
else
|
||||||
|
unlet t:tabname
|
||||||
|
end
|
||||||
|
redrawtabline
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! -nargs=? LualineRenameTab call LualineRenameTab("<args>")
|
||||||
]])
|
]])
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -14,6 +14,10 @@ end
|
||||||
--- of the tab.
|
--- of the tab.
|
||||||
---@return string
|
---@return string
|
||||||
function Tab:label()
|
function Tab:label()
|
||||||
|
local custom_tabname = vim.t[self.tabnr].tabname
|
||||||
|
if custom_tabname and custom_tabname ~= '' then
|
||||||
|
return custom_tabname
|
||||||
|
end
|
||||||
local buflist = vim.fn.tabpagebuflist(self.tabnr)
|
local buflist = vim.fn.tabpagebuflist(self.tabnr)
|
||||||
local winnr = vim.fn.tabpagewinnr(self.tabnr)
|
local winnr = vim.fn.tabpagewinnr(self.tabnr)
|
||||||
local bufnr = buflist[winnr]
|
local bufnr = buflist[winnr]
|
||||||
|
|
Loading…
Reference in New Issue