plugin/theme: setup optional barbar plugin

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-17 17:26:13 +03:00
parent a686e4b253
commit ab06dbf6e4
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
3 changed files with 59 additions and 10 deletions

View file

@ -11,7 +11,7 @@ let
plugins = callPlugins [ plugins = callPlugins [
./plugins/syntax ./plugins/syntax
./plugins/explorer ./plugins/explorer
(import ./plugins/theme { enableTabline = false; }) (import ./plugins/theme { enableBarBar = true; })
./plugins/lsp ./plugins/lsp
./plugins/formatter ./plugins/formatter
]; ];

38
plugins/theme/barbar.lua Normal file
View file

@ -0,0 +1,38 @@
-- See: https://github.com/romgrk/barbar.nvim
require("bufferline").setup({
auto_hide = false,
closable = false,
clickable = false,
icons = false, -- TODO: add icons (required nvim-web-devicons)
})
-------------------------------------------------------------------------------
-- Keybindings
local opts = { silent = true }
vim.keymap.set("n", "gB", "<Cmd>BufferPrevious<CR>", opts)
vim.keymap.set("n", "gb", "<Cmd>BufferNext<CR>", opts)
vim.keymap.set("n", "gQ", "<Cmd>BufferClose<CR>", opts)
-------------------------------------------------------------------------------
-- Integration with nvim-tree
local nvim_tree_events = require("nvim-tree.events")
local bufferline_state = require("bufferline.state")
local function get_tree_size()
return require("nvim-tree.view").View.width
end
nvim_tree_events.subscribe("TreeOpen", function()
bufferline_state.set_offset(get_tree_size())
end)
nvim_tree_events.subscribe("Resize", function()
bufferline_state.set_offset(get_tree_size())
end)
nvim_tree_events.subscribe("TreeClose", function()
bufferline_state.set_offset(0)
end)

View file

@ -1,16 +1,27 @@
{ enableTabline ? false }: { enableTabline ? false
, enableBarBar ? false
}:
{ lib, catppuccin-nvim, lualine-nvim, lualine-lsp-progress, tabline-nvim, ... }: { lib
, catppuccin-nvim
, lualine-nvim
, lualine-lsp-progress
, tabline-nvim
, barbar-nvim
, ...
}:
let
lualinePlugins = [ lualine-nvim lualine-lsp-progress ];
in
{ {
luaConfig = (builtins.readFile ./catppuccin-nvim.lua) luaConfig = (builtins.readFile ./catppuccin-nvim.lua)
+ (builtins.readFile ./lualine.lua) + (builtins.readFile ./lualine.lua)
+ (lib.optional enableTabline (builtins.readFile ./tabline.lua)); + (lib.optional enableTabline (builtins.readFile ./tabline.lua))
+ (lib.optional enableBarBar (builtins.readFile ./barbar.lua));
plugins = [ plugins = [ catppuccin-nvim ]
catppuccin-nvim ++ lualinePlugins
++ (lib.optional enableTabline [ tabline-nvim ])
lualine-nvim ++ (lib.optional enableBarBar [ barbar-nvim ]);
lualine-lsp-progress
] ++ (lib.optional enableTabline [ tabline-nvim ]);
} }