Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Alternative installation method #24

Open
luckasRanarison opened this issue Aug 15, 2023 · 14 comments
Open

Alternative installation method #24

luckasRanarison opened this issue Aug 15, 2023 · 14 comments
Labels
enhancement New feature or request

Comments

@luckasRanarison
Copy link
Owner

luckasRanarison commented Aug 15, 2023

Edit: Writing the files when building the docs is done synchronously and freezes neovim for a moment. My initial thought was to create another program for managing docs but I prefer sticking with the current method, so instead I want to make write asynchronous.

@luckasRanarison luckasRanarison added the enhancement New feature or request label Aug 15, 2023
@emmanueltouzery
Copy link
Contributor

Do you intend to still allow to download from neovim (as currently) for users who'd prefer that?

@luckasRanarison
Copy link
Owner Author

luckasRanarison commented Aug 16, 2023

Yes, but I think most of people would be confused if the editor freezes when building docs with neovim

@emmanueltouzery
Copy link
Contributor

I'm not too sure, but I think it is or will soon be possible to have non blocking lua tasks:
neovim/neovim#17386

It's that's not enough (I really don't know), a hack for now could be to spawn another neovim (running your own code) to perform the computation, it's easy to work spawn other processes async. Or just name the call DownloadBlocking and warning the user before starting so it's less jarring. For me I'd go very far before I'd consider introducing another language/stdlib/runtime.

@emmanueltouzery
Copy link
Contributor

@emmanueltouzery
Copy link
Contributor

I think coroutines also exist:
https://www.reddit.com/r/neovim/comments/ld83tj/help_me_understand_this_lua_plugin_with_coroutines/

I think also diffview may use them (but unsure).

@emmanueltouzery
Copy link
Contributor

Ok last link I'm dropping and then I shut up:
https://github.com/ms-jpq/lua-async-await

@luckasRanarison
Copy link
Owner Author

Ok last link I'm dropping and then I shut up:
https://github.com/ms-jpq/lua-async-await

It's fine :), I really appreciate your help. I'll take a look at it. The only blocking operation is writing files, plenary provides a way to read files asynchronously but it doesn't provide a way to write files asynchronously.

@emmanueltouzery
Copy link
Contributor

I'd not assume plenary wraps all possible calls.

I'm without a computer this week, but maybe vim.loop.libuv_fs_write() or something?

Or ask in some neovim forum or similar.

https://teukka.tech/vimloop.html

@luckasRanarison luckasRanarison changed the title Make a separate program for building/managing docs Write files asynchronously Sep 13, 2023
@luckasRanarison luckasRanarison added the help wanted Extra attention is needed label Sep 14, 2023
@luckasRanarison luckasRanarison changed the title Write files asynchronously Alternative installation method Oct 1, 2023
@luckasRanarison luckasRanarison removed the help wanted Extra attention is needed label Oct 1, 2023
@luckasRanarison
Copy link
Owner Author

luckasRanarison commented Oct 2, 2023

Using a separate thread in neovim still blocks the input, and it's kinda inevitable.

Like you, I also want to keep installation inside neovim. But freezing when downloading really annoyed me recently, it uses a lot of RAM and sometimes also entirely freezes my computer.

I've found this and it could be interesting https://github.com/neovim/node-client. I think most of people already have node installed and the only needed dependencies are the neovim client and the treesitter node binding, I'll just have to rewrite the transpiler in js. Leaving the heavy operations to node sounds better and it'd still be a part of the plugin.

@emmanueltouzery
Copy link
Contributor

It's 100% your call, obviously! You know best 👍

And thanks again for the plugin!!

@luckasRanarison
Copy link
Owner Author

luckasRanarison commented Oct 22, 2023

I was wrong during all this time, writing files is really fast. Freezing actually happens when transpiling, but treesitter APIs are not available yet in multi-threaded code so transpiling must be done synchronously. Maybe in the future that will be possible but I'll work on a remote plugin using node as an alternative for now.

@emmanueltouzery
Copy link
Contributor

I know that some plugins are launching a separate neovim in another process to do things like that. That could achieve the desired effect without requiring much new work, or having to install node and so on?

@emmanueltouzery
Copy link
Contributor

I remembered which plugin spaws a separate neovim instance for async processing:
smjonas/live-command.nvim#29

I'm not saying it's necessarily a good idea.. in fact it should probably be avoided at all costs if at all possible. But in some extreme cases it's possibly the least bad option. Maybe keep in mind that it's an option.

@luckasRanarison
Copy link
Owner Author

I remembered which plugin spaws a separate neovim instance for async processing: smjonas/live-command.nvim#29

That's a really interesting idea! Neovim rpc interface is really powerful, I'll try some stuff and see how it goes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants