feat(context): add a ui for selecting and adding files to the sidebar as context (#912)

* feat(sidebar): supports select files

chore (context) update add type annotations to context functions

chore (sidebar) remove unused notify function call

refactor (sidebar) remove setting search file to file path

chore (sidebar) remove nvim_notify debugging api call

* feat (files) allow selecting a file by string via cmp suggestion menu

* chore (context) refactor to allow context using @file with a context view

* refactor (context) refactor seletected file types as an array of path and content

* refactor (config) remove unused configuration options

* refactor (sidebar) remove unused unbild key

* refactor (context) remove unused imports

* refactor (mentions) update mentions to support items with callback functions and removal of the underlying selection.

* fix (sidebar) add file context as a window that is visitable via the tab key

* refactor (file_content) remove file content as an input to llm

* feat (sidebar) support suggesting and applying code in all languages that are in the context

* feat (sidebar) configurable mapping for removing a file from the context.

* feat (context_view) configure hints for the context view for adding and deleting a file.

* feat (context) add hints for the context view.

* fix (sidebar) type when scrolling the results buffer.

* refactor (selected files) refactor llm stream to accept an array of selected file metadata

* refactor: context => selected_files

---------

Co-authored-by: yetone <yetoneful@gmail.com>
This commit is contained in:
Christopher Brewin
2024-12-12 03:29:10 +10:00
committed by GitHub
parent 3b33170097
commit 78dd9b0a6d
13 changed files with 695 additions and 224 deletions

View File

@@ -2,7 +2,6 @@ local api = vim.api
local Config = require("avante.config")
local Utils = require("avante.utils")
local Highlights = require("avante.highlights")
local H = {}
local M = {}
@@ -558,7 +557,7 @@ end
---@param enable_autojump boolean
function M.process_position(bufnr, side, position, enable_autojump)
local lines = {}
if vim.tbl_contains({ SIDES.OURS, SIDES.THEIRS, SIDES.BASE }, side) then
if vim.tbl_contains({ SIDES.OURS, SIDES.THEIRS }, side) then
local data = position[name_map[side]]
lines = Utils.get_buf_lines(data.content_start, data.content_end + 1)
elseif side == SIDES.BOTH then
@@ -569,7 +568,7 @@ function M.process_position(bufnr, side, position, enable_autojump)
lines = {}
elseif side == SIDES.CURSOR then
local cursor_line = Utils.get_cursor_pos()
for _, pos in ipairs({ SIDES.OURS, SIDES.THEIRS, SIDES.BASE }) do
for _, pos in ipairs({ SIDES.OURS, SIDES.THEIRS }) do
local data = position[name_map[pos]] or {}
if data.range_start and data.range_start + 1 <= cursor_line and data.range_end + 1 >= cursor_line then
side = pos