mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 08:39:50 +01:00
modules/tabline: switch to explicit lib calls
This commit is contained in:
parent
32c2e7733a
commit
e80f2c9280
4 changed files with 86 additions and 82 deletions
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./nvim-bufferline
|
./nvim-bufferline
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim pushDownDefault;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.nvim.binds) mkLuaBinding mkBinding pushDownDefault;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.tabline.nvimBufferline;
|
cfg = config.vim.tabline.nvimBufferline;
|
||||||
self = import ./nvim-bufferline.nix {
|
|
||||||
inherit lib;
|
self = import ./nvim-bufferline.nix {inherit lib;};
|
||||||
};
|
inherit (self.options.vim.tabline.nvimBufferline) mappings;
|
||||||
mappings = self.options.vim.tabline.nvimBufferline.mappings;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable (
|
config = mkIf cfg.enable (
|
||||||
let
|
let
|
||||||
|
@ -22,82 +23,84 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
vim.startPlugins = [
|
vim = {
|
||||||
(assert config.vim.visuals.nvimWebDevicons.enable == true; "nvim-bufferline-lua")
|
startPlugins = [
|
||||||
"bufdelete-nvim"
|
(assert config.vim.visuals.nvimWebDevicons.enable; "nvim-bufferline-lua")
|
||||||
];
|
"bufdelete-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
maps.normal = mkMerge [
|
||||||
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
||||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||||
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||||
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||||
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
||||||
(mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description)
|
(mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description)
|
||||||
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
||||||
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.binds.whichKey.register = pushDownDefault {
|
binds.whichKey.register = pushDownDefault {
|
||||||
"<leader>b" = "+Buffer";
|
"<leader>b" = "+Buffer";
|
||||||
"<leader>bm" = "BufferLineMove";
|
"<leader>bm" = "BufferLineMove";
|
||||||
"<leader>bs" = "BufferLineSort";
|
"<leader>bs" = "BufferLineSort";
|
||||||
"<leader>bsi" = "BufferLineSortById";
|
"<leader>bsi" = "BufferLineSortById";
|
||||||
|
};
|
||||||
|
|
||||||
|
luaConfigRC.nvimBufferline = entryAnywhere ''
|
||||||
|
require("bufferline").setup{
|
||||||
|
options = {
|
||||||
|
mode = "buffers",
|
||||||
|
numbers = "both",
|
||||||
|
close_command = ${mouse.close},
|
||||||
|
right_mouse_command = ${mouse.right},
|
||||||
|
indicator = {
|
||||||
|
style = 'icon',
|
||||||
|
indicator_icon = '▎',
|
||||||
|
},
|
||||||
|
buffer_close_icon = '',
|
||||||
|
modified_icon = '●',
|
||||||
|
close_icon = '',
|
||||||
|
left_trunc_marker = '',
|
||||||
|
right_trunc_marker = '',
|
||||||
|
max_name_length = 18,
|
||||||
|
max_prefix_length = 15,
|
||||||
|
tab_size = 18,
|
||||||
|
show_buffer_icons = true,
|
||||||
|
show_buffer_close_icons = true,
|
||||||
|
show_close_icon = true,
|
||||||
|
show_tab_indicators = true,
|
||||||
|
persist_buffer_sort = true,
|
||||||
|
--separator_style = "thin",
|
||||||
|
separator_style = { " ", " " },
|
||||||
|
enforce_regular_tabs = true,
|
||||||
|
always_show_bufferline = true,
|
||||||
|
offsets = {
|
||||||
|
{filetype = "NvimTree", text = "File Explorer", text_align = "center"}
|
||||||
|
},
|
||||||
|
sort_by = 'extension',
|
||||||
|
diagnostics = "nvim_lsp", -- TODO: use coc if it's enabled
|
||||||
|
diagnostics_update_in_insert = true,
|
||||||
|
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
||||||
|
local s = ""
|
||||||
|
for e, n in pairs(diagnostics_dict) do
|
||||||
|
local sym = e == "error" and ""
|
||||||
|
or (e == "warning" and "" or "" )
|
||||||
|
if(sym ~= "") then
|
||||||
|
s = s .. " " .. n .. sym
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end,
|
||||||
|
numbers = function(opts)
|
||||||
|
return string.format('%s·%s', opts.raise(opts.id), opts.lower(opts.ordinal))
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
|
||||||
require("bufferline").setup{
|
|
||||||
options = {
|
|
||||||
mode = "buffers",
|
|
||||||
numbers = "both",
|
|
||||||
close_command = ${mouse.close},
|
|
||||||
right_mouse_command = ${mouse.right},
|
|
||||||
indicator = {
|
|
||||||
style = 'icon',
|
|
||||||
indicator_icon = '▎',
|
|
||||||
},
|
|
||||||
buffer_close_icon = '',
|
|
||||||
modified_icon = '●',
|
|
||||||
close_icon = '',
|
|
||||||
left_trunc_marker = '',
|
|
||||||
right_trunc_marker = '',
|
|
||||||
max_name_length = 18,
|
|
||||||
max_prefix_length = 15,
|
|
||||||
tab_size = 18,
|
|
||||||
show_buffer_icons = true,
|
|
||||||
show_buffer_close_icons = true,
|
|
||||||
show_close_icon = true,
|
|
||||||
show_tab_indicators = true,
|
|
||||||
persist_buffer_sort = true,
|
|
||||||
--separator_style = "thin",
|
|
||||||
separator_style = { " ", " " },
|
|
||||||
enforce_regular_tabs = true,
|
|
||||||
always_show_bufferline = true,
|
|
||||||
offsets = {
|
|
||||||
{filetype = "NvimTree", text = "File Explorer", text_align = "center"}
|
|
||||||
},
|
|
||||||
sort_by = 'extension',
|
|
||||||
diagnostics = "nvim_lsp", -- TODO: use coc if it's enabled
|
|
||||||
diagnostics_update_in_insert = true,
|
|
||||||
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
|
||||||
local s = ""
|
|
||||||
for e, n in pairs(diagnostics_dict) do
|
|
||||||
local sym = e == "error" and ""
|
|
||||||
or (e == "warning" and "" or "" )
|
|
||||||
if(sym ~= "") then
|
|
||||||
s = s .. " " .. n .. sym
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return s
|
|
||||||
end,
|
|
||||||
numbers = function(opts)
|
|
||||||
return string.format('%s·%s', opts.raise(opts.id), opts.lower(opts.ordinal))
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./nvim-bufferline.nix
|
./nvim-bufferline.nix
|
||||||
./config.nix
|
./config.nix
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib) mkEnableOption mkMappingOption;
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
in {
|
in {
|
||||||
options.vim.tabline.nvimBufferline = {
|
options.vim.tabline.nvimBufferline = {
|
||||||
enable = mkEnableOption "nvim-bufferline-lua as a bufferline";
|
enable = mkEnableOption "neovim bufferline";
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
closeCurrent = mkMappingOption "Close buffer" null;
|
closeCurrent = mkMappingOption "Close buffer" null;
|
||||||
|
|
Loading…
Reference in a new issue