From 711dc8275d334ab4690b0a8205ce6c06a9c20900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 23 Feb 2015 11:14:19 +0100 Subject: [PATCH] Local config: function to find a specific file Allows main configuration files to be overridden or suppressed by the local configuration. --- config-bits/09-local-config.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config-bits/09-local-config.vim b/config-bits/09-local-config.vim index 4c8e5d6..41b2081 100644 --- a/config-bits/09-local-config.vim +++ b/config-bits/09-local-config.vim @@ -32,6 +32,35 @@ function! GetVardataPath(name) return g:vim_vardata . "/" . a:name endfunction +" Find a configuration file, based on a path relative to the configuration +" directory and a name. +" +" 1/ If there is a local configuration, this will look for the file in the +" local configuration. If it exists, its full path will be returned. +" 2/ If there is a local configuration, this will look for a file named +" 'suppress.' at the same location; if the file is found, the +" function will return an empty string. +" 3/ If the file exists in the global configuration, its full path will be +" returned. +" 4/ An empty string will be returned. +function! GetConfigFilePath(base,name) + if exists( "g:vim_local_path" ) + let bd = g:vim_local_path . "/" . a:base + if filereadable( l:bd . "/" . a:name ) + return l:bd . "/" . a:name + endif + if filereadable( l:bd . "/suppress." . a:name ) + return "" + endif + endif + let f = g:vim_home . "/" . a:base . "/" . a:name + if filereadable( l:f ) + return l:f + endif + return '' +endfunction + + " We need signature handling abilities to continue if !exists( "g:vim_keys" ) finish