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

Support for lewis6991/gitsigns.nvim broken #306

Closed
richardstrnad opened this issue Apr 18, 2022 · 6 comments · Fixed by #307
Closed

Support for lewis6991/gitsigns.nvim broken #306

richardstrnad opened this issue Apr 18, 2022 · 6 comments · Fixed by #307

Comments

@richardstrnad
Copy link

Hi,

Thanks for the amazing color theme! :)
Unfortunately the PR #294 (or commit a4bf0a6) broke support for the gitsigns plugin as the required styles are no longer loaded.

Would you accept an PR for this?

Cheers

@spywhere
Copy link

spywhere commented Apr 20, 2022

I can confirm the breaking on the vim-signify plugin as well.

Here's a reproducible configurations for neovim

plugin_home = vim.fn.stdpath('cache') .. '/nord.tmp'
vim_plug_url = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
vim_plug = plugin_home .. '/plug.vim'

if vim.fn.filereadable(vim_plug) == 0 then
  vim.cmd(
  'silent !curl -fLo ' .. vim_plug .. ' --create-dirs ' .. vim_plug_url
  )
end
vim.opt.runtimepath:append(plugin_home)

vim.fn['plug#begin'](plugin_home)
vim.fn['plug#']('mhinz/vim-signify')
vim.fn['plug#']('arcticicestudio/nord-vim')
vim.fn['plug#end']()
if vim.fn.isdirectory(plugin_home .. '/nord-vim') == 0 then
  vim.cmd('PlugInstall --sync | q')
end

print('before loaded_signify: ', vim.g.loaded_signify)
vim.cmd('colorscheme nord')
print('after loaded_signify: ', vim.g.loaded_signify)

Save it as some-name.lua and run it via nvim -u some-name.lua

Screen Shot 2565-04-20 at 12 37 46

So this block of code is not loaded when setting the color scheme

https://github.com/arcticicestudio/nord-vim/blob/291e05d96f7b938ab975e19205a42f6b41a35900/colors/nord.vim#L596-L601

@zxlvera
Copy link

zxlvera commented Apr 22, 2022

I'm not sure should I start a new issue, it is an aesthetic issue but in regards to Gitsigns as well. The highlights for nord is thick compare to other themes. Where can we configure this?

image

Gruvbox-material:

image

Catppuccin:
image

spywhere added a commit to spywhere/dotfiles that referenced this issue Apr 22, 2022
@richardstrnad
Copy link
Author

richardstrnad commented Apr 22, 2022

That's exactly the issue I have!
Temp fix

cd ~/.config/nvim/plugged/nord-vim
git checkout a8256787edbd4569a7f92e4e163308ab8256a6e5

@svengreb
Copy link
Member

svengreb commented Apr 23, 2022

Hi @richardstrnad 👋, thanks for your contribution 👍

Basically, the PR can't have broken the support because there has never been explicit support for the lewis6991/gitsigns.nvim plugin.
I was wondering why it might break anyway and found out that it is the way how the plugin uses highlighting groups, or better said which ones: it defines it own ones, which is the best way, but they also fall back to groups of other plugins like SignifySign* that is defined by mhinz/vim-signify.
Before PR #294 the groups for the mhinz/vim-signify plugin where loaded unconditionally so lewis6991/gitsigns.nvim picked them up since Nord does not define any GitSigns* group, but now the groups are only loaded when the mhinz/vim-signify plugin has been loaded too. Therefore the style with Nord “break“ when only the lewis6991/gitsigns.nvim plugin is loaded.

I'd say this is not a problem of the PR but only just a side effect. We could add dedicated support for the lewis6991/gitsigns.nvim plugin, but I would like to avoid adding more Neovim specific plugins/features as a dedicated Nord port for Neovim is in the pipeline.

@spywhere thanks for the reproduction snippet 👍🏼
This definitely looks more like a problem which could be related to the way how “vanilla“ Vim(8) and Neovim loading code, especially when using third-party plugin managers which might behave differently as well.

After playing around with multiple plugins that are explicitly supported by Nord, loaded with different Vim(8) and Neovim plugin managers, I noticed various problems with the way how plugins and loaded, especially their order and when the code is applied to global namespaces to be available to other scripts. I've often had reports regarding this issue and up to today this is still the most annoying reason why users having problems when it comes to loading Nord plugin options.

Anyway, I decided to revert the changes from PR #294 because I haven't thought about the fact that the plugin loading order could be random and the Nord plugin might be loaded before the ones that are supported, but the highlighting groups will be missing because of this. The advantage of having faster loading times which are only in the nanosecond range is way to

The advantage that it is only minimally faster (we're talking about nanoseconds here) is too small compared to the fact that the actual functionally of the plugin could no longer work properly.

@spywhere
Copy link

Instead of simply either conditionally or un-conditionally loaded plugin related highlights. I think we could introduce a new option to let the user choose if they want to change how it behaves.

In general, more features always good to have but more importantly is how to get those features roll out. And one easy way to make it happy for all is to opt-in into a new feature through configuration options.

Regardless, I think you would know best if it would be benefit or not. So revert the change is fine to me in this case.

@svengreb
Copy link
Member

svengreb commented Apr 23, 2022

Feature flags are often a good way, but it also comes with the cost of cluttering code with more and more conditions, especially when you have to maintain multiple deployment paths and some features are mutual.
However, in this case a feature flag would also not because the problem that plugins might be loaded in random order still exists. It also depends whether the user calls the function to load the Nord plugin before or after other plugins that it supports, so e.g. when the line to load the mhinz/vim-signify plugin comes after the one of Nord in the users configuration the current condition will fail because the global loaded_signify variable has not been declared and set.

Reverting the change it currently the only reliable way to ensure that it works for all users regardless of their own configurations or plugin managers behavior.

arcticicestudio pushed a commit that referenced this issue Apr 23, 2022
The changes introduced in PR GH-294 [1] did not take into account that
the order how plugins are loaded are not always constant and can also
change based on how users order plugins in their configurations.
When a supported plugin is loaded after Nord the global `loaded_*`
variable might not be available yet, causing the styles to be skipped
due to the conditional block guard. Also each plugin manager handles the
plugin loading order differently which is also a problem when checking
for global variable existence.

[1]: #294
[2]: #306

Fixes GH-306
svengreb added a commit that referenced this issue Apr 23, 2022
The changes introduced in PR GH-294 [1] did not take into account that
the order how plugins are loaded are not always constant and can also
change based on how users order plugins in their configurations.
When a supported plugin is loaded after Nord the global `loaded_*`
variable might not be available yet, causing the styles to be skipped
due to the conditional block guard. Also each plugin manager handles the
plugin loading order differently which is also a problem when checking
for global variable existence.

The loading time of the Nord plugin is still totally fine so improving
the stability for only a minimal performance boost is no negative trade
at all (tested via `vim --startuptime timing.out`):

  4.956ms: sourcing ~/.local/share/vim/plugged/nord-vim/colors/nord.vim

[1]: #294
[2]: #306

Fixes GH-306
arcticicestudio pushed a commit that referenced this issue May 14, 2022
The changes introduced in PR GH-294 [1] did not take into account that
the order how plugins are loaded are not always constant and can also
change based on how users order plugins in their configurations.
When a supported plugin is loaded after Nord the global `loaded_*`
variable might not be available yet, causing the styles to be skipped
due to the conditional block guard. Also each plugin manager handles the
plugin loading order differently which is also a problem when checking
for global variable existence.

The loading time of the Nord plugin is still totally fine so improving
the stability for only a minimal performance boost is no negative trade
at all (tested via `vim --startuptime timing.out`):

  4.956ms: sourcing ~/.local/share/vim/plugged/nord-vim/colors/nord.vim

[1]: #294
[2]: #306

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

Successfully merging a pull request may close this issue.

5 participants