diff --git a/plugins/avante.nix b/plugins/avante.nix index 27acd51..deb975b 100644 --- a/plugins/avante.nix +++ b/plugins/avante.nix @@ -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 {}; }