mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-22 06:43:52 +00:00
new: add cokeline
This commit is contained in:
parent
2c9a9b4d29
commit
915bef780f
7 changed files with 142 additions and 1 deletions
17
modules/plugins/tabline/cokeline/cokeline.nix
Normal file
17
modules/plugins/tabline/cokeline/cokeline.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.tabline.cokeline = {
|
||||
enable = mkEnableOption "cokeline";
|
||||
|
||||
mappings = {
|
||||
cycleNext = mkMappingOption "Next buffer" "<Tab>";
|
||||
cyclePrevious = mkMappingOption "Previous buffer" "<S-Tab>";
|
||||
pick = mkMappingOption "Pick buffer" "<leader>bc";
|
||||
switchNext = mkMappingOption "Switch with next buffer" "<leader>bmn";
|
||||
switchPrevious = mkMappingOption "Move previous buffer" "<leader>bmp";
|
||||
closeByLetter = mkMappingOption "Close buffer by letter" "<leader>bd";
|
||||
};
|
||||
};
|
||||
}
|
||||
95
modules/plugins/tabline/cokeline/config.nix
Normal file
95
modules/plugins/tabline/cokeline/config.nix
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding pushDownDefault;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.tabline.cokeline;
|
||||
|
||||
self = import ./cokeline.nix {inherit lib;};
|
||||
inherit (self.options.vim.tabline.cokeline) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
(assert config.vim.visuals.nvimWebDevicons.enable; "nvim-cokeline")
|
||||
"bufdelete-nvim"
|
||||
];
|
||||
|
||||
maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.cycleNext "<Plug>(cokeline-focus-next)" mappings.cycleNext.description)
|
||||
(mkBinding cfg.mappings.cyclePrevious "<Plug>(cokeline-focus-prev)" mappings.cyclePrevious.description)
|
||||
(mkBinding cfg.mappings.switchNext "<Plug>(cokeline-switch-next)" mappings.switchNext.description)
|
||||
(mkBinding cfg.mappings.switchPrevious "<Plug>(cokeline-switch-prev)" mappings.switchPrevious.description)
|
||||
# this does not work
|
||||
# (mkBinding cfg.mappings.pick "<Plug>(cokeline-pick-focus)" mappings.pick.description)
|
||||
# (mkLuaBinding cfg.mappings.pick "function() require('cokeline.mappings').pick(\"focus\") end" mappings.pick.description)
|
||||
# (mkBinding cfg.mappings.closeByLetter "<Plug>(cokeline-pick-close)" mappings.closeByLetter.description)
|
||||
];
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>b" = "+Buffer";
|
||||
"<leader>bm" = "BufferLineMove";
|
||||
};
|
||||
|
||||
luaConfigRC = {
|
||||
cokeline = entryAnywhere ''
|
||||
local get_hex = require('cokeline.hlgroups').get_hl_attr
|
||||
|
||||
require('cokeline').setup({
|
||||
default_hl = {
|
||||
fg = function(buffer)
|
||||
return
|
||||
buffer.is_focused
|
||||
and get_hex('Normal', 'fg')
|
||||
or get_hex('Comment', 'fg')
|
||||
end,
|
||||
bg = get_hex('ColorColumn', 'bg'),
|
||||
},
|
||||
|
||||
components = {
|
||||
{
|
||||
text = ' ',
|
||||
bg = get_hex('Normal', 'bg'),
|
||||
},
|
||||
{
|
||||
text = '',
|
||||
fg = get_hex('ColorColumn', 'bg'),
|
||||
bg = get_hex('Normal', 'bg'),
|
||||
},
|
||||
{
|
||||
text = function(buffer)
|
||||
return buffer.devicon.icon
|
||||
end,
|
||||
fg = function(buffer)
|
||||
return buffer.devicon.color
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = ' ',
|
||||
},
|
||||
{
|
||||
text = function(buffer) return buffer.filename .. ' ' end,
|
||||
style = function(buffer)
|
||||
return buffer.is_focused and 'bold' or nil
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = '',
|
||||
delete_buffer_on_left_click = true,
|
||||
},
|
||||
{
|
||||
text = '',
|
||||
fg = get_hex('ColorColumn', 'bg'),
|
||||
bg = get_hex('Normal', 'bg'),
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/tabline/cokeline/default.nix
Normal file
6
modules/plugins/tabline/cokeline/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./cokeline.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nvim-bufferline
|
||||
./cokeline
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ in {
|
|||
maps.normal = mkMerge [
|
||||
(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.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue