Comments (7)
I think this is workable. I plan to improve the configuration experience, use less code to configure these things. I will update in this issue if that is completed.
from tabby.nvim.
Even more important is the buf modified sign. What do u thing about this:
local function win_label(winid, top)
local icon = top and '' or ''
local fname = require("tabby.filename").tail(winid)
local extension = vim.fn.fnamemodify(fname, ':e')
local fileIcon = require'nvim-web-devicons'.get_icon(filename, extension)
local buid = vim.api.nvim_win_get_buf(winid)
local is_modified = vim.api.nvim_buf_get_option(buid, 'modified')
local modifiedIcon = is_modified and '' or ''
return string.format(' %s %s %s %s', icon, fileIcon, filename.unique(winid), modifiedIcon)
end
from tabby.nvim.
For now, you can use nvim-web-devicons to add file icon.
- install
nvim-web-devicons
and start it. require'nvim-web-devicons'.setup {}
require'nvim-web-devicons'.get_icon(filename, extension, options)
and you should get filename and extension from tabid. Overall, the code will looks like:
local focus_win = vim.api.nvim_tabpage_get_win(tabid)
local filename = require("tabby.filename").tail(focus_win)
local extension = local fname = vim.fn.fnamemodify(name, ':e')
local icon = require'nvim-web-devicons'.get_icon(filename, extension)
from tabby.nvim.
A little survey: Is it helpful to add a helper function to get the file icon in tabby.nvim
?
from tabby.nvim.
Yeah, will be good.
from tabby.nvim.
Let me share my way.
local function buffer_render (bufid, is_current)
local buftype = vim.bo[bufid].buftype
local modified = vim.bo[bufid].modified
local modified_icon = modified and '' or ' '
local path = vim.fn.bufname(bufid);
local extension = vim.fn.fnamemodify(path, ":e")
local filename = vim.fn.fnamemodify(path, ":t")
local fileicon = require'nvim-web-devicons'.get_icon (filename, extension, { default = true})
local buf_name = ' ' .. fileicon .. ' ' .. filename ..' ' .. modified_icon .. ' '
local buf_color = is_current and active_tab_hl or inactive_tab_hl
return {
type = 'text',
text = {
string.format(' %s ', buf_name) ,
hl = buf_color,
}
}
end
local components = function()
local cur_bufid = vim.api.nvim_get_current_buf()
for _, bufid in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(bufid) and vim.bo[bufid].buflisted then
local is_current = false;
if bufid == cur_bufid then
is_current = true
end
local buf_render = buffer_render (bufid,is_current)
table.insert(coms, buf_render)
table.insert(coms,
{
type = 'text',
text = {
' ',
hl = 'TabLineFill'
}
}
)
end
end
--- etc
end
from tabby.nvim.
I rewrite the config API in case to easily add helper functions. For example in setup, you can add a file icon by win object:
line.wins_in_tab(line.api.get_current_tab()).foreach(function(win)
return {
line.sep('', theme.win, theme.fill),
win.is_current() and '' or '',
win.file_icon(),
win.buf_name(),
line.sep('', theme.win, theme.fill),
hl = theme.win,
margin = ' ',
}
end),
Detail: https://github.com/nanozuki/tabby.nvim#win
from tabby.nvim.
Related Issues (20)
- Tabline Background Seems Corrupted HOT 6
- Changing colorscheme without restarting causes inconsistent highlighting HOT 4
- Add option to use lualine compatiable theme HOT 1
- Support customer mouse handler
- refactor doc
- About the highlight extraction routine HOT 2
- use pure nvim lua api
- How to handle too many tabs HOT 1
- How to show all buffers in tab? HOT 2
- feature: add symbol in tab when there are not saved changes on file. HOT 1
- Change the lazy install code HOT 1
- How to handle tab.name() for certain plugins (Overseer / Aerial etc) HOT 6
- In the preset, the color of the tab and the border color are inconsistent
- Backwards compatibility HOT 5
- Add buffer filter HOT 6
- Weird redraw issue when entering command mode HOT 4
- Add option to choose truncate mode HOT 5
- Why it's `win.buf().id` not `win.buf.id`? HOT 2
- It seems that the `line.spacer()` doesn't work correctly HOT 3
- Is it possible to assign a name when creating a new tab? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tabby.nvim.