feat: floating input (#721)

* feat: add floating input to ask method

Open a floating input similar to the "edit" input for the "ask" input.
Enabled in config via `Config.windows.ask.floating` or by passing
`{ floating = true }` to the `api.ask` method.

Includes logic to ensure the sidebar uses the correct buffer and selection
if an existing sidebar is open for another code buffer.

Also refactored the `selection` module to extract the floating input
logic into a new `PromptInput` class.

* docs: update config options

* feat: more accurate annotations to prevent user misunderstandings

---------

Co-authored-by: yetone <yetoneful@gmail.com>
This commit is contained in:
Maddison Hellstrom
2024-10-14 20:22:34 -07:00
committed by GitHub
parent b19573cb2a
commit 964715be64
7 changed files with 443 additions and 286 deletions

View File

@@ -357,6 +357,27 @@ M.toggle_sidebar = function(opts)
return sidebar:toggle(opts)
end
M.is_sidebar_open = function()
local sidebar = M.get()
if not sidebar then return false end
return sidebar:is_open()
end
---@param opts? AskOptions
M.open_sidebar = function(opts)
opts = opts or {}
if opts.ask == nil then opts.ask = true end
local sidebar = M.get()
if not sidebar then M._init(api.nvim_get_current_tabpage()) end
M.current.sidebar:open(opts)
end
M.close_sidebar = function()
local sidebar = M.get()
if not sidebar then return end
sidebar:close()
end
M.toggle.debug = H.api(Utils.toggle_wrap({
name = "debug",
get = function() return Config.debug end,