refactor(ui): bounding popover (#13) (#29)

* refactor(ui): bounding popover (#13)

* refactor(ui): bounding popover

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: update readme instructions on setting up render-markdown.nvim

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: align code style

* fix: incorrect type annotation

* fix: make it work with mouse movement

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: focus correct on render

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: make sure to close the view

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: cleanup cursor position

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* docs: add notes on rc

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: make sure to apply if has diff

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: do not simulate user input

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: yetone <yetoneful@gmail.com>

* fix(autocmd): make sure to load tiktoken on correct events (closes #16) (#24)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* feat(type): better hinting on nui components (#27)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* feat: scrollview and tracking config and lazy load and perf (#33)

* feat: scrollview and tracking config and lazy load and perf

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: add back options

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* revert: remove unused autocmd

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* fix: get code content

* fix: keybinding hint virtual text position

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: yetone <yetoneful@gmail.com>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
yetone
2024-08-17 15:14:30 +08:00
committed by GitHub
parent ce5d421c98
commit f8cbc88424
10 changed files with 661 additions and 395 deletions

View File

@@ -1,6 +1,10 @@
---NOTE: user will be merged with defaults and
---we add a default var_accessor for this table to config values.
---@class avante.CoreConfig: avante.Config
local M = {}
local config = {
---@class avante.Config
M.defaults = {
provider = "claude", -- "claude" or "openai" or "azure"
openai = {
endpoint = "https://api.openai.com",
@@ -38,14 +42,37 @@ local config = {
prev = "[x",
},
},
windows = {
width = 30, -- default % based on available width
},
}
function M.update(opts)
config = vim.tbl_deep_extend("force", config, opts or {})
---@type avante.Config
M.options = {}
---@param opts? avante.Config
function M.setup(opts)
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
end
function M.get()
return config
M = setmetatable(M, {
__index = function(_, k)
if M.options[k] then
return M.options[k]
end
end,
})
function M.get_window_width()
return math.ceil(vim.o.columns * (M.windows.width / 100))
end
---@return {width: integer, height: integer, position: integer}
function M.get_renderer_layout_options()
local width = M.get_window_width()
local height = vim.o.lines
local position = vim.o.columns - width
return { width = width, height = height, position = position }
end
return M