blob: 9c6005527c52c37e37dfec52704be5bd79fc98e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
" Allows per-project configuration of keybindings.
" For example, '*.cpp <F5> make' will run make on F5 button push
" if .cpp file was opened
let s:commandFormat="au BufReadPost,BufNewFile %s map %s :!%s<CR>"
" Files that plugin searches on startup (relative to pwd)
let s:allowedConfigPaths=[".vim/config", ".vim.conf", "vim.conf"]
function! s:createCommand(line)
let line=split(a:line)
return printf(s:commandFormat, line[0], line[1], join(line[2:]))
endfunction
function! s:parseFile(filename)
let commands=[]
for line in readfile(a:filename)
let commands=commands + [s:createCommand(line)]
endfor
return commands
endfunction
function! s:getConfigs()
let commands=[]
for filename in s:allowedConfigPaths
if filereadable(filename)
let commands=commands + s:parseFile(filename)
endif
endfor
return commands
endfunction
function! s:applyConfig(config)
for line in a:config
execute line
endfor
endfunction
function! projector#init()
let config=s:getConfigs()
call s:applyConfig(config)
endfunction
|