Compare commits
	
		
			1 Commits
		
	
	
		
			fcd5cfbd54
			...
			e78c8fc07f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e78c8fc07f | 
@ -36,6 +36,7 @@ return {
 | 
				
			|||||||
    vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
 | 
					    vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
 | 
				
			||||||
    vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
 | 
					    vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
 | 
				
			||||||
    vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
 | 
					    vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
 | 
				
			||||||
 | 
					    vim.keymap.set('n', '<leader>rg', builtin.grep_string, opts)
 | 
				
			||||||
    vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
 | 
					    vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
 | 
				
			||||||
    vim.keymap.set('n', '<leader>gh', builtin.help_tags, opts)
 | 
					    vim.keymap.set('n', '<leader>gh', builtin.help_tags, opts)
 | 
				
			||||||
    vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
 | 
					    vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
 | 
				
			||||||
 | 
				
			|||||||
@ -116,31 +116,16 @@ end, {
 | 
				
			|||||||
  complete = 'file',
 | 
					  complete = 'file',
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- :Rg grep for the given string, word under the cursor, or visual selection
 | 
					-- :Rg grep for the given string and fuzzy find the results, bang to enable
 | 
				
			||||||
-- then fuzzy find the results. Bang to enable regex in given string.
 | 
					-- regex in given string
 | 
				
			||||||
 | 
					-- FIXME: Support visual select modes
 | 
				
			||||||
vim.api.nvim_create_user_command('Rg', function(opts)
 | 
					vim.api.nvim_create_user_command('Rg', function(opts)
 | 
				
			||||||
  print(vim.inspect(opts))
 | 
					  local grep_opts = { search = opts.args }
 | 
				
			||||||
  local search = opts.args
 | 
					 | 
				
			||||||
  if opts.range == 2 then
 | 
					 | 
				
			||||||
    local lines = vim.fn.getline(vim.fn.line("'<"), vim.fn.line("'>"))
 | 
					 | 
				
			||||||
    local start_col = vim.fn.col("'<")
 | 
					 | 
				
			||||||
    local end_col = vim.fn.col("'>")
 | 
					 | 
				
			||||||
    if #lines == 1 then
 | 
					 | 
				
			||||||
      lines[1] = string.sub(lines[1], start_col, end_col)
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      lines[1] = string.sub(lines[1], start_col)
 | 
					 | 
				
			||||||
      lines[#lines] = string.sub(lines[#lines], 1, end_col)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
    search = table.concat(lines, "\n")
 | 
					 | 
				
			||||||
  elseif #search == 0 then
 | 
					 | 
				
			||||||
    search = vim.fn.expand('<cword>')
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
  local grep_opts = { search = search}
 | 
					 | 
				
			||||||
  if opts.bang then
 | 
					  if opts.bang then
 | 
				
			||||||
    grep_opts['use_regex'] = true
 | 
					    grep_opts['use_regex'] = true
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  require('telescope.builtin').grep_string(grep_opts)
 | 
					  require('telescope.builtin').grep_string(grep_opts)
 | 
				
			||||||
end, { bang = true, range = true, nargs = '*' })
 | 
					end, { bang = true, nargs = '*' })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
 | 
					vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
 | 
				
			||||||
  local buffer = vim.api.nvim_get_current_buf()
 | 
					  local buffer = vim.api.nvim_get_current_buf()
 | 
				
			||||||
@ -149,5 +134,5 @@ vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
 | 
				
			|||||||
  vim.api.nvim_buf_set_lines(
 | 
					  vim.api.nvim_buf_set_lines(
 | 
				
			||||||
    buffer, opts.line1 - 1, opts.line1 - 1, true, { '#if 0' })
 | 
					    buffer, opts.line1 - 1, opts.line1 - 1, true, { '#if 0' })
 | 
				
			||||||
  local window = vim.api.nvim_get_current_win()
 | 
					  local window = vim.api.nvim_get_current_win()
 | 
				
			||||||
  vim.api.nvim_win_set_cursor(window, { opts.line1, 5 })
 | 
					  vim.api.nvim_win_set_cursor(window, {opts.line1, 5})
 | 
				
			||||||
end, { range = true })
 | 
					end, { range = true })
 | 
				
			||||||
 | 
				
			|||||||
@ -43,7 +43,3 @@ vim.keymap.set('t', '<C-w><C-g>', '<C-\\><C-n>:Gdb<CR>:startinsert<CR>', opts)
 | 
				
			|||||||
vim.keymap.set('t', '<C-w><C-e>', '<C-\\><C-n>:Program<CR>', opts)
 | 
					vim.keymap.set('t', '<C-w><C-e>', '<C-\\><C-n>:Program<CR>', opts)
 | 
				
			||||||
vim.keymap.set('t', '<C-w><C-s>', '<C-\\><C-n>:Source<CR>', opts)
 | 
					vim.keymap.set('t', '<C-w><C-s>', '<C-\\><C-n>:Source<CR>', opts)
 | 
				
			||||||
vim.keymap.set('t', '<C-w><C-a>', '<C-\\><C-n>:Asm<CR>', opts)
 | 
					vim.keymap.set('t', '<C-w><C-a>', '<C-\\><C-n>:Asm<CR>', opts)
 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Mappings to grep for then fuzzy find the word under the cursor or visual selection
 | 
					 | 
				
			||||||
vim.keymap.set('n', '<leader>rg', ':Rg<CR>', opts)
 | 
					 | 
				
			||||||
vim.keymap.set('v', '<leader>rg', ":'<,'>Rg<CR>", opts)
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user