-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat!: support replace mode, new colors and improve performance via caching #59
base: main
Are you sure you want to change the base?
Conversation
I am currently in the middle of migrating to a new machine and I don't have any neovim setup at the moment so I can't test it. By skimming the changes, everything looks good, regardless of my personal preferences to avoid using:
Of course all of them are personal preference and not a bad thing, so feel free to ignore them |
Regarding documentation, I think it would be better if we could document the available highlight groups ( |
Really appreciate the feedback. I'll look into the custom colors not applying, that's something I simply haven't tried manually so thanks for bringing it up. As far as your feedback, @fitrh, the global shenanigans were inspired by mini.nvim but I'm not attached to anything. I'll definitely remove A large goal of this refactor was to help me regain a grasp of how modes even works because it's been a while since I've looked at it in depth and to allow easier disabling/enabling (especially the autocmds) |
& maybe we don't need to be able to configure colors via modes. We could have an example autocmd in the readme to modify the colors? Less abstraction is always my preferred way but I don't want to take away from UX either. |
I think we will end up removing colours then. The only question is what the API should look like. vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
-- With full control of fg/bg, using blend for the bg to replace `line_opacity`
vim.api.nvim_set_hl(0, "ModesInsert", { fg = "blue", bg = "blue", blend = 15 })
-- or only caring about the bg, leaving `line_opacity` as an option
vim.api.nvim_set_hl(0, "ModesInsert", { bg = "blue" })
end
}) Also, there seems to be a pretty bad performance regression—probably related to the autocmds. Haven't had time to debug but opening mini.files (presumably any ignored buffer) and navigating around brings nvim to a halt after a few seconds. |
Would diff --git a/plugin/modes.lua b/plugin/modes.lua
index cc97d14..8e95b79 100644
--- a/plugin/modes.lua
+++ b/plugin/modes.lua
@@ -1,7 +1,7 @@
-if vim.g.modes_loaded then
+if package.loaded["modes"] then
return
end
-vim.g.modes_loaded = true
+package.loaded["modes"] = true
require("modes").setup() Edit: after reading Also, I'm curious why you are against enabling the plugin without explicitly calling setup? I quite like this pattern from standard vim and aside from convention I don't see any downsides—especially with package managers like lazy.nvim having an Finally, once the colour handling is addressed/fixed the only remaining point I see is the use of |
There is no technical reason here, I just feel like that kind of behavior limits the user's freedom in how they want to load plugins (personally, for
The dependency on package managers/package manager-oriented stuff is one thing I really don't like in this day neovim plugin ecosystem It should be noted that I'm fine with all the changes, not against them, it's a matter of personal preference ❤️ |
Yes, we just need to check diff --git a/plugin/modes.lua b/plugin/modes.lua
index cc97d14..8e95b79 100644
--- a/plugin/modes.lua
+++ b/plugin/modes.lua
@@ -1,7 +1,7 @@
-if vim.g.modes_loaded then
+if package.loaded["modes"] then
return
end
-vim.g.modes_loaded = true
require("modes").setup() |
That’s fair. This is why I asked you—I only know my workflow so it’s good to hear more/different preferences and I respect yours :)
Yea I definitely wouldn’t want to rely on a specific package manager. I assume setting Thanks again for your input, I really do appreciate it |
Any progress on this? |
After some quick testing, it looks like the colours are working. The line numbers are only highlighted if you set the color scheme after setting up modes, though. @kamack38 you are welcome to use the canary branch and report any bugs here. If more people confirm that setting colours is working etc. then perhaps we can move this to the main branch. Edit: Looks like I never got around to fixing the performance regression. This can be reproduced by opening |
Getting closer here. The performance regression should be fixed in da8b76b. I removed the global |
This pull request is an internal refactor of modes, including support for replace mode, more predictable mode/operator detection, a shiny new palette, and builtin documentation.
These changes should not be breaking for most, but we have removed default
ignored_filetypes
as the detection of unlisted buffers seems to suffice.Todo
visual.color
andvisual.opacity
Fixes #57