diff src/testdir/test_filetype.vim @ 32601:c659c4a5aae2 v9.0.1632

patch 9.0.1632: not all cabal config files are recognized Commit: https://github.com/vim/vim/commit/166cd7b801ebe4aa042a9bbd6007d1951800aaa9 Author: Marcin Szamotulski <coot@coot.me> 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 14 Jun 2023 21:00:03 +0200
parents 73e1207ec28d
children 2cd120c9daba
line wrap: on
line diff
--- 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<string>
+  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<list<string>>
@@ -95,7 +119,7 @@ def s:GetFilenameChecks(): dict<list<str
     bzr: ['bzr_log.any', 'bzr_log.file'],
     c: ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg'],
     cabal: ['file.cabal'],
-    cabalconfig: ['cabal.config'],
+    cabalconfig: ['cabal.config', expand("$HOME/.config/cabal/config")] + WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'),
     cabalproject: ['cabal.project', 'cabal.project.local'],
     cairo: ['file.cairo'],
     calendar: ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'],
@@ -229,10 +253,10 @@ def s:GetFilenameChecks(): dict<list<str
     gedcom: ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'],
     gemtext: ['file.gmi', 'file.gemini'],
     gift: ['file.gift'],
-    gitattributes: ['file.git/info/attributes', '.gitattributes', '/.config/git/attributes', '/etc/gitattributes', '/usr/local/etc/gitattributes', 'some.git/info/attributes'],
+    gitattributes: ['file.git/info/attributes', '.gitattributes', '/.config/git/attributes', '/etc/gitattributes', '/usr/local/etc/gitattributes', 'some.git/info/attributes'] + WhenConfigHome('$XDG_CONFIG_HOME/git/attributes'),
     gitcommit: ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG', 'NOTES_EDITMSG', 'EDIT_DESCRIPTION'],
-    gitconfig: ['file.git/config', 'file.git/config.worktree', 'file.git/worktrees/x/config.worktree', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/usr/local/etc/gitconfig', '/etc/gitconfig.d/file', 'any/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'],
-    gitignore: ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'],
+    gitconfig: ['file.git/config', 'file.git/config.worktree', 'file.git/worktrees/x/config.worktree', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/usr/local/etc/gitconfig', '/etc/gitconfig.d/file', 'any/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'] + WhenConfigHome('$XDG_CONFIG_HOME/git/config'),
+    gitignore: ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'] + WhenConfigHome('$XDG_CONFIG_HOME/git/ignore'),
     gitolite: ['gitolite.conf', '/gitolite-admin/conf/file', 'any/gitolite-admin/conf/file'],
     gitrebase: ['git-rebase-todo'],
     gitsendemail: ['.gitsendemail.msg.xxxxxx'],
@@ -807,6 +831,12 @@ def s:CheckItems(checks: dict<list<strin
 enddef
 
 def Test_filetype_detection()
+  SetupConfigHome()
+  if !empty(s:saveConfigHome)
+    defer setenv("XDG_CONFIG_HOME", s:saveConfigHome)
+  endif
+  mkdir(GetConfigHome(), 'R')
+
   filetype on
   CheckItems(s:GetFilenameChecks())
   if has('fname_case')