| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Vgrep.Environment.Config.Sources
Synopsis
- editorConfigFromEnv :: MonadIO io => io ConfigMonoid
- configFromFile :: MonadIO io => io ConfigMonoid
Documentation
editorConfigFromEnv :: MonadIO io => io ConfigMonoid Source #
Determines the ConfigMonoid value for _editor
(_meditor) from the environment variable $EDITOR.
configFromFile :: MonadIO io => io ConfigMonoid Source #
Reads the configuration from a JSON or YAML file. The file should be located in one of the following places:
~/.vgrep/config.yaml,~/.vgrep/config.yml,~/.vgrep/config.jsonor~/.vgrep/config.
When none of these files exist, no error is raised. When a file exists, but cannot be parsed, a warning is written to stderr.
Supported formats are JSON and YAML. The example YAML config given in the
project directory (config.yaml.example) is equivalent to the default
config:
>>>import qualified Vgrep.Environment.Config as C>>>Right config <- decodeFileEither "config.yaml.example" :: IO (Either ParseException ConfigMonoid)>>>C.fromConfigMonoid config == C.defaultConfigTrue
Example YAML config file for defaultConfig:
colors:
line-numbers:
fore-color: blue
line-numbers-hl:
fore-color: blue
style: bold
normal: {}
normal-hl:
style: bold
file-headers:
back-color: green
selected:
style: standout
tabstop: 8
editor: "vi"Example JSON file for the same config:
{
"colors": {
"line-numbers" : {
"fore-color": "blue"
},
"line-numbers-hl": {
"fore-color": "blue",
"style": "bold"
},
"normal": {},
"normal-hl": {
"style": "bold"
},
"file-headers": {
"back-color": "green"
},
"selected": {
"style": "standout"
}
},
"tabstop": 8,
"editor": "vi"
}The JSON/YAML keys correspond to the lenses in Vgrep.Environment.Config,
the values for Color and Style can be obtained from the
corresponding predefined constants in Graphics.Vty.Attributes.