-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on_choice
trigger and some in-place remodelling.
#49
base: main
Are you sure you want to change the base?
Conversation
@@ -1,14 +1,15 @@ | |||
local M = {} | |||
|
|||
---@enum Scratch.Trigger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lua/scratch/config.lua
Outdated
local co = coroutine.running() | ||
local confirmer = function(input) | ||
coroutine.resume(co, input) | ||
end | ||
confirmer = vim.schedule_wrap(confirmer) | ||
vim.ui.input({ prompt = "Input filetype: " }, confirmer) | ||
return coroutine.yield() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach to realizing that use case is to use vim.wait(1)
. I guess it should work, my suggestion depends on an async cycle, but I haven't tested it so I really don't know how to make it better.
And remove coroutine.wrap()
from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried vim.wait
like this:
local some
vim.ui.input(...)
vim.wait(1, function() return vim.g.__var_wait end)
return some
And it doesn't work at all, so maybe it should be implemented differently.
lua/scratch/api.lua
Outdated
@@ -8,6 +8,7 @@ local MANUAL_INPUT_OPTION = "MANUAL_INPUT" | |||
---@class Scratch.ActionOpts | |||
---@field window_cmd? Scratch.WindowCmd | |||
---@field content? string[] content will be put into the scratch file | |||
---@field hooks? {[string]: Scratch.Hooks, [Scratch.Trigger]:Scratch.Hook} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[string]: Scratch.Hooks
it is because after choosing, you need to call correctly. I think another approach is table<Scratch.Trigger, table<string, Scratch.Hook>| Scratch.Hook>
Each of the ideas is disgusting in its own way
Proof of concept #48