Skip to content

Introduce dirs.base.data_local helper#415

Open
bltavares wants to merge 1 commit into
volllly:mainfrom
bltavares:expose_dirs_config_local_dir
Open

Introduce dirs.base.data_local helper#415
bltavares wants to merge 1 commit into
volllly:mainfrom
bltavares:expose_dirs_config_local_dir

Conversation

@bltavares

Copy link
Copy Markdown

Thank you for the project. The design seems to fit quite nicely with my current dot-files setup.

I'd like to propose adding a new function to help setup neovim easier across
Windows and Linux/MacOS without having to rely on the per-platform path
declaration.

This PR introduces the dirs.base.data_local helper as a templating
function.

This exposes directories config_local_dir() for using in templating

Platform Value Example
Linux $XDG_CONFIG_HOME or $HOME/.config /home/alice/.config
macOS $HOME/Library/Application Support /Users/Alice/Library/Application Support
Windows {FOLDERID_LocalAppData} C:\Users\Alice\AppData\Local

This is useful for using specially in nvim to setup cross-platform config.

global:
  links:
    nvim: {{ dirs.base.data_local }}/nvim

This should expand to ~/.config/nvim in Linux and MacOS, as well as %USERPROFILE/AppData/Local/nvim on Windows.

This commit introduces the `dirs.base.data_local` helper as a templating
function.

This exposes `directories` [config_local_dir()](https://docs.rs/directories/latest/directories/struct.BaseDirs.html#method.config_local_dir) for using in templating

> |Platform | Value                                 | Example                                  |
> | ------- | ------------------------------------- | ---------------------------------------- |
> | Linux   | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config                      |
> | macOS   | `$HOME`/Library/Application Support   | /Users/Alice/Library/Application Support |
> | Windows | `{FOLDERID_LocalAppData}`             | C:\Users\Alice\AppData\Local             |

This is useful for using specially in `nvim` to setup cross-platform config.

```yaml
global:
  links:
    nvim: {{ dirs.base.data_local }}/nvim
```

This should expand to `~/.config/nvim` in Linux and MacOS, as well as `%USERPROFILE/AppData/Local/nvim` on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant