feat: add codewindow keybindings

This commit is contained in:
n3oney 2023-05-02 23:06:35 +02:00
parent dce3d762d9
commit 25c9bb0962
No known key found for this signature in database
GPG key ID: C786693DE727850E
2 changed files with 22 additions and 10 deletions

View file

@ -1,11 +1,13 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
{lib, ...}:
with lib; {
options.vim.minimap.codewindow = {
enable = mkEnableOption "Enable codewindow plugin for minimap view";
mappings = {
open = mkMappingOption "Open minimap [codewindow]" "<leader>mo";
close = mkMappingOption "Close minimap [codewindow]" "<leader>mc";
toggle = mkMappingOption "Toggle minimap [codewindow]" "<leader>mm";
toggleFocus = mkMappingOption "Toggle minimap focus [codewindow]" "<leader>mf";
};
};
}

View file

@ -6,19 +6,29 @@
with lib;
with builtins; let
cfg = config.vim.minimap.codewindow;
self = import ./codewindow.nix {inherit lib;};
mappingDefinitions = self.options.vim.minimap.codewindow.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"codewindow-nvim"
];
vim.maps.normal = mkMerge [
(mkSetLuaBinding mappings.open "require('codewindow').open_minimap")
(mkSetLuaBinding mappings.close "require('codewindow').close_minimap")
(mkSetLuaBinding mappings.toggle "require('codewindow').toggle_minimap")
(mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus")
];
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
local codewindow = require('codewindow')
codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda'},
}
)
codewindow.apply_default_keybinds()
})
'';
};
}