diff --git a/AUTHORS.txt b/AUTHORS.txt index 08ee74f..d7b6da5 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -34,6 +34,7 @@ Wouter Overmeire (@lodagro) Stephen J. Fuhry (@fuhrysteve) Sheng Yun (@ShengYun) Yann Thomas-Gérard (@inside) +Colin Su (@littleq0903) @something are github user names. diff --git a/README.rst b/README.rst index 080980f..cb0dcdb 100644 --- a/README.rst +++ b/README.rst @@ -106,6 +106,13 @@ put that in your ``.vimrc``: let g:jedi#use_tabs_not_buffers = 0 +If you are a person who likes to use VIM-splits, you might want to put this in your ``.vimrc``: + +.. code-block:: vim + + let g:jedi#use_splits_not_buffers = "left" + +This options could be "left", "right", "top" or "bottom". It will decide the direction where the split open. Jedi automatically starts the completion, if you type a dot, e.g. ``str.``, if you don't want this: diff --git a/autoload/jedi.vim b/autoload/jedi.vim index b4a4d16..201a8e3 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -221,6 +221,7 @@ endfor let s:settings = { \ 'use_tabs_not_buffers': 1, + \ 'use_splits_not_buffers': 1, \ 'auto_initialization': 1, \ 'auto_vim_configuration': 1, \ 'goto_assignments_command': "'g'", diff --git a/doc/jedi-vim.txt b/doc/jedi-vim.txt index bda82f3..20c1140 100644 --- a/doc/jedi-vim.txt +++ b/doc/jedi-vim.txt @@ -37,6 +37,7 @@ Contents *jedi-vim-contents* 6.7. use_tabs_not_buffers |g:jedi#use_tabs_not_buffers| 6.8. squelch_py_warning |g:jedi#squelch_py_warning| 6.9. completions_enable |g:jedi#completions_enable| + 6.10. use_splits_not_buffers |g:jedi#use_splits_not_buffers| 7. Testing |jedi-vim-testing| 8. Contributing |jedi-vim-contributing| 9. License |jedi-vim-license| @@ -394,6 +395,15 @@ YCM). Options: 0 or 1 Default: 1 +------------------------------------------------------------------------------ +6.10. `g:jedi#use_splits_not_buffers` *g:jedi#use_splits_not_buffers* + +If you want to open new split for "go to", you could set this option to the +direction which you want to open a split with. + +Options: top, left, right or bottom +Default: "" (not enabled by default) + ============================================================================== 7. Testing *jedi-vim-testing* diff --git a/jedi_vim.py b/jedi_vim.py index 1f1d056..35df53a 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -399,6 +399,18 @@ def new_buffer(path, options=''): # options are what you can to edit the edit options if vim_eval('g:jedi#use_tabs_not_buffers') == '1': _tabnew(path, options) + elif not vim_eval('g:jedi#use_splits_not_buffers') == '1': + user_split_option = vim_eval('g:jedi#use_splits_not_buffers') + split_options = { + 'top': 'topleft split', + 'left': 'topleft vsplit', + 'right': 'botright vsplit', + 'bottom': 'botright split' + } + if user_split_option not in split_options: + print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys())) + else: + vim_command(split_options[user_split_option] + " %s" % path) else: if vim_eval("!&hidden && &modified") == '1': if vim_eval("bufname('%')") is None: diff --git a/test/goto.vim b/test/goto.vim index 45acd81..6163093 100644 --- a/test/goto.vim +++ b/test/goto.vim @@ -67,6 +67,7 @@ describe 'goto_with_tabs' Expect line('.') == 1 Expect col('.') == 1 Expect tabpagenr('$') == 2 + Expect winnr('$') == 1 tabprevious Expect bufname('%') == '' end @@ -78,12 +79,14 @@ describe 'goto_with_tabs' Expect g:current_buffer_is_module('token') == 0 execute "normal \" Expect tabpagenr('$') == 2 + Expect winnr('$') == 1 Expect g:current_buffer_is_module('token') == 1 bd silent normal G$\d execute "normal j\" Expect tabpagenr('$') == 2 + Expect winnr('$') == 1 Expect g:current_buffer_is_module('tokenize') == 1 end end @@ -112,6 +115,7 @@ describe 'goto_with_buffers' set hidden call jedi#goto_assignments() Expect g:current_buffer_is_module('os') == 1 + Expect winnr('$') == 1 Expect tabpagenr('$') == 1 Expect line('.') == 1 Expect col('.') == 1 @@ -125,14 +129,48 @@ describe 'goto_with_buffers' Expect g:current_buffer_is_module('token') == 0 execute "normal \" Expect tabpagenr('$') == 1 + Expect winnr('$') == 1 Expect g:current_buffer_is_module('token') == 1 bd silent normal G$\d execute "normal j\" Expect tabpagenr('$') == 1 + Expect winnr('$') == 1 Expect g:current_buffer_is_module('tokenize') == 1 end end + + +describe 'goto_with_splits' + before + set filetype=python + let g:jedi#use_splits_not_buffers = 'left' + end + + after + bd! + bd! + end + + it 'follow_import' + put = ['import subprocess', 'subprocess'] + silent normal G\g + Expect getline('.') == 'import subprocess' + Expect line('.') == 2 + Expect col('.') == 8 + + silent normal G\d + Expect g:current_buffer_is_module('subprocess') == 1 + Expect line('.') == 1 + Expect col('.') == 1 + Expect winnr('$') == 2 + wincmd l + Expect bufname('%') == '' + end + +end + + " vim: et:ts=4:sw=4