new: add cokeline

This commit is contained in:
justchokingaround 2024-05-22 05:07:17 +02:00
parent 2c9a9b4d29
commit 915bef780f
7 changed files with 142 additions and 1 deletions

View file

@ -1021,6 +1021,22 @@
"type": "github"
}
},
"plugin-nvim-cokeline": {
"flake": false,
"locked": {
"lastModified": 1715991329,
"narHash": "sha256-FXXh+a5hld9e1nW53S7vgumW4AD3bbMuewxmZyN+WvI=",
"owner": "willothy",
"repo": "nvim-cokeline",
"rev": "8145048ae68e05f31979c13b0adf7aa99f04f4c0",
"type": "github"
},
"original": {
"owner": "willothy",
"repo": "nvim-cokeline",
"type": "github"
}
},
"plugin-nvim-colorizer-lua": {
"flake": false,
"locked": {
@ -1804,6 +1820,7 @@
"plugin-nvim-bufferline-lua": "plugin-nvim-bufferline-lua",
"plugin-nvim-cmp": "plugin-nvim-cmp",
"plugin-nvim-code-action-menu": "plugin-nvim-code-action-menu",
"plugin-nvim-cokeline": "plugin-nvim-cokeline",
"plugin-nvim-colorizer-lua": "plugin-nvim-colorizer-lua",
"plugin-nvim-cursorline": "plugin-nvim-cursorline",
"plugin-nvim-dap": "plugin-nvim-dap",

View file

@ -223,6 +223,12 @@
flake = false;
};
# Cokeline
plugin-nvim-cokeline = {
url = "github:willothy/nvim-cokeline";
flake = false;
};
# Statuslines
plugin-lualine = {
url = "github:hoob3rt/lualine.nvim";

View 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";
};
};
}

View 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'),
},
},
})
'';
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./cokeline.nix
./config.nix
];
}

View file

@ -1,5 +1,6 @@
{
imports = [
./nvim-bufferline
./cokeline
];
}

View file

@ -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)