Avoid using shell commands #16
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of using shell commands via
io.popen()andos.execute(), this PR changes the code to open a handle to the standard output TTY, and write to it directly.This improves plugin load time from ~8 ms to ~1 ms (on my laptop), which is nice. It also makes execution slightly faster each time the background is updated, which is not noticeable on fast machines, but is on slower ones. (I see a noticeable lag in background color updates on a slow university server without this change.)
This PR also replaces the deprecated
vim.api.nvim_get_hl_by_name()function withvim.api.nvim_get_hl().I've tested this in Ghostty and in a
tmuxsession, and both work as expected. I do not have Kitty installed, so I haven't tested the Kitty-specific functionality.