refactor: complete rewrite
This commit is contained in:
		
							parent
							
								
									19a4bbda3c
								
							
						
					
					
						commit
						8e81943cf9
					
				
					 399 changed files with 3396 additions and 8042 deletions
				
			
		
							
								
								
									
										55
									
								
								outputs/pkgs/ook-vim/modules/plugins/telescope/config.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								outputs/pkgs/ook-vim/modules/plugins/telescope/config.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,55 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   inputs, | ||||
|   ... | ||||
| }: let | ||||
|   inherit (lib) mkIf mkOption; | ||||
|   inherit (lib.types) bool; | ||||
|   inherit (inputs.nvf.lib.nvim.dag) entryAfter; | ||||
|   cfg = config.vim.telescope; | ||||
| in { | ||||
|   options.vim.telescope = { | ||||
|     autostart = mkOption { | ||||
|       type = bool; | ||||
|       default = false; | ||||
|       description = "Auto start telescope when opening neovim unless opening a file"; | ||||
|     }; | ||||
|   }; | ||||
|   config = mkIf cfg.autostart { | ||||
|     vim.luaConfigRC.telescope-autostart = | ||||
|       entryAfter ["pluginConfigs"] | ||||
|       #lua | ||||
|       '' | ||||
|         local find_files_hijack_netrw = vim.api.nvim_create_augroup("find_files_hijack_netrw", { clear = true }) | ||||
|         -- clear FileExplorer appropriately to prevent netrw from launching on folders | ||||
|         -- netrw may or may not be loaded before telescope-find-files | ||||
|         -- conceptual credits to nvim-tree and telescope-file-browser | ||||
|         vim.api.nvim_create_autocmd("VimEnter", { | ||||
|             pattern = "*", | ||||
|             once = true, | ||||
|             callback = function() | ||||
|                 pcall(vim.api.nvim_clear_autocmds, { group = "FileExplorer" }) | ||||
|             end, | ||||
|         }) | ||||
|         vim.api.nvim_create_autocmd("BufEnter", { | ||||
|             group = find_files_hijack_netrw, | ||||
|             pattern = "*", | ||||
|             callback = function() | ||||
|                 vim.schedule(function() | ||||
|                     -- Early return if netrw or not a directory | ||||
|                     if vim.bo[0].filetype == "netrw" or vim.fn.isdirectory(vim.fn.expand("%:p")) == 0 then | ||||
|                         return | ||||
|                     end | ||||
| 
 | ||||
|                     vim.api.nvim_buf_set_option(0, "bufhidden", "wipe") | ||||
| 
 | ||||
|                     require("telescope.builtin").find_files({ | ||||
|                         cwd = vim.fn.expand("%:p:h"), | ||||
|                     }) | ||||
|                 end) | ||||
|             end, | ||||
|         }) | ||||
|       ''; | ||||
|   }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue