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

@@ -161,7 +161,7 @@ M.refresh = function(opts)
if not sidebar:is_open() then return end
local curbuf = vim.api.nvim_get_current_buf()
local focused = sidebar.result.bufnr == curbuf or sidebar.input.bufnr == curbuf
local focused = sidebar.result_container.bufnr == curbuf or sidebar.input_container.bufnr == curbuf
if focused or not sidebar:is_open() then return end
local listed = vim.api.nvim_get_option_value("buflisted", { buf = curbuf })
@@ -185,19 +185,19 @@ M.focus = function(opts)
local curwin = vim.api.nvim_get_current_win()
if sidebar:is_open() then
if curbuf == sidebar.input.bufnr then
if curbuf == sidebar.input_container.bufnr then
if sidebar.code.winid and sidebar.code.winid ~= curwin then vim.api.nvim_set_current_win(sidebar.code.winid) end
elseif curbuf == sidebar.result.bufnr then
elseif curbuf == sidebar.result_container.bufnr then
if sidebar.code.winid and sidebar.code.winid ~= curwin then vim.api.nvim_set_current_win(sidebar.code.winid) end
else
if sidebar.input.winid and sidebar.input.winid ~= curwin then
vim.api.nvim_set_current_win(sidebar.input.winid)
if sidebar.input_container.winid and sidebar.input_container.winid ~= curwin then
vim.api.nvim_set_current_win(sidebar.input_container.winid)
end
end
else
if sidebar.code.winid then vim.api.nvim_set_current_win(sidebar.code.winid) end
sidebar:open(opts)
if sidebar.input.winid then vim.api.nvim_set_current_win(sidebar.input.winid) end
if sidebar.input_container.winid then vim.api.nvim_set_current_win(sidebar.input_container.winid) end
end
end