update
This commit is contained in:
parent
962807aa70
commit
76d9c95927
1 changed files with 75 additions and 3 deletions
78
init.lua
78
init.lua
|
|
@ -186,7 +186,78 @@ local TablineFileName = {
|
|||
end,
|
||||
}
|
||||
|
||||
local TablineFileFlags = {
|
||||
{
|
||||
condition = function(self)
|
||||
return vim.api.nvim_buf_get_option(self.bufnr, "modified")
|
||||
end,
|
||||
provider = "[+]",
|
||||
hl = { fg = "green" },
|
||||
},
|
||||
{
|
||||
condition = function(self)
|
||||
return not vim.api.nvim_buf_get_option(self.bufnr, "modifiable")
|
||||
or vim.api.nvim_buf_get_option(self.bufnr, "readonly")
|
||||
end,
|
||||
provider = function(self)
|
||||
if vim.api.nvim_buf_get_option(self.bufnr, "buftype") == "terminal" then
|
||||
return " "
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end,
|
||||
hl = { fg = "orange" },
|
||||
},
|
||||
}
|
||||
|
||||
local FileIcon = {
|
||||
init = function(self)
|
||||
local filename = self.filename
|
||||
local extension = vim.fn.fnamemodify(filename, ":e")
|
||||
self.icon, self.icon_color =
|
||||
require("nvim-web-devicons").get_icon_color(filename, extension, { default = true })
|
||||
end,
|
||||
provider = function(self)
|
||||
return self.icon and (self.icon .. " ")
|
||||
end,
|
||||
hl = function(self)
|
||||
return { fg = self.icon_color }
|
||||
end,
|
||||
}
|
||||
|
||||
local TablineFileNameBlock = {
|
||||
init = function(self)
|
||||
self.filename = vim.api.nvim_buf_get_name(self.bufnr)
|
||||
end,
|
||||
hl = function(self)
|
||||
if self.is_active then
|
||||
return "TabLineSel"
|
||||
else
|
||||
return "TabLine"
|
||||
end
|
||||
end,
|
||||
on_click = {
|
||||
callback = function(_, minwid, _, _)
|
||||
vim.api.nvim_win_set_buf(0, minwid)
|
||||
end,
|
||||
minwid = function(self)
|
||||
return self.bufnr
|
||||
end,
|
||||
name = "termline_buffer_callback",
|
||||
},
|
||||
FileIcon, -- turns out the version defined in #crash-course-part-ii-filename-and-friends can be reutilized as is here!
|
||||
TablineFileName,
|
||||
TablineFileFlags, -- turns out the version defined in #crash-course-part-ii-filename-and-friends can be reutilized as is here!
|
||||
}
|
||||
local TablineBufferBlock = utils.surround({ "", "" }, function(self)
|
||||
if self.is_active then
|
||||
return utils.get_highlight("TabLineSel").bg
|
||||
else
|
||||
return utils.get_highlight("TabLine").bg
|
||||
end
|
||||
end, { TablineFileNameBlock })
|
||||
|
||||
local TerminalLineFileNameBlock = {
|
||||
init = function(self)
|
||||
self.filename = vim.api.nvim_buf_get_name(self.bufnr)
|
||||
end,
|
||||
|
|
@ -208,13 +279,14 @@ local TablineFileNameBlock = {
|
|||
},
|
||||
TablineFileName,
|
||||
}
|
||||
local TablineBufferBlock = utils.surround({ "", "" }, function(self)
|
||||
local TerminalLineBufferBlock = utils.surround({ "", "" }, function(self)
|
||||
if self.is_active then
|
||||
return utils.get_highlight("TabLineSel").bg
|
||||
else
|
||||
return utils.get_highlight("TabLine").bg
|
||||
end
|
||||
end, { TablineFileNameBlock })
|
||||
end, { TerminalLineFileNameBlock })
|
||||
|
||||
local function get_terminal_bufs()
|
||||
return vim.tbl_filter(function(bufnr)
|
||||
return vim.api.nvim_buf_get_option(bufnr, "buftype") == "terminal"
|
||||
|
|
@ -235,7 +307,7 @@ local TerminalLine = {
|
|||
buftype = { "terminal" },
|
||||
})
|
||||
end,
|
||||
utils.make_buflist(TablineBufferBlock, nil, nil, get_terminal_bufs),
|
||||
utils.make_buflist(TerminalLineBufferBlock, nil, nil, get_terminal_bufs),
|
||||
}
|
||||
local BufferLine = {
|
||||
utils.make_buflist(TablineBufferBlock, nil, nil, get_non_terminal_bufs),
|
||||
|
|
|
|||
Loading…
Reference in a new issue