mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	utility/telescope: add custom extensions API; clean up setupOptions
This commit is contained in:
		
					parent
					
						
							
								a0d6d8407f
							
						
					
				
			
			
				commit
				
					
						6594409a25
					
				
			
		
					 2 changed files with 71 additions and 31 deletions
				
			
		|  | @ -5,8 +5,8 @@ | ||||||
|   ... |   ... | ||||||
| }: let | }: let | ||||||
|   inherit (lib.modules) mkIf; |   inherit (lib.modules) mkIf; | ||||||
|   inherit (lib.strings) optionalString; |   inherit (lib.strings) optionalString concatMapStringsSep; | ||||||
|   inherit (lib.lists) optionals; |   inherit (lib.lists) optionals concatLists; | ||||||
|   inherit (lib.nvim.binds) pushDownDefault mkKeymap; |   inherit (lib.nvim.binds) pushDownDefault mkKeymap; | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.telescope; |   cfg = config.vim.telescope; | ||||||
|  | @ -16,7 +16,7 @@ | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = ["plenary-nvim"]; |       startPlugins = ["plenary-nvim"] ++ concatLists (map (x: x.packages) cfg.extensions); | ||||||
| 
 | 
 | ||||||
|       lazy.plugins.telescope = { |       lazy.plugins.telescope = { | ||||||
|         package = "telescope"; |         package = "telescope"; | ||||||
|  | @ -28,11 +28,14 @@ in { | ||||||
|           vim.g.loaded_telescope = nil |           vim.g.loaded_telescope = nil | ||||||
|         ''; |         ''; | ||||||
| 
 | 
 | ||||||
|         after = '' |         after = let | ||||||
|  |           enabledExtensions = map (x: x.name) cfg.extensions; | ||||||
|  |         in '' | ||||||
|           local telescope = require("telescope") |           local telescope = require("telescope") | ||||||
|           ${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} |           ${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} | ||||||
|           ${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"} |           ${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"} | ||||||
|           ${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"} |           ${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"} | ||||||
|  |           ${concatMapStringsSep "\n" (x: "telescope.load_extension('${x}')") enabledExtensions} | ||||||
|         ''; |         ''; | ||||||
| 
 | 
 | ||||||
|         cmd = ["Telescope"]; |         cmd = ["Telescope"]; | ||||||
|  |  | ||||||
|  | @ -4,16 +4,12 @@ | ||||||
|   ... |   ... | ||||||
| }: let | }: let | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   inherit (lib.options) mkEnableOption mkOption; | ||||||
|   inherit (lib.types) int str listOf float bool either enum submodule attrsOf; |   inherit (lib.types) int str listOf float bool either enum submodule attrsOf anything package; | ||||||
|   inherit (lib.nvim.binds) mkMappingOption; |   inherit (lib.nvim.binds) mkMappingOption; | ||||||
|   inherit (lib.nvim.types) mkPluginSetupOption luaInline; |   inherit (lib.nvim.types) mkPluginSetupOption luaInline; | ||||||
|   setupOptions = { |   setupOptions = { | ||||||
|     defaults = { |     defaults = { | ||||||
|       vimgrep_arguments = mkOption { |       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; |         type = listOf str; | ||||||
|         default = [ |         default = [ | ||||||
|           "${pkgs.ripgrep}/bin/rg" |           "${pkgs.ripgrep}/bin/rg" | ||||||
|  | @ -26,53 +22,65 @@ | ||||||
|           "--hidden" |           "--hidden" | ||||||
|           "--no-ignore" |           "--no-ignore" | ||||||
|         ]; |         ]; | ||||||
|  | 
 | ||||||
|  |         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. | ||||||
|  |         ''; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       pickers.find_command = mkOption { |       pickers.find_command = mkOption { | ||||||
|         description = "cmd to use for finding files"; |  | ||||||
|         type = either (listOf str) luaInline; |         type = either (listOf str) luaInline; | ||||||
|         default = ["${pkgs.fd}/bin/fd"]; |         default = ["${pkgs.fd}/bin/fd"]; | ||||||
|  |         description = '' | ||||||
|  |           Command to use for finding files. If using an executable from `PATH` then you must | ||||||
|  |           make sure that the package is available in [](#opt-vim.extraPackages). | ||||||
|  |         ''; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       prompt_prefix = mkOption { |       prompt_prefix = mkOption { | ||||||
|         description = "Shown in front of Telescope's prompt"; |  | ||||||
|         type = str; |         type = str; | ||||||
|         default = "     "; |         default = "     "; | ||||||
|  |         description = "Shown in front of Telescope's prompt"; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       selection_caret = mkOption { |       selection_caret = mkOption { | ||||||
|  |         type = str; | ||||||
|  |         default = "  "; | ||||||
|         description = "Character(s) to show in front of the current selection"; |         description = "Character(s) to show in front of the current selection"; | ||||||
|         type = str; |  | ||||||
|         default = "  "; |  | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       entry_prefix = mkOption { |       entry_prefix = mkOption { | ||||||
|         description = "Prefix in front of each result entry. Current selection not included."; |  | ||||||
|         type = str; |         type = str; | ||||||
|         default = "  "; |         default = "  "; | ||||||
|  |         description = "Prefix in front of each result entry. Current selection not included."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       initial_mode = mkOption { |       initial_mode = mkOption { | ||||||
|         description = "Determines in which mode telescope starts."; |  | ||||||
|         type = enum ["insert" "normal"]; |         type = enum ["insert" "normal"]; | ||||||
|         default = "insert"; |         default = "insert"; | ||||||
|  |         description = "Determines in which mode telescope starts."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       selection_strategy = mkOption { |       selection_strategy = mkOption { | ||||||
|         description = "Determines how the cursor acts after each sort iteration."; |  | ||||||
|         type = enum ["reset" "follow" "row" "closest" "none"]; |         type = enum ["reset" "follow" "row" "closest" "none"]; | ||||||
|         default = "reset"; |         default = "reset"; | ||||||
|  |         description = "Determines how the cursor acts after each sort iteration."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       sorting_strategy = mkOption { |       sorting_strategy = mkOption { | ||||||
|         description = ''Determines the direction "better" results are sorted towards.''; |  | ||||||
|         type = enum ["descending" "ascending"]; |         type = enum ["descending" "ascending"]; | ||||||
|         default = "ascending"; |         default = "ascending"; | ||||||
|  |         description = ''Determines the direction "better" results are sorted towards.''; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       layout_strategy = mkOption { |       layout_strategy = mkOption { | ||||||
|         description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`."; |  | ||||||
|         type = str; |         type = str; | ||||||
|         default = "horizontal"; |         default = "horizontal"; | ||||||
|  |         description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       layout_config = mkOption { |       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 = {}; |         default = {}; | ||||||
|         type = submodule { |         type = submodule { | ||||||
|           options = { |           options = { | ||||||
|  | @ -117,33 +125,57 @@ | ||||||
|             }; |             }; | ||||||
|           }; |           }; | ||||||
|         }; |         }; | ||||||
|  | 
 | ||||||
|  |         description = '' | ||||||
|  |           Determines the default configuration values for layout strategies. | ||||||
|  |           See `telescope.layout` for details of the configurations options for | ||||||
|  |           each strategy. | ||||||
|  |         ''; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       file_ignore_patterns = mkOption { |       file_ignore_patterns = mkOption { | ||||||
|         description = "A table of lua regex that define the files that should be ignored."; |  | ||||||
|         type = listOf str; |         type = listOf str; | ||||||
|         default = ["node_modules" ".git/" "dist/" "build/" "target/" "result/"]; |         default = ["node_modules" ".git/" "dist/" "build/" "target/" "result/"]; | ||||||
|  |         description = "A table of lua regex that define the files that should be ignored."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       color_devicons = mkOption { |       color_devicons = mkOption { | ||||||
|         description = "Boolean if devicons should be enabled or not."; |  | ||||||
|         type = bool; |         type = bool; | ||||||
|         default = true; |         default = true; | ||||||
|  |         description = "Boolean if devicons should be enabled or not."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       path_display = mkOption { |       path_display = mkOption { | ||||||
|         description = "Determines how file paths are displayed."; |  | ||||||
|         type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]); |         type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]); | ||||||
|         default = ["absolute"]; |         default = ["absolute"]; | ||||||
|  |         description = "Determines how file paths are displayed."; | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       set_env = mkOption { |       set_env = mkOption { | ||||||
|         description = "Set an environment for term_previewer"; |  | ||||||
|         type = attrsOf str; |         type = attrsOf str; | ||||||
|         default = { |         default = {COLORTERM = "truecolor";}; | ||||||
|           COLORTERM = "truecolor"; |         description = "Set an environment for term_previewer"; | ||||||
|         }; |  | ||||||
|       }; |       }; | ||||||
|  | 
 | ||||||
|       winblend = mkOption { |       winblend = mkOption { | ||||||
|         description = "pseudo-transparency of keymap hints floating window"; |  | ||||||
|         type = int; |         type = int; | ||||||
|         default = 0; |         default = 0; | ||||||
|  |         description = "pseudo-transparency of keymap hints floating window"; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   extensionOpts = { | ||||||
|  |     options = { | ||||||
|  |       name = mkOption { | ||||||
|  |         type = str; | ||||||
|  |         description = "Name of the extension, will be used to load it with a `require`"; | ||||||
|  |       }; | ||||||
|  | 
 | ||||||
|  |       packages = mkOption { | ||||||
|  |         type = listOf (either str package); | ||||||
|  |         default = []; | ||||||
|  |         description = "Package or packages providing the Telescope extension to be loaded."; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|  | @ -178,5 +210,10 @@ in { | ||||||
|     enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; |     enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; | ||||||
| 
 | 
 | ||||||
|     setupOpts = mkPluginSetupOption "Telescope" setupOptions; |     setupOpts = mkPluginSetupOption "Telescope" setupOptions; | ||||||
|  |     extensions = mkOption { | ||||||
|  |       type = listOf (attrsOf (submodule extensionOpts)); | ||||||
|  |       default = []; | ||||||
|  |       description = "TODO"; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue