Compare commits

...

25 Commits

Author SHA1 Message Date
changeme
21a5d0b3c1 Merge branch 'hotfix/typo' 2020-06-29 21:30:54 +02:00
changeme
045ccdfa9f Fixed a typo 2020-06-29 21:30:19 +02:00
changeme
83005361b6 Merge branch 'release/v1.1.0' 2020-06-29 21:28:12 +02:00
changeme
722e2da2f2 Added release documentation 2020-06-29 21:28:07 +02:00
Michael Mandl
97d53cf45c Added new Split() command to split an existing tab 2019-10-30 22:40:30 +01:00
Michael Mandl
4896a7c3cd Merge branch 'master' into develop 2019-10-30 22:22:15 +01:00
Michael Mandl
a7097e7cb8 Merge branch 'release/v1' 2019-10-30 22:22:13 +01:00
Michael Mandl
d12fde2ddc Updated release notes 2019-10-30 22:21:59 +01:00
7c6d4779f6 Overwrite exported command and function, used endfunction instead of endfunc 2019-10-22 19:01:14 +02:00
15aa4bf864 Merge tag 'configure-filetypes' into develop
v0.0.4
2019-10-20 15:54:43 +02:00
f4b4dfe38d Merge branch 'release/configure-filetypes' 2019-10-20 15:54:28 +02:00
d91bb228a7 Added release notes 2019-10-20 15:53:29 +02:00
84cd6e1661 Merge branch 'feature/filetype-dict' into develop 2019-10-20 15:50:57 +02:00
a6f8b0fda5 Formatting 2019-10-20 15:48:05 +02:00
b6b1377f93 Added documentation for g:splitopen_extensions 2019-10-20 15:45:53 +02:00
cd2d198447 Define left- and right-hand filetypes via global config variable 2019-10-20 15:39:32 +02:00
b842eb4a48 Replace FSwitch call with vimscript 2019-10-20 13:55:10 +02:00
82512f18df Merge tag 'v0.0.3' into develop
v0.0.3
2019-10-18 21:08:36 +02:00
8d7e9ca868 Merge branch 'release/v0.0.3' 2019-10-18 21:08:29 +02:00
657fc628d5 Updated changelog 2019-10-18 21:05:08 +02:00
b551e9965a Merge branch 'feature/extend-fzf-keys' into develop 2019-10-18 21:02:50 +02:00
a2736f4579 Added config option g:splitopen_set_fzf_keys to enable fzf keybinding.
Disabled by default.
2019-10-18 20:57:12 +02:00
c170d0779f Set fzf.vim keybinding (dangerous) 2019-10-18 20:53:42 +02:00
48cdd5b9d7 Updated readme from doc 2019-10-18 20:21:43 +02:00
55cb28c7e0 Merge tag 'v0.0.2' into develop
v0.0.2
2019-10-18 14:55:30 +02:00
4 changed files with 205 additions and 18 deletions

View File

@ -1,3 +1,68 @@
# vim-split-open
# SplitOpen
This is my first vim plugin. It provides a command to open a combination of c++ source and header file in a new tab split side-by-side.
This vim plugin opens file-pairs in a new split-window tab
## Usage
Use
:SplitOpen filename
with a .cpp or .h file as filename to open a new tab containing a vertical split
with the corresponding header file in the left window and the corresponding
source file in the right window.
Use
:Split
to open the corresponding header or source file to your currently open file in
a vertical split.
## Configuration
You can configure the following settings:
### g:splitopen_extensions
Use this dictionary to define your pairs of left-hand- right-hand-side file
types. E.g.
let g:splitopen_extensions = {"h": "cpp"}
always places a .cpp file on the right-hand side when opening an .h file and
vice versa.
### g:splitopen_set_fzf_keys
Set this option to 1
let g:splitopen_set_fzf_keys = 1
to have SplitOpen overwrite the default fzf keybindings ctrl-t/x/v for opening
files in splits or tabs to add an addional binding ctrl-s to call SplitOpen.
## License
SplitOpen is GPL-3.0 licensed. See LICENSE file for more info.
## Changelog
v1.1.0
* Added Split() command
v1.0.0
* Fixed error when reloading plugin
v0.0.4
* Add filetype configuraton
v0.0.3
* Add fzf.vim keybinding
v0.0.2
* Added delay-loading
* Added documentation
v0.0.1
* Initial release

View File

@ -1,11 +1,68 @@
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")
function s:invert_dict(source_dict)
let result = {}
for [key, value] in items(a:source_dict)
let result[value] = key
endfor
return result
endfunction
let s:extensions = g:splitopen_extensions
let s:extensions_rev = s:invert_dict(s:extensions)
function s:isLeftSideExtension(extension)
return has_key(s:extensions, a:extension)
endfunction
function s:isRightSideExtension(extension)
return has_key(s:extensions_rev, a:extension)
endfunction
function s:getFileExtension(filename)
return fnamemodify(a:filename, ":e")
endfunction
function s:getFileRoot(filename)
return fnamemodify(a:filename, ":r")
endfunction
function s:getSwitchExtension(filename)
let extension = s:getFileExtension(a:filename)
if s:isLeftSideExtension(extension)
return s:extensions[extension]
elseif s:isRightSideExtension(extension)
return s:extensions_rev[extension]
endif
endfunction
function s:getSwitchFile(filename)
return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(a:filename)
endfunction
function s:addLeftSplit(filename)
execute("vsplit " . s:getSwitchFile(a:filename))
execute("wincmd l")
endfunction
function s:addRightSplit(filename)
execute("vsplit " . s:getSwitchFile(a:filename))
execute("wincmd L")
execute("wincmd h")
endfunction
function s:splitOpenFile(filename)
let extension = s:getFileExtension(a:filename)
if s:isLeftSideExtension(extension)
call s:addRightSplit(a:filename)
elseif s:isRightSideExtension(extension)
call s:addLeftSplit(a:filename)
endif
endfunction
function! splitopen#SplitOpenFile(filename)
execute("tabedit " . a:filename)
call s:splitOpenFile(a:filename)
endfunction
function! splitopen#SplitFile()
call s:splitOpenFile(expand("%:p"))
endfunction

View File

@ -3,9 +3,12 @@
================================================================================
CONTENTS *SplitOpenContents*
1. Usage ..................................|SplitOpenUsage|
2. License ................................|SplitOpenLicense|
3. Changelog ..............................|SplitOpenChangelog|
1. Usage ..............................|SplitOpenUsage|
2. Configuration ......................|SlitOpenConfiguraton|
2.1 g:splitopen_extensions.........|SplitOpenConfiguration_extensions|
2.2 g:splitopen_set_fzf_keys.......|SplitOpenConfiguration_set_fzf_keys|
3. License ............................|SplitOpenLicense|
4. Changelog ..........................|SplitOpenChangelog|
================================================================================
1. Usage *SplitOpenUsage*
@ -18,17 +21,57 @@ with a .cpp or .h file as filename to open a new tab containing a vertical split
with the corresponding header file in the left window and the corresponding
source file in the right window.
Use
:Split
to open the corresponding header or source file to your currently open file in
a vertical split.
================================================================================
2. License *SplitOpenLicense*
2. Configuration *SplitOpenConfiguration*
You can configure the following settings:
--------------------------------------------------------------------------------
2.1 g:splitopen_extensions *SplitOpenConfiguration_extensions*
Use this dictionary to define your pairs of left-hand- right-hand-side file
types. E.g.
let g:splitopen_extensions = {"h": "cpp"}
always places a .cpp file on the right-hand side when opening an .h file and
vice versa.
--------------------------------------------------------------------------------
2.2 g:splitopen_set_fzf_keys *SplitOpenConfiguration_set_fzf_keys*
Set this option to 1
let g:splitopen_set_fzf_keys = 1
to have SplitOpen overwrite the default fzf keybindings ctrl-t/x/v for opening
files in splits or tabs to add an addional binding ctrl-s to call SplitOpen.
================================================================================
3. License *SplitOpenLicense*
SplitOpen is GPL-3.0 licensed. See LICENSE file for more info.
================================================================================
3. Changelog *SplitOpenChangelog*
4. Changelog *SplitOpenChangelog*
v1.1.0
* Added Split() command
v1.0.0
* Fixed error when reloading plugin
v0.0.4
* Add filetype configuraton
v0.0.3
* Add fzf.vim keybinding
v0.0.2
* Added delay-loading
* Added documentation
v0.0.1
* Initial release

View File

@ -1 +1,23 @@
command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("<args>")
command! -nargs=1 SplitOpen :call splitopen#SplitOpenFile("<args>")
command! Split :call splitopen#SplitFile()
" map left-split / right-split file extensions
if !exists("g:splitopen_extensions")
let g:splitopen_extensions = {
\ "h": "cpp",
\ "H": "CPP",
\ }
endif
if !exists('g:splitopen_set_fzf_keys')
let g:splitopen_set_fzf_keys = 0
endif
if g:splitopen_set_fzf_keys
let g:fzf_action = {
\ 'ctrl-s': 'SplitOpen',
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit',
\ }
endif