Skip to content

Commit 1777885

Browse files
committed
Fix ctrl-e on popup AND default current dir for grep in dir
1 parent cb776c8 commit 1777885

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

init.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ vim.keymap.set('n', '<C-\\>', function()
228228
if vim.api.nvim_buf_is_loaded(bufnr) then
229229
return true
230230
end
231+
return false
231232
end, vim.api.nvim_list_bufs())
232233

233234
table.sort(bufnrs, function(a, b)
@@ -263,6 +264,9 @@ vim.keymap.set('n', 'K', function()
263264
vim.cmd { cmd = 'Rg', args = { vim.fn.expand '<cword>' } }
264265
end, { desc = 'Search Word and push to qf' })
265266

267+
-- in RSI
268+
-- vim.keymap.set('i', '<C-E>', '<End>')
269+
266270
-- [[ END MY OPTS ]]
267271

268272
-- [[ Basic Keymaps ]]
@@ -631,6 +635,7 @@ require('lazy').setup({
631635
end, { desc = '[S]earch [N]eovim files' })
632636

633637
vim.keymap.set('n', '<leader>sG', function()
638+
local path = vim.fn.expand '%:h'
634639
local out = vim.system({ 'fd', '-H', '--type', 'd', '--color', 'never' }, { text = true }):wait()
635640
-- local out = vim.system({ 'rg', '--files', '--hidden', '--color', 'never' }, { text = true }):wait()
636641

@@ -653,11 +658,16 @@ require('lazy').setup({
653658
.new(opts, {
654659
prompt_title = 'Grep in dir',
655660
finder = finders.new_table {
656-
results = { 'red', 'green', 'blue' },
657661
results = results,
658662
},
659663
sorter = conf.file_sorter(opts),
664+
default_text = path,
660665
attach_mappings = function(prompt_bufnr, map)
666+
map('i', '<c-space>', function(prompt_bufnr)
667+
local current_picker = action_state.get_current_picker(prompt_bufnr)
668+
current_picker:reset_prompt ''
669+
-- current_picker:set_prompt(path, false)
670+
end)
661671
actions.select_default:replace(function()
662672
actions.close(prompt_bufnr)
663673
local selection = action_state.get_selected_entry()
@@ -1070,6 +1080,8 @@ require('lazy').setup({
10701080
local luasnip = require 'luasnip'
10711081
luasnip.config.setup {}
10721082

1083+
-- local my_preset = cmp.mapping.preset
1084+
10731085
cmp.setup {
10741086
snippet = {
10751087
expand = function(args)
@@ -1108,6 +1120,13 @@ require('lazy').setup({
11081120
-- completions whenever it has completion options available.
11091121
['<C-Space>'] = cmp.mapping.complete {},
11101122

1123+
['<C-e>'] = {
1124+
i = function()
1125+
cmp.mapping.abort()
1126+
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<End>', true, false, true), 'n', false)
1127+
end,
1128+
},
1129+
11111130
-- Think of <c-l> as moving to the right of your snippet expansion.
11121131
-- So if you have a snippet that's like:
11131132
-- function $name($args)

0 commit comments

Comments
 (0)