Global settings config file support
Description of the problem or steps to reproduce
In micro, your settings are stored in ~/.config/micro/settings.json
According to doc micro uses only user settings file.
Would be great to supprt global config, like /etc/micro/settings.json for every user.
Specifications
micro-2.0.8
@zyedidia Is it possible to implement the feature?
You can provide a different config directory location with the MICRO_CONFIG_HOME environment variable, or by using the config-dir flag. Does this address what you want to do?
It would be nice to be able to keep two config dirs around, and overlay the user config on top of the global config. For instance, if a distro doesn't ship with sudo it can set sucmd in the global config file and then the user can set whatever other options they want in ~/.config
I have the same feature request. @AdrianVovk proposed a good solution that's intuitive & standard for many different Linux applications (e.g. tor, bash, nano, but AFAIK nvim lacks this feature).
I suggest supporting configuration similar to the following:
- Default global config in
/etc/micro:
├── plug
│ └── [...global plugin storage]
├── syntax
│ └── [...example syntax highlight files]
├── [...other supported dirs that make sense to be global, w/ examples]
├── bindings.json
└── settings.json
- Local config in
~/.config/micro:
├── buffers
│ └── history
├── plug
│ └── user_installed_plugin_001
├── [...other supported dirs]
├── bindings.json
└── settings.json
- Changes in
~/.config/microshould overwrite/etc/micro"atomically", "unit by unit", i.e. config entry per config entry, not file per file.
@zyedidia what do you think of this?
AFAIK, multi-source config management can be achieved with Viper library.
The suggested setup would help me support a global micro setup for all users on a few systems.
Currently I use the MICRO_CINFIG_HOME to point to the configuration for all users.
But they obviously cannot write all their backups and buffers there.
in settings.json I have "backupdir": "~/.config/micro/backups", but I cannot get savecursor working. I assume because the buffers are not saved. Any workaround for this?
Bert
Any workaround for this?
They could all have their own config directories (i.e. ~/.config/micro/ as usual) but with settings.json, bindings.json, init.lua, plug, colorschemes, syntax being symlinks to some global files?
To avoid the need for such hassle, we (or you?) could probably implement an option similar to backupdir for specifying a custom buffers directory instead of ~/.config/micro/buffers.
Will try your suggested setup and report back.
A built-in setup for buffers like backupdir if it supports globbing with e.g. ~ and $USER would be really nice.
Bert
To avoid the need for such hassle, we (or you?) could probably implement an option similar to
backupdirfor specifying a custom buffers directory instead of~/.config/micro/buffers.
I think we should just follow the XDG base directory specification and store the buffers in $XDG_STATE_HOME/micro/ (~/.local/state/micro/) on Linux by default. Backups don't really belong in the config directory either ($XDG_STATE_HOME would be more appropriate) but since we already have a setting for using a different directory there's no real need to mess with it.
related: #2004 #3176
I think we should just follow the XDG base directory specification and store the buffers in
$XDG_STATE_HOME/micro/(~/.local/state/micro/) on Linux by default. Backups don't really belong in the config directory either ($XDG_DATA_HOMEwould be more appropriate) but since we already have a setting for using a different directory there's no real need to mess with it.
That sounds even better. But that would be future work, so I'll go on for myself with the symlinks. And that is also work in process.
Not tested to the bones, but this works.
The contents of ~/conf/micro:
drwxr-xr-x 2 root root 4096 Aug 30 17:53 backups/
lrwxrwxrwx 1 root root 41 Aug 30 17:53 bindings.json -> /usr/local/share/micro-conf/bindings.json*
drwxr-xr-x 2 root root 4096 Aug 30 18:12 buffers/
lrwxrwxrwx 1 root root 40 Aug 30 17:53 colorschemes -> /usr/local/share/micro-conf/colorschemes/
lrwxrwxrwx 1 root root 36 Aug 30 17:53 init.lua -> /usr/local/share/micro-conf/init.lua*
lrwxrwxrwx 1 root root 32 Aug 30 17:53 plug -> /usr/local/share/micro-conf/plug/
lrwxrwxrwx 1 root root 41 Aug 30 17:53 settings.json -> /usr/local/share/micro-conf/settings.json*
lrwxrwxrwx 1 root root 34 Aug 30 17:53 syntax -> /usr/local/share/micro-conf/syntax/