mirror of
				https://github.com/folke/lazy.nvim.git
				synced 2025-10-31 14:31:04 +00:00 
			
		
		
		
	feat(cmd): use cmd table instead of trying to create the cmd string. Fixes #472
This commit is contained in:
		
					parent
					
						
							
								0dcc9071df
							
						
					
				
			
			
				commit
				
					
						3c29f196f4
					
				
			
		
					 1 changed files with 15 additions and 9 deletions
				
			
		|  | @ -14,16 +14,22 @@ end | |||
| ---@param cmd string | ||||
| function M:_add(cmd) | ||||
|   vim.api.nvim_create_user_command(cmd, function(event) | ||||
|     local command = { | ||||
|       cmd = cmd, | ||||
|       bang = event.bang or nil, | ||||
|       mods = event.smods, | ||||
|       args = event.fargs, | ||||
|       count = event.count >= 0 and event.count or nil, | ||||
|     } | ||||
| 
 | ||||
|     if event.range == 1 then | ||||
|       command.range = { event.line1 } | ||||
|     elseif event.range == 2 then | ||||
|       command.range = { event.line1, event.line2 } | ||||
|     end | ||||
| 
 | ||||
|     self:_load(cmd) | ||||
|     vim.cmd( | ||||
|       ("%s %s%s%s %s"):format( | ||||
|         event.mods or "", | ||||
|         event.line1 == event.line2 and "" or event.line1 .. "," .. event.line2, | ||||
|         cmd, | ||||
|         event.bang and "!" or "", | ||||
|         event.args or "" | ||||
|       ) | ||||
|     ) | ||||
|     vim.cmd(command) | ||||
|   end, { | ||||
|     bang = true, | ||||
|     range = true, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue