Replace FSwitch call with vimscript

This commit is contained in:
mandlm 2019-10-20 13:55:10 +02:00
parent 82512f18df
commit b842eb4a48

View File

@ -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)
execute("tabedit " . a:filename)
let l:file_extension = tolower(fnamemodify(a:filename, ":e"))
if l:file_extension == "cpp"
execute("FSSplitLeft")
execute("wincmd l")
elseif l:file_extension == "h"
execute("FSSplitRight")
execute("wincmd h")
endif
call s:addLeftSplit(a:filename)
endfunction