diff --git a/lua/hardline.lua b/lua/hardline.lua index 6d72e7b..95f82e4 100644 --- a/lua/hardline.lua +++ b/lua/hardline.lua @@ -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)) diff --git a/lua/hardline/bufferline.lua b/lua/hardline/bufferline.lua index 83ae521..d99414c 100644 --- a/lua/hardline/bufferline.lua +++ b/lua/hardline/bufferline.lua @@ -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'),