mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 08:05:58 +01:00
telescope: lazy load
This commit is contained in:
parent
7e144707d9
commit
bc6597c36a
1 changed files with 52 additions and 62 deletions
|
@ -4,11 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.nvim.binds) pushDownDefault;
|
inherit (lib.lists) optionals;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding;
|
||||||
|
|
||||||
cfg = config.vim.telescope;
|
cfg = config.vim.telescope;
|
||||||
self = import ./telescope.nix {inherit pkgs lib;};
|
self = import ./telescope.nix {inherit pkgs lib;};
|
||||||
|
@ -18,45 +18,58 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [
|
startPlugins = ["plenary-nvim"];
|
||||||
"telescope"
|
|
||||||
"plenary-nvim"
|
|
||||||
];
|
|
||||||
|
|
||||||
maps.normal = mkMerge [
|
lazy.plugins = [
|
||||||
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
{
|
||||||
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
package = "telescope";
|
||||||
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
setupModule = "telescope";
|
||||||
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
inherit (cfg) setupOpts;
|
||||||
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
# FIXME: how do I deal with extensions? set all as deps?
|
||||||
(mkSetBinding mappings.resume "<cmd> Telescope resume<CR>")
|
after = ''
|
||||||
|
local telescope = require("telescope")
|
||||||
|
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"}
|
||||||
|
${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"}
|
||||||
|
${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"}
|
||||||
|
'';
|
||||||
|
|
||||||
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
cmd = ["Telescope"];
|
||||||
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
|
||||||
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
|
||||||
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
|
||||||
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
|
||||||
|
|
||||||
(mkIf config.vim.lsp.enable (mkMerge [
|
keys =
|
||||||
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
[
|
||||||
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
(mkSetLznBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
||||||
|
(mkSetLznBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||||
|
(mkSetLznBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||||
|
(mkSetLznBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||||
|
(mkSetLznBinding mappings.open "<cmd> Telescope<CR>")
|
||||||
|
|
||||||
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
(mkSetLznBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
||||||
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
(mkSetLznBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
||||||
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
(mkSetLznBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
||||||
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
(mkSetLznBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
||||||
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
(mkSetLznBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
||||||
]))
|
]
|
||||||
|
++ (optionals config.vim.lsp.enable [
|
||||||
|
(mkSetLznBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||||
|
(mkSetLznBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||||
|
|
||||||
(
|
(mkSetLznBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
||||||
mkIf config.vim.treesitter.enable
|
(mkSetLznBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
||||||
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
(mkSetLznBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
||||||
)
|
(mkSetLznBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
||||||
|
(mkSetLznBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
||||||
(
|
])
|
||||||
mkIf config.vim.projects.project-nvim.enable
|
++ (
|
||||||
(mkSetBinding mappings.findProjects "<cmd> Telescope projects<CR>")
|
optionals config.vim.treesitter.enable [
|
||||||
)
|
(mkSetLznBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||||
|
]
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
optionals config.vim.projects.project-nvim.enable [
|
||||||
|
(mkSetLznBinding mappings.findProjects "<cmd Telescope projects<CR>")
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
binds.whichKey.register = pushDownDefault {
|
binds.whichKey.register = pushDownDefault {
|
||||||
|
@ -66,29 +79,6 @@ in {
|
||||||
"<leader>fv" = "Telescope Git";
|
"<leader>fv" = "Telescope Git";
|
||||||
"<leader>fvc" = "Commits";
|
"<leader>fvc" = "Commits";
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginRC.telescope = entryAnywhere ''
|
|
||||||
local telescope = require('telescope')
|
|
||||||
telescope.setup(${toLuaObject cfg.setupOpts})
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.ui.noice.enable
|
|
||||||
then "telescope.load_extension('noice')"
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.notify.nvim-notify.enable
|
|
||||||
then "telescope.load_extension('notify')"
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.projects.project-nvim.enable
|
|
||||||
then "telescope.load_extension('projects')"
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue