Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AgatZan
Copy link
Contributor

@AgatZan AgatZan commented Oct 20, 2024

Proof of concept #48

@@ -1,14 +1,15 @@
local M = {}

---@enum Scratch.Trigger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 62 to 68
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()
Copy link
Contributor Author

@AgatZan AgatZan Oct 21, 2024

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
image

Copy link
Contributor Author

@AgatZan AgatZan Oct 22, 2024

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.

@@ -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}
Copy link
Contributor Author

@AgatZan AgatZan Oct 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant