mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-05 18:01:32 +00:00
refactor: move gestures
, which-key
, telescope
and cheatsheet
to utils
This commit is contained in:
parent
9cab13f667
commit
9ac1e1dadd
8 changed files with 3 additions and 3 deletions
22
modules/utility/binds/cheatsheet.nix
Normal file
22
modules/utility/binds/cheatsheet.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.binds.cheatsheet;
|
||||
in {
|
||||
options.vim.binds.cheatsheet = {
|
||||
enable = mkEnableOption "Searchable cheatsheet for nvim using telescope";
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = ["cheatsheet-nvim"];
|
||||
|
||||
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere ''
|
||||
require('cheatsheet').setup({})
|
||||
'';
|
||||
};
|
||||
}
|
11
modules/utility/binds/default.nix
Normal file
11
modules/utility/binds/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./which-key.nix
|
||||
./cheatsheet.nix
|
||||
];
|
||||
}
|
20
modules/utility/binds/which-key.nix
Normal file
20
modules/utility/binds/which-key.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.binds.whichKey;
|
||||
in {
|
||||
options.vim.binds.whichKey = {
|
||||
enable = mkEnableOption "which-key menu";
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = ["which-key"];
|
||||
|
||||
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''local wk = require("which-key").setup {}'';
|
||||
};
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
_: {
|
||||
imports = [
|
||||
./binds
|
||||
./gestures
|
||||
./telescope
|
||||
./colorizer.nix
|
||||
./venn.nix
|
||||
./icon-picker.nix
|
||||
|
|
5
modules/utility/gestures/default.nix
Normal file
5
modules/utility/gestures/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./gesture-nvim.nix
|
||||
];
|
||||
}
|
55
modules/utility/gestures/gesture-nvim.nix
Normal file
55
modules/utility/gestures/gesture-nvim.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.gestures.gesture-nvim;
|
||||
in {
|
||||
options.vim.gestures.gesture-nvim = {
|
||||
enable = mkEnableOption "Enable GitHub Copilot";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["gesture-nvim"];
|
||||
|
||||
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
vim.keymap.set("n", "<LeftDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
|
||||
vim.keymap.set("n", "<LeftRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
|
||||
|
||||
-- or if you would like to use right click
|
||||
-- vim.keymap.set("n", "<RightMouse>", [[<Nop>]])
|
||||
-- vim.keymap.set("n", "<RightDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
|
||||
-- vim.keymap.set("n", "<RightRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
|
||||
|
||||
local gesture = require("gesture")
|
||||
gesture.register({
|
||||
name = "scroll to bottom",
|
||||
inputs = { gesture.up(), gesture.down() },
|
||||
action = "normal! G",
|
||||
})
|
||||
gesture.register({
|
||||
name = "next tab",
|
||||
inputs = { gesture.right() },
|
||||
action = "tabnext",
|
||||
})
|
||||
gesture.register({
|
||||
name = "previous tab",
|
||||
inputs = { gesture.left() },
|
||||
action = function(ctx) -- also can use callable
|
||||
vim.cmd.tabprevious()
|
||||
end,
|
||||
})
|
||||
gesture.register({
|
||||
name = "go back",
|
||||
inputs = { gesture.right(), gesture.left() },
|
||||
-- map to `<C-o>` keycode
|
||||
action = [[lua vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-o>", true, false, true), "n", true)]],
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
90
modules/utility/telescope/default.nix
Normal file
90
modules/utility/telescope/default.nix
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.telescope;
|
||||
in {
|
||||
options.vim.telescope = {
|
||||
enable = mkEnableOption "enable telescope";
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"telescope"
|
||||
];
|
||||
|
||||
vim.nnoremap =
|
||||
{
|
||||
"<leader>ff" = "<cmd> Telescope find_files<CR>";
|
||||
"<leader>fg" = "<cmd> Telescope live_grep<CR>";
|
||||
"<leader>fb" = "<cmd> Telescope buffers<CR>";
|
||||
"<leader>fh" = "<cmd> Telescope help_tags<CR>";
|
||||
"<leader>ft" = "<cmd> Telescope<CR>";
|
||||
|
||||
"<leader>fvcw" = "<cmd> Telescope git_commits<CR>";
|
||||
"<leader>fvcb" = "<cmd> Telescope git_bcommits<CR>";
|
||||
"<leader>fvb" = "<cmd> Telescope git_branches<CR>";
|
||||
"<leader>fvs" = "<cmd> Telescope git_status<CR>";
|
||||
"<leader>fvx" = "<cmd> Telescope git_stash<CR>";
|
||||
}
|
||||
// (
|
||||
if config.vim.lsp.enable
|
||||
then {
|
||||
"<leader>flsb" = "<cmd> Telescope lsp_document_symbols<CR>";
|
||||
"<leader>flsw" = "<cmd> Telescope lsp_workspace_symbols<CR>";
|
||||
|
||||
"<leader>flr" = "<cmd> Telescope lsp_references<CR>";
|
||||
"<leader>fli" = "<cmd> Telescope lsp_implementations<CR>";
|
||||
"<leader>flD" = "<cmd> Telescope lsp_definitions<CR>";
|
||||
"<leader>flt" = "<cmd> Telescope lsp_type_definitions<CR>";
|
||||
"<leader>fld" = "<cmd> Telescope diagnostics<CR>";
|
||||
}
|
||||
else {}
|
||||
)
|
||||
// (
|
||||
if config.vim.treesitter.enable
|
||||
then {
|
||||
"<leader>fs" = "<cmd> Telescope treesitter<CR>";
|
||||
}
|
||||
else {}
|
||||
);
|
||||
|
||||
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
|
||||
local telescope = require('telescope')
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
"${pkgs.ripgrep}/bin/rg",
|
||||
"--color=never",
|
||||
"--no-heading",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"--column",
|
||||
"--smart-case"
|
||||
},
|
||||
pickers = {
|
||||
find_command = {
|
||||
"${pkgs.fd}/bin/fd",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
${
|
||||
if config.vim.ui.noice.enable
|
||||
then "telescope.load_extension('noice')"
|
||||
else null
|
||||
}
|
||||
|
||||
${
|
||||
if config.vim.notify.nvim-notify.enable
|
||||
then "telescope.load_extension('notify')"
|
||||
else null
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue