Skip to content

Commit c51f8af

Browse files
committed
Specify both Python 2 and Python 3
1 parent e786db0 commit c51f8af

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# VIntSearch
22

3-
*Currently, this plugin only supports the vim compiled with python 2 support (+python).*
4-
53
VIntSearch is a vim plugin providing an integrated interface across various types of searches. It currently supports symbol search, text search, and file search.
64
Search results are given in the quickfix window and a user can conviniently move forward / backward through the integrated search history.
75
VIntSearch means **V**im **Int**egrated **Search**.
@@ -39,8 +37,10 @@ VIntSearch means **V**im **Int**egrated **Search**.
3937
- Manual install (not recommended)
4038
- Download this plugin and extract it in `~/.vim/`
4139

42-
This plugin requires a version of vim with python support. You can check your vim with `:echo has('python')`.
43-
- Linux: If your vim doesn't support python, one of the easiest solutions would be installing a more featured version of vim by `sudo apt-get install vim-gtk-py2`.
40+
## Requirements
41+
42+
This plugin requires a version of vim with Python 2 (+python) or Python 3 (+python3) support. You can check your vim with `:echo has('python')` or `:echo has('python3')`.
43+
- Ubuntu: If your vim doesn't support python, one of the easiest solutions would be installing a more featured version of vim by `sudo apt-get install vim-gtk`.
4444
- Windows: gvim for Windows is already equipped with python support.
4545

4646
## Getting Started

autoload/VIntSearch.vim

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
" Author: yssl <http://github.com/yssl>
44
" License: MIT License
55

6+
" Support for Python3 and Python2
7+
" from https://github.com/Valloric/YouCompleteMe
8+
function! s:UsingPython3()
9+
if has('python3')
10+
return 1
11+
endif
12+
return 0
13+
endfunction
14+
let s:using_python3 = s:UsingPython3()
15+
let s:pythonX_until_EOF = s:using_python3 ? "python3 << EOF" : "python << EOF"
16+
617
" wrappers
718
function! VIntSearch#Cc(linenum, use_quickfix)
819
call s:Cc(a:linenum, a:use_quickfix)
@@ -384,14 +395,14 @@ function! s:ClearStack()
384395
endfunction
385396

386397
function! s:PrintStack()
387-
python << EOF
398+
exec s:pythonX_until_EOF
388399
import vim
389400
def ltrunc(s, width, prefix=''):
390-
if width >= len(s): prefix = ''
391-
return prefix+s[-width+len(prefix):]
401+
if width >= len(s): prefix = ''
402+
return prefix+s[-width+len(prefix):]
392403
def rtrunc(s, width, postfix=''):
393-
if width >= len(s): postfix = ''
394-
return s[:width-len(postfix)]+postfix
404+
if width >= len(s): postfix = ''
405+
return s[:width-len(postfix)]+postfix
395406
def toWidthColMat(rowMat):
396407
colMat = [[None]*len(rowMat) for c in range(len(rowMat[0]))]
397408
for r in range(len(rowMat)):
@@ -413,7 +424,7 @@ for i in range(len(searchstack)+1):
413424
ss = searchstack[i]
414425
propMat.append([mark, str(i+1), ss['keyword'], ss['type'],\
415426
ss['file'], ss['line'], \
416-
ss['text'].lstrip().replace('\t',' ')])
427+
ss['text'].lstrip().replace('\t',' ')])
417428
else:
418429
propMat.append([mark,'','','','','',''])
419430

@@ -614,7 +625,7 @@ function! s:GetRepoDirFrom(filepath)
614625
if a:filepath==#''
615626
return ''
616627
endif
617-
python << EOF
628+
exec s:pythonX_until_EOF
618629
repodirs = vim.eval('g:vintsearch_repodirs')
619630
filepath = vim.eval('a:filepath')
620631
dir = os.path.dirname(filepath)
@@ -626,7 +637,7 @@ while True:
626637
exist = True
627638
break
628639
if exist:
629-
break
640+
break
630641

631642
prevdir = dir
632643
dir = os.path.dirname(dir)
@@ -850,7 +861,7 @@ function! s:GetCtagsQFList(keyword)
850861
redir END
851862
let tags = []
852863

853-
python << EOF
864+
exec s:pythonX_until_EOF
854865
import vim
855866

856867
def splitTaglineByIndexes(tagline, indexes):

doc/VIntSearch.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,8 @@ VIntSearch means Vim Integrated Search.
4242
- Search keyword can be from a word under the cursor, visually selected text,
4343
or any string you type.
4444

45-
This plugin requires a version of vim with python support.
46-
You can check your vim with `:echo has('python')`.
47-
48-
- Linux: If your vim doesn't support python, one of the easiest solutions
49-
would be installing a more featured version of vim by `sudo apt-get install vim-gtk`.
50-
51-
- Windows: gvim for Windows is already equipped with python support.
45+
This plugin requires a version of vim with Python 2 (+python) or Python 3 (+python3)
46+
support. You can check your vim with `:echo has('python')` or `:echo has('python3')`.
5247

5348
==============================================================================
5449
2. Getting Started *VIntSearch-gettingstarted*

plugin/VIntSearch.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ set cpo&vim
1212

1313
"""""""""""""""""""""""""""""""""""""""""""""
1414

15+
" vim version checking
16+
if !has('python3') && !has('python')
17+
echohl WarningMsg
18+
echomsg 'VIntSearch unavailable: requires vim with Python support'
19+
echohl None
20+
finish
21+
endif
22+
1523
"" global variables
1624
if !exists('g:vintsearch_searchpathmode')
1725
" search path is the root dir of grep search path tree or the dir where tags

0 commit comments

Comments
 (0)