mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-29 18:33:53 +00:00 
			
		
		
		
	utility/surround: Add mappings for nvim-surround
The default mappings for nvim-leap and nvim-surround conflict (i.e. nvim-surround uses `S` in visual mode). This change adds options to adapt the mappings for nvim-surround directly from the surround-module.
This commit is contained in:
		
					parent
					
						
							
								e6a4f2d66b
							
						
					
				
			
			
				commit
				
					
						59c23f2855
					
				
			
		
					 2 changed files with 84 additions and 7 deletions
				
			
		|  | @ -6,14 +6,38 @@ | |||
| with lib; | ||||
| with builtins; let | ||||
|   cfg = config.vim.utility.surround; | ||||
|   self = import ./surround.nix {inherit lib;}; | ||||
|   mappingDefinitions = self.options.vim.utility.surround.mappings; | ||||
|   mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; | ||||
| in { | ||||
|   config = mkIf (cfg.enable) { | ||||
|     vim.startPlugins = [ | ||||
|       "nvim-surround" | ||||
|     ]; | ||||
|   config = mkIf cfg.enable { | ||||
|     vim = { | ||||
|       startPlugins = [ | ||||
|         "nvim-surround" | ||||
|       ]; | ||||
| 
 | ||||
|     vim.luaConfigRC.surround = nvim.dag.entryAnywhere '' | ||||
|       require('nvim-surround').setup() | ||||
|     ''; | ||||
|       luaConfigRC.surround = nvim.dag.entryAnywhere '' | ||||
|         require('nvim-surround').setup() | ||||
|       ''; | ||||
| 
 | ||||
|       maps = { | ||||
|         insert = mkMerge [ | ||||
|           (mkSetBinding mappings.insert "<Plug>(nvim-surround-insert)") | ||||
|           (mkSetBinding mappings.insertLine "<Plug>(nvim-surround-insert-line)") | ||||
|         ]; | ||||
|         normal = mkMerge [ | ||||
|           (mkSetBinding mappings.normal "<Plug>(nvim-surround-normal)") | ||||
|           (mkSetBinding mappings.normalCur "<Plug>(nvim-surround-normal-cur)") | ||||
|           (mkSetBinding mappings.normalLine "<Plug>(nvim-surround-normal-line)") | ||||
|           (mkSetBinding mappings.normalCurLine "<Plug>(nvim-surround-normal-cur-line)") | ||||
|           (mkSetBinding mappings.delete "<Plug>(nvim-surround-delete)") | ||||
|           (mkSetBinding mappings.change "<Plug>(nvim-surround-change)") | ||||
|         ]; | ||||
|         visualOnly = mkMerge [ | ||||
|           (mkSetBinding mappings.visual "<Plug>(nvim-surround-visual)") | ||||
|           (mkSetBinding mappings.visualLine "<Plug>(nvim-surround-visual-line)") | ||||
|         ]; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
|  | @ -3,5 +3,58 @@ with lib; | |||
| with builtins; { | ||||
|   options.vim.utility.surround = { | ||||
|     enable = mkEnableOption "nvim-surround: add/change/delete surrounding delimiter pairs with ease"; | ||||
|     mappings = { | ||||
|       insert = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "<C-g>s"; | ||||
|         description = "Add surround character around the cursor"; | ||||
|       }; | ||||
|       insertLine = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "<C-g>S"; | ||||
|         description = "Add surround character around the cursor on new lines"; | ||||
|       }; | ||||
|       normal = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "ys"; | ||||
|         description = "Surround motion with character"; | ||||
|       }; | ||||
|       normalCur = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "yss"; | ||||
|         description = "Surround motion with character on new lines"; | ||||
|       }; | ||||
|       normalLine = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "yS"; | ||||
|         description = "Surround line with character"; | ||||
|       }; | ||||
|       normalCurLine = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "ySS"; | ||||
|         description = "Surround line with character on new lines"; | ||||
|       }; | ||||
|       visual = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "S"; | ||||
|         description = "Surround selection with character"; | ||||
|       }; | ||||
|       visualLine = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "gS"; | ||||
|         description = "Surround selection with character on new lines"; | ||||
|       }; | ||||
|       delete = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "ds"; | ||||
|         description = "Delete surrounding character"; | ||||
|       }; | ||||
|       change = mkOption { | ||||
|         type = types.nullOr types.str; | ||||
|         default = "cs"; | ||||
|         description = "Change surrounding character"; | ||||
|       }; | ||||
| 
 | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kalle Jepsen
				Kalle Jepsen