feat: exclude terminal buffers from bufferline
This commit is contained in:
committed by
Olivier Roques
parent
c68758ab39
commit
4373b556c2
@@ -14,6 +14,9 @@ local cache = {}
|
||||
-------------------- OPTIONS -------------------------------
|
||||
M.options = {
|
||||
bufferline = false,
|
||||
bufferline_settings = {
|
||||
exclude_terminal = false,
|
||||
},
|
||||
theme = 'default',
|
||||
sections = {
|
||||
{class = 'mode', item = require('hardline.parts.mode').get_item},
|
||||
@@ -150,7 +153,7 @@ end
|
||||
-------------------- BUFFERLINE ----------------------------
|
||||
function M.update_bufferline()
|
||||
local sections = {}
|
||||
local buffers = bufferline.get_buffers()
|
||||
local buffers = bufferline.get_buffers(M.options.bufferline_settings)
|
||||
local separator = '|'
|
||||
for i, buffer in ipairs(buffers) do
|
||||
table.insert(sections, bufferline.to_section(buffer))
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
local fn, vim = vim.fn, vim
|
||||
local fmt = string.format
|
||||
|
||||
local function is_excluded(bufnr)
|
||||
return fn.buflisted(bufnr) == 0 or fn.getbufvar(bufnr, '&filetype') == 'qf'
|
||||
local function is_excluded(bufnr, settings)
|
||||
local excluded = fn.buflisted(bufnr) == 0 or fn.getbufvar(bufnr, '&filetype') == 'qf'
|
||||
if settings.exclude_terminal then
|
||||
excluded = excluded or fn.getbufvar(bufnr, '&buftype') == 'terminal'
|
||||
end
|
||||
return excluded
|
||||
end
|
||||
|
||||
local function get_head(path, tail)
|
||||
@@ -58,10 +62,10 @@ local function to_section(buffer)
|
||||
}
|
||||
end
|
||||
|
||||
local function get_buffers()
|
||||
local function get_buffers(settings)
|
||||
local buffers = {}
|
||||
for nr = 1, fn.bufnr('$') do
|
||||
if not is_excluded(nr) then
|
||||
if not is_excluded(nr, settings) then
|
||||
table.insert(buffers, {
|
||||
bufnr = nr,
|
||||
name = fn.fnamemodify(fn.bufname(nr), ':t'),
|
||||
|
||||
Reference in New Issue
Block a user