From f873e9e9792806956b8bf93eceacb0af118bf87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 23 Feb 2015 18:18:09 +0100 Subject: [PATCH] Local config: load merged lists of config files GetConfigFiles function can be used to generate a list of files, merged from both the main configuration directory and the local configuration directory. The local configuration directory is also able to suppress files from the main configuration if necessary. --- config-bits/09-local-config.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config-bits/09-local-config.vim b/config-bits/09-local-config.vim index 41b2081..7e201ce 100644 --- a/config-bits/09-local-config.vim +++ b/config-bits/09-local-config.vim @@ -60,6 +60,30 @@ function! GetConfigFilePath(base,name) return '' endfunction +" List files in a configuration directory, letting the local configuration +" override the main configuration. The files are returned as a dictionary; +" keys are the files' basenames, while values are the full paths. +function! GetConfigFiles(base,pattern) + let fd = {} + " Get main configuration files + for mcf in glob( g:vim_home . "/" . a:base . "/" . a:pattern , 1 , 1 ) + let l:fd[ fnamemodify( l:mcf , ":t" ) ] = l:mcf + endfor + " Exit if there's no local configuration + if !exists( "g:vim_local_path" ) + return l:fd + endif + " Handle suppressions + for lsf in glob( g:vim_local_path . "/" . a:base . "/suppress." . a:pattern , 1 , 1 ) + unlet! l:fd[ fnamemodify( l:lsf , ":t" )[ 9 : -1 ] ] + endfor + " Handle local files + for lcf in glob( g:vim_local_path . "/" . a:base . "/" . a:pattern , 1 , 1 ) + let l:fd[ fnamemodify( l:lcf , ":t" ) ] = l:lcf + endfor + return l:fd +endfunction + " We need signature handling abilities to continue if !exists( "g:vim_keys" )