added nvim-tree integration to avanete
This commit is contained in:
parent
a4488ddf90
commit
e4e8213366
1 changed files with 34 additions and 0 deletions
|
@ -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 {};
|
} else {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue