mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
# TODO: move this to its own module
|
||||
inherit (lib) pushDownDefault;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.telescope;
|
||||
self = import ./telescope.nix {inherit pkgs lib;};
|
||||
mappingDefinitions = self.options.vim.telescope.mappings;
|
||||
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"telescope"
|
||||
];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
||||
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
||||
|
||||
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
||||
(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 [
|
||||
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||
|
||||
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
||||
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
||||
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
||||
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
||||
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
||||
]))
|
||||
|
||||
(
|
||||
mkIf config.vim.treesitter.enable
|
||||
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||
)
|
||||
|
||||
(
|
||||
mkIf config.vim.projects.project-nvim.enable
|
||||
(mkSetBinding mappings.findProjects "<cmd Telescope projects<CR>")
|
||||
)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>f" = "+Telescope";
|
||||
"<leader>fl" = "Telescope LSP";
|
||||
"<leader>fm" = "Cellular Automaton";
|
||||
"<leader>fv" = "Telescope Git";
|
||||
"<leader>fvc" = "Commits";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.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 ""
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
_: {
|
||||
imports = [
|
||||
./telescope.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) int str listOf float bool either enum submodule attrsOf;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
setupOptions = {
|
||||
defaults = {
|
||||
vimgrep_arguments = mkOption {
|
||||
description = ''
|
||||
Defines the command that will be used for `live_grep` and `grep_string` pickers.
|
||||
Make sure that color is set to `never` because telescope does not yet interpret color codes.
|
||||
'';
|
||||
type = listOf str;
|
||||
default = [
|
||||
"${pkgs.ripgrep}/bin/rg"
|
||||
"--color=never"
|
||||
"--no-heading"
|
||||
"--with-filename"
|
||||
"--line-number"
|
||||
"--column"
|
||||
"--smart-case"
|
||||
"--hidden"
|
||||
"--no-ignore"
|
||||
];
|
||||
};
|
||||
pickers.find_command = mkOption {
|
||||
description = "cmd to use for finding files";
|
||||
type = either (listOf str) luaInline;
|
||||
default = ["${pkgs.fd}/bin/fd"];
|
||||
};
|
||||
prompt_prefix = mkOption {
|
||||
description = "Shown in front of Telescope's prompt";
|
||||
type = str;
|
||||
default = " ";
|
||||
};
|
||||
selection_caret = mkOption {
|
||||
description = "Character(s) to show in front of the current selection";
|
||||
type = str;
|
||||
default = " ";
|
||||
};
|
||||
entry_prefix = mkOption {
|
||||
description = "Prefix in front of each result entry. Current selection not included.";
|
||||
type = str;
|
||||
default = " ";
|
||||
};
|
||||
initial_mode = mkOption {
|
||||
description = "Determines in which mode telescope starts.";
|
||||
type = enum ["insert" "normal"];
|
||||
default = "insert";
|
||||
};
|
||||
selection_strategy = mkOption {
|
||||
description = "Determines how the cursor acts after each sort iteration.";
|
||||
type = enum ["reset" "follow" "row" "closest" "none"];
|
||||
default = "reset";
|
||||
};
|
||||
sorting_strategy = mkOption {
|
||||
description = ''Determines the direction "better" results are sorted towards.'';
|
||||
type = enum ["descending" "ascending"];
|
||||
default = "ascending";
|
||||
};
|
||||
layout_strategy = mkOption {
|
||||
description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`.";
|
||||
type = str;
|
||||
default = "horizontal";
|
||||
};
|
||||
layout_config = mkOption {
|
||||
description = ''
|
||||
Determines the default configuration values for layout strategies.
|
||||
See telescope.layout for details of the configurations options for
|
||||
each strategy.
|
||||
'';
|
||||
default = {};
|
||||
type = submodule {
|
||||
options = {
|
||||
horizontal = {
|
||||
prompt_position = mkOption {
|
||||
description = "";
|
||||
type = str;
|
||||
default = "top";
|
||||
};
|
||||
preview_width = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.55;
|
||||
};
|
||||
results_width = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.8;
|
||||
};
|
||||
};
|
||||
vertical = {
|
||||
mirror = mkOption {
|
||||
description = "";
|
||||
type = bool;
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
width = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.8;
|
||||
};
|
||||
height = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.8;
|
||||
};
|
||||
preview_cutoff = mkOption {
|
||||
description = "";
|
||||
type = int;
|
||||
default = 120;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
file_ignore_patterns = mkOption {
|
||||
description = "A table of lua regex that define the files that should be ignored.";
|
||||
type = listOf str;
|
||||
default = ["node_modules" ".git/" "dist/" "build/" "target/" "result/"];
|
||||
};
|
||||
color_devicons = mkOption {
|
||||
description = "Boolean if devicons should be enabled or not.";
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
path_display = mkOption {
|
||||
description = "Determines how file paths are displayed.";
|
||||
type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]);
|
||||
default = ["absolute"];
|
||||
};
|
||||
set_env = mkOption {
|
||||
description = "Set an envrionment for term_previewer";
|
||||
type = attrsOf str;
|
||||
default = {
|
||||
COLORTERM = "truecolor";
|
||||
};
|
||||
};
|
||||
winblend = mkOption {
|
||||
description = "pseudo-transparency of keymap hints floating window";
|
||||
type = int;
|
||||
default = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.telescope = {
|
||||
mappings = {
|
||||
findProjects = mkMappingOption "Find files [Telescope]" "<leader>fp";
|
||||
|
||||
findFiles = mkMappingOption "Find files [Telescope]" "<leader>ff";
|
||||
liveGrep = mkMappingOption "Live grep [Telescope]" "<leader>fg";
|
||||
buffers = mkMappingOption "Buffers [Telescope]" "<leader>fb";
|
||||
helpTags = mkMappingOption "Help tags [Telescope]" "<leader>fh";
|
||||
open = mkMappingOption "Open [Telescope]" "<leader>ft";
|
||||
|
||||
gitCommits = mkMappingOption "Git commits [Telescope]" "<leader>fvcw";
|
||||
gitBufferCommits = mkMappingOption "Git buffer commits [Telescope]" "<leader>fvcb";
|
||||
gitBranches = mkMappingOption "Git branches [Telescope]" "<leader>fvb";
|
||||
gitStatus = mkMappingOption "Git status [Telescope]" "<leader>fvs";
|
||||
gitStash = mkMappingOption "Git stash [Telescope]" "<leader>fvx";
|
||||
|
||||
lspDocumentSymbols = mkMappingOption "LSP Document Symbols [Telescope]" "<leader>flsb";
|
||||
lspWorkspaceSymbols = mkMappingOption "LSP Workspace Symbols [Telescope]" "<leader>flsw";
|
||||
lspReferences = mkMappingOption "LSP References [Telescope]" "<leader>flr";
|
||||
lspImplementations = mkMappingOption "LSP Implementations [Telescope]" "<leader>fli";
|
||||
lspDefinitions = mkMappingOption "LSP Definitions [Telescope]" "<leader>flD";
|
||||
lspTypeDefinitions = mkMappingOption "LSP Type Definitions [Telescope]" "<leader>flt";
|
||||
diagnostics = mkMappingOption "Diagnostics [Telescope]" "<leader>fld";
|
||||
|
||||
treesitter = mkMappingOption "Treesitter [Telescope]" "<leader>fs";
|
||||
};
|
||||
|
||||
enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";
|
||||
|
||||
setupOpts = mkPluginSetupOption "Telescope" setupOptions;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue