some small nvim changes
This commit is contained in:
@@ -228,6 +228,7 @@ in
|
||||
nnoremap <leader>fb <cmd>Telescope buffers<cr>
|
||||
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
|
||||
nnoremap <leader>ft <cmd>Telescope tags<cr>
|
||||
nnoremap <leader>fr <cmd>lua KitaabRecent()<cr>
|
||||
|
||||
" exit normal mode in terminal
|
||||
:tnoremap <C-n> <C-\><C-n>
|
||||
@@ -975,6 +976,110 @@ in
|
||||
vim.keymap.set('n', '<M-S-k>', '<Cmd>resize +2<CR>', {silent = true})
|
||||
vim.keymap.set('n', '<M-S-l>', '<Cmd>vertical resize +2<CR>', {silent = true})
|
||||
|
||||
-- Kitaab recent files (only date-based files, sorted reverse)
|
||||
function KitaabRecent()
|
||||
local pickers = require('telescope.pickers')
|
||||
local finders = require('telescope.finders')
|
||||
local conf = require('telescope.config').values
|
||||
|
||||
-- Use current working directory
|
||||
local kitaab_path = vim.fn.getcwd()
|
||||
|
||||
-- Get all files (depth 1, exclude directories)
|
||||
local files = vim.fn.readdir(kitaab_path, function(name)
|
||||
return vim.fn.isdirectory(kitaab_path .. '/' .. name) == 0
|
||||
end)
|
||||
|
||||
-- Filter to only date-based files (starting with digit)
|
||||
local date_files = {}
|
||||
for _, filename in ipairs(files) do
|
||||
if filename:match('^%d') then
|
||||
table.insert(date_files, filename)
|
||||
end
|
||||
end
|
||||
|
||||
-- Sort in reverse (most recent first)
|
||||
table.sort(date_files, function(a, b) return a > b end)
|
||||
|
||||
pickers.new({}, {
|
||||
prompt_title = 'Kitaab Recent',
|
||||
finder = finders.new_table({
|
||||
results = date_files,
|
||||
entry_maker = function(entry)
|
||||
return {
|
||||
value = kitaab_path .. '/' .. entry,
|
||||
display = entry,
|
||||
ordinal = entry,
|
||||
path = kitaab_path .. '/' .. entry,
|
||||
}
|
||||
end
|
||||
}),
|
||||
previewer = conf.file_previewer({}),
|
||||
sorter = conf.generic_sorter({}),
|
||||
}):find()
|
||||
end
|
||||
|
||||
-- Setup amp.nvim
|
||||
require('amp').setup({
|
||||
auto_start = true,
|
||||
log_level = "info"
|
||||
})
|
||||
|
||||
-- Amp commands
|
||||
vim.api.nvim_create_user_command("AmpSend", function(opts)
|
||||
local message = opts.args
|
||||
if message == "" then
|
||||
print("Please provide a message to send")
|
||||
return
|
||||
end
|
||||
local amp_message = require("amp.message")
|
||||
amp_message.send_message(message)
|
||||
end, {
|
||||
nargs = "*",
|
||||
desc = "Send a message to Amp",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("AmpSendBuffer", function(opts)
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
local content = table.concat(lines, "\n")
|
||||
local amp_message = require("amp.message")
|
||||
amp_message.send_message(content)
|
||||
end, {
|
||||
nargs = "?",
|
||||
desc = "Send current buffer contents to Amp",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("AmpPromptSelection", function(opts)
|
||||
local lines = vim.api.nvim_buf_get_lines(0, opts.line1 - 1, opts.line2, false)
|
||||
local text = table.concat(lines, "\n")
|
||||
local amp_message = require("amp.message")
|
||||
amp_message.send_to_prompt(text)
|
||||
end, {
|
||||
range = true,
|
||||
desc = "Add selected text to Amp prompt",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("AmpPromptRef", function(opts)
|
||||
local bufname = vim.api.nvim_buf_get_name(0)
|
||||
if bufname == "" then
|
||||
print("Current buffer has no filename")
|
||||
return
|
||||
end
|
||||
local relative_path = vim.fn.fnamemodify(bufname, ":.")
|
||||
local ref = "@" .. relative_path
|
||||
if opts.line1 ~= opts.line2 then
|
||||
ref = ref .. "#L" .. opts.line1 .. "-" .. opts.line2
|
||||
elseif opts.line1 > 1 then
|
||||
ref = ref .. "#L" .. opts.line1
|
||||
end
|
||||
local amp_message = require("amp.message")
|
||||
amp_message.send_to_prompt(ref)
|
||||
end, {
|
||||
range = true,
|
||||
desc = "Add file reference (with selection) to Amp prompt",
|
||||
})
|
||||
|
||||
EOF
|
||||
|
||||
'';
|
||||
@@ -1093,6 +1198,17 @@ in
|
||||
yuck-vim
|
||||
nvim-parinfer
|
||||
# vim-processing
|
||||
|
||||
# amp.nvim for Sourcegraph Amp integration
|
||||
(pkgs.vimUtils.buildVimPlugin {
|
||||
name = "amp-nvim";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "sourcegraph";
|
||||
repo = "amp.nvim";
|
||||
rev = "main";
|
||||
sha256 = "1n6d8nbakyg6yiq8mhhrvmsp9z0zb8cb67820jsg3wl6vqd1vwv5";
|
||||
};
|
||||
})
|
||||
];
|
||||
withPython3 = true;
|
||||
extraPython3Packages = pkgs: with pkgs; [ tasklib six packaging ];
|
||||
@@ -1100,3 +1216,4 @@ in
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user