vgrep-0.2.3.0: A pager for grep
Safe HaskellNone
LanguageHaskell2010

Vgrep.Environment.Config.Sources

Synopsis

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.json or
  • ~/.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.defaultConfig
True

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.