-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add keymap options to bufferline
- Loading branch information
1 parent
175bc01
commit 8f5a85d
Showing
1 changed file
with
144 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,162 @@ | ||
{ lib, config, ... }: | ||
{ | ||
options = { | ||
bufferline.enable = lib.mkEnableOption "Enable bufferline module"; | ||
}; | ||
config = lib.mkIf config.bufferline.enable { | ||
plugins = { | ||
bufferline = { | ||
enable = true; | ||
settings = { | ||
options = { | ||
separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“ | ||
offsets = [ | ||
{ | ||
filetype = "neo-tree"; | ||
text = "Neo-tree"; | ||
highlight = "Directory"; | ||
text_align = "left"; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
keymaps = [ | ||
{ | ||
mode = "n"; | ||
key = "<Tab>"; | ||
action = "<cmd>BufferLineCycleNext<cr>"; | ||
options = { | ||
desc = "Cycle to next buffer"; | ||
}; | ||
} | ||
bufferline = { | ||
enable = lib.mkEnableOption "Enable bufferline module"; | ||
|
||
{ | ||
mode = "n"; | ||
key = "<S-Tab>"; | ||
action = "<cmd>BufferLineCyclePrev<cr>"; | ||
options = { | ||
desc = "Cycle to previous buffer"; | ||
keymaps = { | ||
enable = lib.mkOption { | ||
type = lib.types.bool; | ||
default = true; | ||
description = "Enable default keymaps"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<S-l>"; | ||
action = "<cmd>BufferLineCycleNext<cr>"; | ||
options = { | ||
desc = "Cycle to next buffer"; | ||
enableHL = lib.mkOption { | ||
type = lib.types.bool; | ||
default = true; | ||
description = "Enable keymaps for switching buffers with h and l"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<S-h>"; | ||
action = "<cmd>BufferLineCyclePrev<cr>"; | ||
options = { | ||
desc = "Cycle to previous buffer"; | ||
enableTab = lib.mkOption { | ||
type = lib.types.bool; | ||
default = true; | ||
description = "Enable keymaps for switching buffers with Tab and S-Tab"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bd"; | ||
action = "<cmd>bdelete<cr>"; | ||
options = { | ||
desc = "Delete buffer"; | ||
}; | ||
}; | ||
}; | ||
config = | ||
let | ||
cfg = config.bufferline; | ||
in | ||
lib.mkIf cfg.enable { | ||
plugins = { | ||
bufferline = { | ||
enable = true; | ||
settings = { | ||
options = { | ||
separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“ | ||
offsets = [ | ||
{ | ||
filetype = "neo-tree"; | ||
text = "Neo-tree"; | ||
highlight = "Directory"; | ||
text_align = "left"; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
} | ||
}; | ||
keymaps = lib.mkIf cfg.keymaps.enable | ||
([ | ||
{ | ||
mode = "n"; | ||
key = "<leader>bd"; | ||
action = "<cmd>bdelete<cr>"; | ||
options = { | ||
desc = "Delete buffer"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bb"; | ||
action = "<cmd>e #<cr>"; | ||
options = { | ||
desc = "Switch to Other Buffer"; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>bb"; | ||
action = "<cmd>e #<cr>"; | ||
options = { | ||
desc = "Switch to Other Buffer"; | ||
}; | ||
} | ||
|
||
# { | ||
# mode = "n"; | ||
# key = "<leader>`"; | ||
# action = "<cmd>e #<cr>"; | ||
# options = { | ||
# desc = "Switch to Other Buffer"; | ||
# }; | ||
# } | ||
# { | ||
# mode = "n"; | ||
# key = "<leader>`"; | ||
# action = "<cmd>e #<cr>"; | ||
# options = { | ||
# desc = "Switch to Other Buffer"; | ||
# }; | ||
# } | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>br"; | ||
action = "<cmd>BufferLineCloseRight<cr>"; | ||
options = { | ||
desc = "Delete buffers to the right"; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>br"; | ||
action = "<cmd>BufferLineCloseRight<cr>"; | ||
options = { | ||
desc = "Delete buffers to the right"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bl"; | ||
action = "<cmd>BufferLineCloseLeft<cr>"; | ||
options = { | ||
desc = "Delete buffers to the left"; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>bl"; | ||
action = "<cmd>BufferLineCloseLeft<cr>"; | ||
options = { | ||
desc = "Delete buffers to the left"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bo"; | ||
action = "<cmd>BufferLineCloseOthers<cr>"; | ||
options = { | ||
desc = "Delete other buffers"; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>bo"; | ||
action = "<cmd>BufferLineCloseOthers<cr>"; | ||
options = { | ||
desc = "Delete other buffers"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bp"; | ||
action = "<cmd>BufferLineTogglePin<cr>"; | ||
options = { | ||
desc = "Toggle pin"; | ||
}; | ||
} | ||
{ | ||
mode = "n"; | ||
key = "<leader>bp"; | ||
action = "<cmd>BufferLineTogglePin<cr>"; | ||
options = { | ||
desc = "Toggle pin"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<leader>bP"; | ||
action = "<Cmd>BufferLineGroupClose ungrouped<CR>"; | ||
options = { | ||
desc = "Delete non-pinned buffers"; | ||
}; | ||
} | ||
]; | ||
}; | ||
{ | ||
mode = "n"; | ||
key = "<leader>bP"; | ||
action = "<Cmd>BufferLineGroupClose ungrouped<CR>"; | ||
options = { | ||
desc = "Delete non-pinned buffers"; | ||
}; | ||
} | ||
] ++ (lib.optionals cfg.keymaps.enableTab [ | ||
{ | ||
mode = "n"; | ||
key = "<Tab>"; | ||
action = "<cmd>BufferLineCycleNext<cr>"; | ||
options = { | ||
desc = "Cycle to next buffer"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<S-Tab>"; | ||
action = "<cmd>BufferLineCyclePrev<cr>"; | ||
options = { | ||
desc = "Cycle to previous buffer"; | ||
}; | ||
} | ||
]) ++ (lib.optionals cfg.keymaps.enableHL [ | ||
{ | ||
mode = "n"; | ||
key = "<S-l>"; | ||
action = "<cmd>BufferLineCycleNext<cr>"; | ||
options = { | ||
desc = "Cycle to next buffer"; | ||
}; | ||
} | ||
|
||
{ | ||
mode = "n"; | ||
key = "<S-h>"; | ||
action = "<cmd>BufferLineCyclePrev<cr>"; | ||
options = { | ||
desc = "Cycle to previous buffer"; | ||
}; | ||
} | ||
])); | ||
}; | ||
} |