added nvim-tree integration to avanete

This commit is contained in:
Ellis Rahhal 2025-04-06 19:41:33 -07:00
parent a4488ddf90
commit e4e8213366

View file

@ -130,5 +130,39 @@
# };
};
};
nvim-tree = {
# Add "ga" keybinding to add to Avante context
onAttach.__raw = ''
function(bufnr)
local api = require 'nvim-tree.api'
api.config.mappings.default_on_attach(bufnr)
local add_file_to_avante_ctx = function()
local sidebar = require('avante').get()
if not (sidebar and sidebar:is_open()) then
return
end
local node = api.tree.get_node_under_cursor()
if not (node and node.type == 'file') then
return
end
sidebar.file_selector:add_selected_file(node.absolute_path)
end
vim.keymap.set('n', 'ga', add_file_to_avante_ctx, {
desc = 'add to Avante context',
buffer = bufnr,
noremap = true,
silent = true,
nowait = true,
})
end
'';
};
} else {};
}