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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃攳 Config resolution from a global path #5173

Open
bdsoha opened this issue Jan 17, 2024 · 7 comments
Open

馃攳 Config resolution from a global path #5173

bdsoha opened this issue Jan 17, 2024 · 7 comments

Comments

@bdsoha
Copy link

bdsoha commented Jan 17, 2024

Is your feature request related to a problem? Please describe.
The cspell tool can be installed globally (i.e. npm -g install ...), as well as executed from any directory.
However, the configuration files cannot be defined globally.

Describe the solution you'd like
I propose, that in addition to local configurations lookups, global lookups be included as well.
For example, configurations could also be stored in

  • $HOME/.cspell.{yaml,json}
  • $HOME/.config/cspell/*

Describe alternatives you've considered
Defining a global alias:

alias cspell='cspell --config=/home/.../.config/cspell/config.yaml'
@Jason3S
Copy link
Collaborator

Jason3S commented Jan 21, 2024

@bdsoha,

Will the cspell link command work for you?

cspell link --help

Usage: cspell link [options] [command]

Link dictionaries and other settings to the cspell global config.

Options:
  -h, --help               display help for command

Commands:
  list|ls                  List currently linked configurations.
  add|a <dictionaries...>  Add dictionaries any other settings to the cspell global config.
  remove|r <paths...>      Remove matching paths / packages from the global config.
  help [command]           display help for command

Using something like:

cspell link add ./cspell.config.yaml

@bdsoha
Copy link
Author

bdsoha commented Jan 21, 2024

@Jason3S
The suggested link command does indeed work.
However, it requires additional (manual) steps to be executed by the user.
I am suggested an automated (convention based) approach to the same solution.

@Jason3S
Copy link
Collaborator

Jason3S commented Jan 21, 2024

@bdsoha,

It is not exactly the same, but cspell does search up the directory structure looking for the configuration.

If you have a ~/.config/cspell.config.yaml file and you run cspell from ~/a/b/c, it will find the configuration as long as it does not find another one sooner.

@Jason3S
Copy link
Collaborator

Jason3S commented Jan 21, 2024

Another option would be to have cspell look at environment variables:

  • $CSPELL_DEFAULT_CONFIG_PATH - a path to the config to use if one is not found using the standard search method.
  • $CSPELL_CONFIG_PATH - a path the the config file to use as long as one has not been specified on the command line.

Edited based upon comment below.

@bdsoha
Copy link
Author

bdsoha commented Jan 21, 2024

Also a great option, just be sure to use underscores: $CSPELL_DEFAULT_CONFIG_PATH

@bdsoha
Copy link
Author

bdsoha commented Feb 8, 2024

Any updates on this?

@Jason3S
Copy link
Collaborator

Jason3S commented Feb 9, 2024

@bdsoha,

A PR is welcome if you would like to try.

This will most likely get done within the next three months. If it is urgent, consider a support contract: Street Side Software - Support.

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

No branches or pull requests

2 participants