Replace FSwitch call with vimscript
This commit is contained in:
parent
82512f18df
commit
b842eb4a48
1 changed files with 25 additions and 8 deletions
|
@ -1,11 +1,28 @@
|
||||||
|
function s:getFileExtension(filename)
|
||||||
|
return fnamemodify(a:filename, ":e")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:getFileRoot(filename)
|
||||||
|
return fnamemodify(a:filename, ":r")
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function s:getSwitchExtension(extension)
|
||||||
|
if (a:extension == "cpp")
|
||||||
|
return "h"
|
||||||
|
elseif (a:extension == "h")
|
||||||
|
return "cpp"
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function s:getSwitchFile(filename)
|
||||||
|
return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(s:getFileExtension(a:filename))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
function s:addLeftSplit(filename)
|
||||||
|
execute("vsplit " . s:getSwitchFile(a:filename))
|
||||||
|
endfunc
|
||||||
|
|
||||||
function splitopen#SplitOpenFile(filename)
|
function splitopen#SplitOpenFile(filename)
|
||||||
execute("tabedit " . a:filename)
|
execute("tabedit " . a:filename)
|
||||||
let l:file_extension = tolower(fnamemodify(a:filename, ":e"))
|
call s:addLeftSplit(a:filename)
|
||||||
if l:file_extension == "cpp"
|
|
||||||
execute("FSSplitLeft")
|
|
||||||
execute("wincmd l")
|
|
||||||
elseif l:file_extension == "h"
|
|
||||||
execute("FSSplitRight")
|
|
||||||
execute("wincmd h")
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in a new issue