mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 02:52:37 +00:00 
			
		
		
		
	neovim/clipboard: init module
This commit is contained in:
		
					parent
					
						
							
								1ed6fd9f58
							
						
					
				
			
			
				commit
				
					
						4678f73411
					
				
			
		
					 3 changed files with 86 additions and 1 deletions
				
			
		|  | @ -91,6 +91,9 @@ | ||||||
|   options for `vim.diagnostic.config()` can now be customized through the |   options for `vim.diagnostic.config()` can now be customized through the | ||||||
|   [](#opt-vim.diagnostics.config) in nvf. |   [](#opt-vim.diagnostics.config) in nvf. | ||||||
| 
 | 
 | ||||||
|  | - Add `vim.clipboard` module for easily managing Neovim clipboard providers and | ||||||
|  |   relevant packages in a simple UI. | ||||||
|  | 
 | ||||||
| [amadaluzia](https://github.com/amadaluzia): | [amadaluzia](https://github.com/amadaluzia): | ||||||
| 
 | 
 | ||||||
| [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim | [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim | ||||||
|  | @ -361,4 +364,5 @@ | ||||||
| 
 | 
 | ||||||
| [Hardtime.nvim]: https://github.com/m4xshen/hardtime.nvim | [Hardtime.nvim]: https://github.com/m4xshen/hardtime.nvim | ||||||
| 
 | 
 | ||||||
| - Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and `setupOpts` options | - Add Plugin [Hardtime.nvim] under `vim.binds.hardtime-nvim` with `enable` and | ||||||
|  |   `setupOpts` options | ||||||
|  |  | ||||||
							
								
								
									
										80
									
								
								modules/neovim/init/clipboard.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								modules/neovim/init/clipboard.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,80 @@ | ||||||
|  | { | ||||||
|  |   config, | ||||||
|  |   pkgs, | ||||||
|  |   lib, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   inherit (lib.modules) mkIf; | ||||||
|  |   inherit (lib.options) mkOption mkEnableOption mkPackageOption; | ||||||
|  |   inherit (lib.types) nullOr either str listOf submodule; | ||||||
|  |   inherit (lib.attrsets) mapAttrs mapAttrsToList filterAttrs; | ||||||
|  |   cfg = config.vim.clipboard; | ||||||
|  | in { | ||||||
|  |   options = { | ||||||
|  |     vim = { | ||||||
|  |       clipboard = { | ||||||
|  |         enable = mkEnableOption '' | ||||||
|  |           clipboard management for Neovim. Users may still choose to manage their | ||||||
|  |           clipboard through [](#opt-vim.options) should they wish to avoid using | ||||||
|  |           this module. | ||||||
|  |         ''; | ||||||
|  | 
 | ||||||
|  |         registers = mkOption { | ||||||
|  |           type = either str (listOf str); | ||||||
|  |           default = ""; | ||||||
|  |           example = "unnamedplus"; | ||||||
|  |           description = '' | ||||||
|  |             The register to be used by the Neovim clipboard. Recognized types are: | ||||||
|  | 
 | ||||||
|  |             * unnamed: Vim will use the clipboard register `"*"` for all yank, delete, | ||||||
|  |               change and put operations which would normally go to the unnamed register. | ||||||
|  | 
 | ||||||
|  |             * unnamedplus: A variant of the "unnamed" flag which uses the clipboard register | ||||||
|  |             `"+"` ({command}`:h quoteplus`) instead of register `"*"` for all yank, delete, | ||||||
|  |             change and put operations which would normally go to the unnamed register. | ||||||
|  | 
 | ||||||
|  |             When `unnamed` and `unnamedplus` is included simultaneously yank and delete | ||||||
|  |             operations (but not put) will additionally copy the text into register `"*"`. | ||||||
|  | 
 | ||||||
|  |             Please see  {command}`:h clipboard` for more details. | ||||||
|  | 
 | ||||||
|  |           ''; | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         providers = mkOption { | ||||||
|  |           type = submodule { | ||||||
|  |             options = let | ||||||
|  |               clipboards = { | ||||||
|  |                 # name = "package name"; | ||||||
|  |                 wl-copy = "wl-clipboard"; | ||||||
|  |                 xclip = "xclip"; | ||||||
|  |                 xsel = "xsel"; | ||||||
|  |               }; | ||||||
|  |             in | ||||||
|  |               mapAttrs (name: pname: { | ||||||
|  |                 enable = mkEnableOption name; | ||||||
|  |                 package = mkPackageOption pkgs pname {nullable = true;}; | ||||||
|  |               }) | ||||||
|  |               clipboards; | ||||||
|  |           }; | ||||||
|  |           default = {}; | ||||||
|  |           description = '' | ||||||
|  |             Clipboard providers for which packages will be added to nvf's | ||||||
|  |             {option}`extraPackages`. The `package` field may be set to `null` | ||||||
|  |             if related packages are already found in system packages to | ||||||
|  |             potentially reduce closure sizes. | ||||||
|  |           ''; | ||||||
|  |         }; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = mkIf cfg.enable { | ||||||
|  |     vim = { | ||||||
|  |       options.clipboard = cfg.registers; | ||||||
|  |       extraPackages = mapAttrsToList (_: v: v.package) ( | ||||||
|  |         filterAttrs (_: v: v.enable && v.package != null) cfg.providers | ||||||
|  |       ); | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
|   imports = [ |   imports = [ | ||||||
|     ./autocmds.nix |     ./autocmds.nix | ||||||
|     ./basic.nix |     ./basic.nix | ||||||
|  |     ./clipboard.nix | ||||||
|     ./debug.nix |     ./debug.nix | ||||||
|     ./diagnostics.nix |     ./diagnostics.nix | ||||||
|     ./highlight.nix |     ./highlight.nix | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue