Merge pull request #191 from littleq0903/goto_split_support

added split support for goto action
This commit is contained in:
David Halter
2013-09-14 12:19:28 -07:00
6 changed files with 69 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ ethinx (@ethinx) <eth2net@gmail.com>
Wouter Overmeire (@lodagro) <lodagro@gmail.com>
Stephen J. Fuhry (@fuhrysteve) <fuhrysteve@gmail.com>
Sheng Yun (@ShengYun) <uewing@gmail.com>
Colin Su (@littleq0903) <littleq0903@gmail.com>
@something are github user names.

View File

@@ -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:

View File

@@ -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': "'<leader>g'",

View File

@@ -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*

View File

@@ -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:

View File

@@ -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 \<CR>"
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
Expect g:current_buffer_is_module('token') == 1
bd
silent normal G$\d
execute "normal j\<CR>"
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 \<CR>"
Expect tabpagenr('$') == 1
Expect winnr('$') == 1
Expect g:current_buffer_is_module('token') == 1
bd
silent normal G$\d
execute "normal j\<CR>"
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