# HG changeset patch # User Bram Moolenaar # Date 1686769203 -7200 # Node ID c659c4a5aae2098273a088b728386aefed515dee # Parent d588202c7c37fa5de6123c4b1ea24dbba1ed3b3b patch 9.0.1632: not all cabal config files are recognized Commit: https://github.com/vim/vim/commit/166cd7b801ebe4aa042a9bbd6007d1951800aaa9 Author: Marcin Szamotulski Date: Wed Jun 14 19:45:43 2023 +0100 patch 9.0.1632: not all cabal config files are recognized Problem: Not all cabal config files are recognized. Solution: Add a couple of patterns. (Marcin Szamotulski, closes https://github.com/vim/vim/issues/12463) diff --git a/runtime/filetype.vim b/runtime/filetype.vim --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -784,7 +784,7 @@ au BufNewFile,BufRead */.config/git/conf au BufNewFile,BufRead *.git/config.worktree setf gitconfig au BufNewFile,BufRead *.git/worktrees/*/config.worktree setf gitconfig au BufNewFile,BufRead .gitmodules,*.git/modules/*/config setf gitconfig -if !empty($XDG_CONFIG_HOME) +if exists('$XDG_CONFIG_HOME') au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig au BufNewFile,BufRead $XDG_CONFIG_HOME/git/attributes setf gitattributes au BufNewFile,BufRead $XDG_CONFIG_HOME/git/ignore setf gitignore @@ -886,6 +886,10 @@ au BufNewFile,BufRead *.lhs setf lhask au BufNewFile,BufRead *.chs setf chaskell au BufNewFile,BufRead cabal.project setf cabalproject au BufNewFile,BufRead $HOME/.cabal/config setf cabalconfig +if exists('$XDG_CONFIG_HOME') + au BufNewFile,BufRead $XDG_CONFIG_HOME/cabal/config setf cabalconfig +endif +au BufNewFile,BufRead $HOME/.config/cabal/config setf cabalconfig au BufNewFile,BufRead cabal.config setf cabalconfig " Haste diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -40,6 +40,30 @@ func Test_other_type() filetype off endfunc +" If $XDG_CONFIG_HOME is set return "fname" expanded in a list. +" Otherwise return an empty list. +def s:WhenConfigHome(fname: string): list + if exists('$XDG_CONFIG_HOME') + return [expand(fname)] + endif + return [] +enddef + +" Return the name used for the $XDG_CONFIG_HOME directory. +def s:GetConfigHome(): string + return getcwd() .. '/Xdg_config_home' +enddef + +" saved value of $XDG_CONFIG_HOME +let s:saveConfigHome = '' + +def s:SetupConfigHome() + if empty(windowsversion()) + s:saveConfigHome = $XDG_CONFIG_HOME + setenv("XDG_CONFIG_HOME", GetConfigHome()) + endif +enddef + " Filetypes detected just from matching the file name. " First one is checking that these files have no filetype. def s:GetFilenameChecks(): dict> @@ -95,7 +119,7 @@ def s:GetFilenameChecks(): dict