spacemacs
spacemacs copied to clipboard
Idiomatic way to support a mode using `evil-collection`?
The documentation for the spacemacs-evil evil layer provides a suggestion for how users might enable evil-collection for a particular package. I wanted to enable evil-collection for info, so following the example I added the below to dotspacemacs/layers
(spacemacs-evil :variables
spacemacs-evil-collection-allowed-list
'(info))
This succeeds, but it breaks evil-collection support for other layers (e.g., dired). I suspect this is because the above declaration sets the default value of spacemacs-evil-collection-allowed list, which appears to clobber the defaults defined here. Other modes which are added by other layers (e.g., magit) do appear preserved, presumably because their {pre,post}-init code runs after I have set the value (like magit).
As a workaround, I tried adding the following to my dotspacemacs/user-config
(add-to-list 'spacemacs-evil-collection-allowed-list 'info)
This avoids clobbering support for dired, but it doesn't add evil-collection support for info, and I suspect this is because my user-config is evaluated after spacemacs-evil-collection-allowed-list has already been copied over to evil-collection-mode-list as part of the init for evil-collection here. Trying to do it as part of user-init doesn't work either since spacemacs-evil-collection-allowed-list isn't defined yet when that is evaluated.
I am able to get things to work as desired by bypassing spacemacs-evil-collection-allowed-list with this code in my user-config
(evil-collection-info-setup)
but this doesn't really feel idiomatic (and it also leaves the value of spacemacs-evil-collection-allowed-list and evil-collection-mode-list inconsistent with what modes are actually supported). What I'd really like is a way to get the :variables keyword for layer-specs to add to lists rather than overwrite variables. From some recent spelunking I did in configuration-layer/make-layer I suspect there isn't a keyword that does what I'm looking for.
At the very least, it'd be nice to update the spacemacs-evil documentation to give an example that won't break support for other modes (which I'm happy to submit as a PR) but I wanted to first see if there's a more idiomatic way to do this, or if we could add a new usage pattern for :variables (or a new keyword like :variables-append) that would support this pattern (which would probably require some changes to configuration-layer//set-layer-variables.
(evil-collection-info-setup)
(evil-collection-info-setup)
Are you saying that this is the idiomatic way to enable evil-collection support for a given ~~layer~~ package? If so, I'll submit a PR to update the spacemacs-evil documentation to reflect this.
No. This is one of three idiomatic ways to setup evil-collection to a package.
There's no one to one mapping between a package and a layer.
And there's no plan of enabling evil-collection by default for any layer.
Sorry, I meant package, not layer.
Is this one of three user-accessible idiomatic ways of enabling evil-collection support for a package? Or one of three idiomatic ways for doing it period (including in layers)? I understand the approach using pre-init in a given layer (like how the git layer does it for magit), but AFAICT this isn't accessible to an end user without modifying their spacemacs distribution, and I'm not sure what the other idiomatic approach is (call to evil-collection-init passing package as an argument?).
Either way, the approach suggested in the docs has unpleasant side effects, so if this is considered idiomatic I will submit PR against the docs to provide this approach as an example.
Please consult evil-collection for all the ways to initialization. It's clearly stated in its documentation.
has unpleasant side effect
Define side effect.
Please consult evil-collection for all the ways to initialization. It's clearly stated in its documentation.
I have. My question is what is the idiomatic way to do this in spacemacs since spacemacs provides spacemacs-evil-collection-allowed-list which is documented as "List of modes Spacemacs will allow to be evilified by ‘evil-collection-init’." It is of course not one of the approaches that evil-collection provides for documentation since it is not part of evil-collection.
Define side effect.
If I follow the guidance given in the documentation for spacemacs-evil, then adding evil-collection support for info (or eglot as in the example) removes support for dired (among other modes). This overrides (rather than augments) the modes supported by the spacemacs-evil layer itself. As a user, I do not expect that if I "enable evil-collection on eglot" that this will cause me to also disable evil-collection on dired, and so I would consider this a side effect.
That's why I always tell people to read source code instead of documentation.
It simply is not working.
Just forget about the integration of evil-collection of spacemacs-evil layer. Call evil-collection-*-setup functions yourself.
I appreciate the value of looking at the code, but nonetheless many people will consult and trust documentation, so I'll just open a PR to fix it and suggest calling evil-collection-*-setup in user-config.
Well. if you choose spacemacs-base distribution you'll have a chance to add it successfully. But I'd rather this is not documented.
@dankessler I see that this is not nicely integrated for non spacemacs-base users. Still I am not sure why a normal user would want to manually add evil collection support for a specific package.
Can you tell what's missing in the given evil bindings instead? Evil collection is notorious in interfering with keybindings therefore we are very careful in forcing its use in layers.
Having lots of users applying binding transformations in large scale does not sound like a scenario I would be keen to debug, if I am honest 🤔.
Rather this is something Spacemacs layers should handle.
Hit the exact same issue today. The docs of spacemacs-evil needs more clarification. I would not expect adding some extra mode to spacemacs-evil-collection-allowed-list would break basic stuff like dired.
I see lets have the handling for evil collection be revised, PRs are welcome.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!