awesome
This commit is contained in:
parent
bab5ad2587
commit
cad3ae0846
|
@ -50,4 +50,62 @@ vim.keymap.set('v', '<A-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selection up' })
|
|||
vim.keymap.set('n', '<C-,>', 'gcc', { desc = 'Comment line', remap = true })
|
||||
vim.keymap.set('v', '<C-,>', 'gc', { desc = 'Comment selection', remap = true })
|
||||
|
||||
vim.keymap.set('v', '<C-c>', '"+y', { desc = 'Copy to clipboard' })
|
||||
vim.keymap.set('v', '<C-c>', '"+y', { desc = 'Copy to clipboard' })
|
||||
|
||||
-- New file and directory creation
|
||||
vim.keymap.set('n', '<leader>nf', function()
|
||||
local current_dir = vim.fn.expand('%:p:h')
|
||||
if current_dir == '' then
|
||||
current_dir = vim.fn.getcwd()
|
||||
end
|
||||
|
||||
vim.ui.input({
|
||||
prompt = 'New file name: ',
|
||||
default = current_dir .. '/',
|
||||
completion = 'file',
|
||||
}, function(input)
|
||||
if input then
|
||||
local file_path = input
|
||||
-- If it's not an absolute path, make it relative to current file's directory
|
||||
if not vim.startswith(file_path, '/') then
|
||||
file_path = current_dir .. '/' .. file_path
|
||||
end
|
||||
|
||||
-- Create parent directories if they don't exist
|
||||
local parent_dir = vim.fn.fnamemodify(file_path, ':h')
|
||||
vim.fn.mkdir(parent_dir, 'p')
|
||||
|
||||
-- Create and open the file
|
||||
vim.cmd('edit ' .. vim.fn.fnameescape(file_path))
|
||||
end
|
||||
end)
|
||||
end, { desc = 'New File' })
|
||||
|
||||
vim.keymap.set('n', '<leader>nd', function()
|
||||
local current_dir = vim.fn.expand('%:p:h')
|
||||
if current_dir == '' then
|
||||
current_dir = vim.fn.getcwd()
|
||||
end
|
||||
|
||||
vim.ui.input({
|
||||
prompt = 'New directory name: ',
|
||||
default = current_dir .. '/',
|
||||
completion = 'dir',
|
||||
}, function(input)
|
||||
if input then
|
||||
local dir_path = input
|
||||
-- If it's not an absolute path, make it relative to current file's directory
|
||||
if not vim.startswith(dir_path, '/') then
|
||||
dir_path = current_dir .. '/' .. dir_path
|
||||
end
|
||||
|
||||
-- Create the directory
|
||||
local success = vim.fn.mkdir(dir_path, 'p')
|
||||
if success == 1 then
|
||||
print('Created directory: ' .. dir_path)
|
||||
else
|
||||
print('Failed to create directory: ' .. dir_path)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end, { desc = 'New Directory' })
|
|
@ -0,0 +1,42 @@
|
|||
-- File operations plugin
|
||||
return {
|
||||
{
|
||||
'stevearc/dressing.nvim',
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
require('dressing').setup({
|
||||
input = {
|
||||
enabled = true,
|
||||
default_prompt = 'Input:',
|
||||
prompt_align = 'left',
|
||||
insert_only = true,
|
||||
start_in_insert = true,
|
||||
anchor = 'SW',
|
||||
border = 'rounded',
|
||||
relative = 'cursor',
|
||||
prefer_width = 40,
|
||||
width = nil,
|
||||
max_width = { 140, 0.9 },
|
||||
min_width = { 20, 0.2 },
|
||||
buf_options = {},
|
||||
win_options = {
|
||||
winblend = 10,
|
||||
wrap = false,
|
||||
},
|
||||
mappings = {
|
||||
n = {
|
||||
['<Esc>'] = 'Close',
|
||||
['<CR>'] = 'Confirm',
|
||||
},
|
||||
i = {
|
||||
['<C-c>'] = 'Close',
|
||||
['<CR>'] = 'Confirm',
|
||||
['<Up>'] = 'HistoryPrev',
|
||||
['<Down>'] = 'HistoryNext',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -46,6 +46,7 @@ return {
|
|||
{ '<leader>W', group = '[W]orkspace' },
|
||||
{ '<leader>t', group = '[T]oggle' },
|
||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
||||
{ '<leader>n', group = '[N]ew' },
|
||||
|
||||
-- General keybinds
|
||||
{ '<leader>w', desc = 'Save File' },
|
||||
|
@ -105,6 +106,10 @@ return {
|
|||
{ '<leader>tb', desc = 'Toggle git show blame line' },
|
||||
{ '<leader>tD', desc = 'Toggle git show deleted' },
|
||||
|
||||
-- New file/directory keybinds
|
||||
{ '<leader>nf', desc = 'New File' },
|
||||
{ '<leader>nd', desc = 'New Directory' },
|
||||
|
||||
-- Function keys
|
||||
{ '<F1>', desc = 'Debug: Step Into' },
|
||||
{ '<F2>', desc = 'Debug: Step Over' },
|
||||
|
|
Loading…
Reference in New Issue