Skip to content

Commit 336220c

Browse files
jtojnarjaspervdj
authored andcommitted
Add platform specific configuration paths
1 parent 51631e2 commit 336220c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

README.markdown

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ following order:
9595
settings)
9696
3. `.stylish-haskell.yaml` in the nearest ancestor directory (useful for
9797
per-project settings)
98-
4. `.stylish-haskell.yaml` in your home directory (useful for user-wide
98+
4. `stylish-haskell/config.yaml` in the platforms configuration directory
99+
(on Windows, it is %APPDATA%, elsewhere it defaults to `~/.config` and
100+
can be overridden by the `XDG_CONFIG_HOME` environment variable;
101+
useful for user-wide settings)
102+
5. `.stylish-haskell.yaml` in your home directory (useful for user-wide
99103
settings)
100-
5. The default settings.
104+
6. The default settings.
101105

102106
Use `stylish-haskell --defaults > .stylish-haskell.yaml` to dump a
103107
well-documented default configuration to a file, this way you can get started

lib/Language/Haskell/Stylish/Config.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ defaultConfigFilePath = getDataFileName "data/stylish-haskell.yaml"
7373
configFilePath :: Verbose -> Maybe FilePath -> IO FilePath
7474
configFilePath _ (Just userSpecified) = return userSpecified
7575
configFilePath verbose Nothing = do
76-
current <- getCurrentDirectory
77-
home <- getHomeDirectory
78-
def <- defaultConfigFilePath
79-
mbConfig <- search $
76+
current <- getCurrentDirectory
77+
configPath <- getXdgDirectory XdgConfig "stylish-haskell"
78+
home <- getHomeDirectory
79+
def <- defaultConfigFilePath
80+
mbConfig <- search $
8081
[d </> configFileName | d <- ancestors current] ++
81-
[home </> configFileName, def]
82+
[configPath </> "config.yaml", home </> configFileName, def]
8283

8384
case mbConfig of
8485
Just config -> return config

stylish-haskell.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Test-suite stylish-haskell-tests
125125
base >= 4.8 && < 5,
126126
bytestring >= 0.9 && < 0.11,
127127
containers >= 0.3 && < 0.6,
128-
directory >= 1.1 && < 1.4,
128+
directory >= 1.2.3 && < 1.4,
129129
filepath >= 1.1 && < 1.5,
130130
haskell-src-exts >= 1.18 && < 1.21,
131131
mtl >= 2.0 && < 2.3,

0 commit comments

Comments
 (0)