Simple local project vimrc

This commit is contained in:
Loic Nageleisen 2023-10-21 13:36:04 +02:00
parent 192da2c047
commit be657558e7
Signed by: lloeki
GPG key ID: D05DAEE6889F94C2

35
vimrc
View file

@ -309,4 +309,39 @@ function! UpdateTags()
endfunction endfunction
nnoremap <F8> :call UpdateTags()<CR> nnoremap <F8> :call UpdateTags()<CR>
" project local vim config
function! LocalInit()
let s:local_config_allowed = []
let s:local_config_allowed_file = expand('~/.vim/localvim')
if filereadable(s:local_config_allowed_file)
let s:local_config_allowed = readfile(s:local_config_allowed_file)
endif
let s:local_config_basename = '.local.vim'
let s:local_config_file = getcwd() . '/' . s:local_config_basename
if filereadable(s:local_config_file)
if index(s:local_config_allowed, s:local_config_file) < 0
echo "local config file disallowed: " . s:local_config_file
else
call LocalLoad()
endif
endif
endfunction
function! LocalLoad()
execute 'source' s:local_config_file
endfunction
function! LocalAllow()
call add(s:local_config_allowed, s:local_config_file)
call writefile(uniq(sort(s:local_config_allowed)), s:local_config_allowed_file)
call LocalLoad()
endfunction
call LocalInit()
command LocalAllow call LocalAllow()
" vim: ft=vim " vim: ft=vim