summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2017-12-26 13:54:48 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2017-12-26 13:54:48 +0100
commit336220ca9f3e1ab9091651d60a9491386f77b7ed (patch)
tree974dba6f3cd080ce8404a8738f9af757e70549c8
parent51631e2d2d5b6b83f84917f36477dd79c3457ea2 (diff)
downloadstylish-haskell-336220ca9f3e1ab9091651d60a9491386f77b7ed.tar.gz
Add platform specific configuration paths
-rw-r--r--README.markdown8
-rw-r--r--lib/Language/Haskell/Stylish/Config.hs11
-rw-r--r--stylish-haskell.cabal2
3 files changed, 13 insertions, 8 deletions
diff --git a/README.markdown b/README.markdown
index 4ee7679..9ff46d7 100644
--- a/README.markdown
+++ b/README.markdown
@@ -95,9 +95,13 @@ following order:
settings)
3. `.stylish-haskell.yaml` in the nearest ancestor directory (useful for
per-project settings)
-4. `.stylish-haskell.yaml` in your home directory (useful for user-wide
+4. `stylish-haskell/config.yaml` in the platform’s configuration directory
+ (on Windows, it is %APPDATA%, elsewhere it defaults to `~/.config` and
+ can be overridden by the `XDG_CONFIG_HOME` environment variable;
+ useful for user-wide settings)
+5. `.stylish-haskell.yaml` in your home directory (useful for user-wide
settings)
-5. The default settings.
+6. The default settings.
Use `stylish-haskell --defaults > .stylish-haskell.yaml` to dump a
well-documented default configuration to a file, this way you can get started
diff --git a/lib/Language/Haskell/Stylish/Config.hs b/lib/Language/Haskell/Stylish/Config.hs
index 9fddbb5..8952790 100644
--- a/lib/Language/Haskell/Stylish/Config.hs
+++ b/lib/Language/Haskell/Stylish/Config.hs
@@ -73,12 +73,13 @@ defaultConfigFilePath = getDataFileName "data/stylish-haskell.yaml"
configFilePath :: Verbose -> Maybe FilePath -> IO FilePath
configFilePath _ (Just userSpecified) = return userSpecified
configFilePath verbose Nothing = do
- current <- getCurrentDirectory
- home <- getHomeDirectory
- def <- defaultConfigFilePath
- mbConfig <- search $
+ current <- getCurrentDirectory
+ configPath <- getXdgDirectory XdgConfig "stylish-haskell"
+ home <- getHomeDirectory
+ def <- defaultConfigFilePath
+ mbConfig <- search $
[d </> configFileName | d <- ancestors current] ++
- [home </> configFileName, def]
+ [configPath </> "config.yaml", home </> configFileName, def]
case mbConfig of
Just config -> return config
diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal
index a1716ef..4938334 100644
--- a/stylish-haskell.cabal
+++ b/stylish-haskell.cabal
@@ -125,7 +125,7 @@ Test-suite stylish-haskell-tests
base >= 4.8 && < 5,
bytestring >= 0.9 && < 0.11,
containers >= 0.3 && < 0.6,
- directory >= 1.1 && < 1.4,
+ directory >= 1.2.3 && < 1.4,
filepath >= 1.1 && < 1.5,
haskell-src-exts >= 1.18 && < 1.21,
mtl >= 2.0 && < 2.3,