Claude code prompt with nvim - insert @<filename>
nvim claude-code
Add a ~/.config/nvim/lua/plugins/telescope-insert-path.lua
:
return {
{
"nvim-telescope/telescope.nvim",
keys = {
{
"<leader>fP",
function()
require("telescope.builtin").find_files({
attach_mappings = function(prompt_bufnr, map)
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
-- Override Enter to insert relative path instead of opening file
actions.select_default:replace(function()
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
if selection then
local path = vim.fn.fnamemodify(selection.path or selection.value, ":.")
vim.api.nvim_put({ path }, "c", false, true)
end
end)
return true
end,
})
end,
desc = "Find files and insert path",
},
},
},
}
You can now press <leader>fP
filter the file you want and press enter to insert relative path of the file.