Compare commits

..

2 commits

Author SHA1 Message Date
bbf89f5752
restucture keybindings 2025-11-20 01:48:27 -06:00
bce9fac052
add normal mode in compile-mode and find-file 2025-11-20 01:47:59 -06:00
3 changed files with 27 additions and 9 deletions

View file

@ -479,6 +479,7 @@ end
map('n', '<leader>ex', function() require('fyler').toggle { kind = 'split_left_most' } end, 'Toggle file tree')
map('n', '<leader>fs', '<cmd>w<cr>', 'Save file')
map('n', '<leader>ff', function() require('find-file').open() end, 'Find file')
map('n', '<leader>fr', function() require('snacks').picker.recent() end, 'Find recent file')
map('n', '<leader>:', function() require('snacks').picker.command_history() end, 'Command history')
-- map('n', '<leader>ex', function() require('snacks').explorer() end, 'Toggle file tree')
@ -488,12 +489,16 @@ map('n', '<leader>.', function() require('snacks').scratch() end, 'Scratch buffe
map('n', '<leader>sf', function() require('snacks').picker.files() end, 'Search file')
map('n', '<leader>sg', function() require('snacks').picker.grep() end, 'Search grep')
map('n', '<leader>sw', function() require('snacks').picker.grep_word() end, 'Search grep word')
map('n', '<leader>sb', function() require('snacks').picker.lines() end, 'Buffer lines')
map('n', '<leader>sB', function() require('snacks').picker.lines() end, 'Grep open buffers')
map('n', '<leader>ls', function() require('snacks').picker.lsp_symbols() end, 'LSP Symbols')
map('n', '<leader>lS', function() require('snacks').picker.lsp_workspace_symbols() end, 'LSP Workspace Symbols')
map('n', '<leader>zz', function() require('snacks').zen() end, 'Toggle zen mode')
map('n', '<leader>zm', function() require('snacks').zen.zoom() end, 'Toggle Zoom')
map('n', '<leader>qq', function() require('quicker').open { focus = true } end, 'Open/focus quickfix')
map('n', '<leader>ql', function() require('quicker').toggle { loclist = true } end, 'Toggle loclist')
map('n', '<leader>cc', function() require('compile-mode').compile() end, 'Compile')
map('n', '<leader>cC', function() require('compile-mode').recompile() end, 'Recompile')
map('n', '<leader>cr', '<cmd>source $MYVIMRC<cr>', 'Reload config')

View file

@ -684,7 +684,7 @@ function M.compile()
-- Cycle to next completion candidate
if config.input_keymaps.next then
vim.keymap.set('i', config.input_keymaps.next, function()
local next_fn = function()
if #matches == 0 then
matches = get_matches(current_input)
if #matches == 0 then return end
@ -696,12 +696,14 @@ function M.compile()
current_input = table.concat(words, ' ')
last_input = current_input
vim.schedule(update_display)
end, opts)
end
vim.keymap.set('i', config.input_keymaps.next, next_fn, opts)
vim.keymap.set('n', config.input_keymaps.next, next_fn, opts)
end
-- Cycle to previous completion candidate
if config.input_keymaps.prev then
vim.keymap.set('i', config.input_keymaps.prev, function()
local prev_fn = function()
if #matches == 0 then
matches = get_matches(current_input)
if #matches == 0 then return end
@ -714,7 +716,9 @@ function M.compile()
current_input = table.concat(words, ' ')
last_input = current_input
vim.schedule(update_display)
end, opts)
end
vim.keymap.set('i', config.input_keymaps.prev, prev_fn, opts)
vim.keymap.set('n', config.input_keymaps.prev, prev_fn, opts)
end
-- Complete to selected candidate
@ -790,7 +794,12 @@ function M.compile()
local close_keys = type(config.input_keymaps.close) == 'table' and config.input_keymaps.close --[[@as string[] ]]
or { config.input_keymaps.close }
for _, key in ipairs(close_keys) do
if key then vim.keymap.set({ 'i', 'n' }, key, function() vim.schedule(close) end, opts) end
if key then
-- In insert mode: exit to normal mode first
vim.keymap.set('i', key, '<Esc>', opts)
-- In normal mode: close the prompt
vim.keymap.set('n', key, function() vim.schedule(close) end, opts)
end
end
-- Delete path component

View file

@ -332,7 +332,7 @@ function M.open_dir(start_path)
local last_input = current_input
vim.api.nvim_create_autocmd({ 'TextChangedI' }, {
vim.api.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, {
buffer = input_buf,
callback = function()
if lock or cycling then return end
@ -354,7 +354,7 @@ function M.open_dir(start_path)
end,
})
vim.api.nvim_create_autocmd({ 'CursorMovedI' }, {
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = input_buf,
callback = function()
if lock or cycling then return end
@ -456,9 +456,13 @@ function M.open_dir(start_path)
end, { buffer = input_buf, nowait = true, expr = true, desc = 'Open file or directory' })
---@type string[]
local close_keys = type(config.keymaps.close) == 'table' and config.keymaps.close --[[@as string[] ]] or { config.keymaps.close }
local close_keys = type(config.keymaps.close) == 'table' and config.keymaps.close --[[@as string[] ]]
or { config.keymaps.close }
for _, key in ipairs(close_keys) do
vim.keymap.set({ 'n', 'i' }, key, function() vim.schedule(close) end, vim.tbl_extend('force', opts, { desc = 'Close find-file' }))
-- In insert mode: exit to normal mode first
vim.keymap.set('i', key, '<Esc>', vim.tbl_extend('force', opts, { desc = 'Exit to normal mode' }))
-- In normal mode: close the prompt
vim.keymap.set('n', key, function() vim.schedule(close) end, vim.tbl_extend('force', opts, { desc = 'Close find-file' }))
end
vim.keymap.set('i', config.keymaps.delete_component, function()