🔍 Config resolution from a global path
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'
@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
@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.
@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.
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.
Also a great option, just be sure to use underscores: $CSPELL_DEFAULT_CONFIG_PATH
Any updates on this?
@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.