summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml14
-rw-r--r--Makefile33
-rw-r--r--autoload/deoplete/handler.vim10
-rw-r--r--autoload/deoplete/init.vim4
-rw-r--r--autoload/deoplete/util.vim10
-rw-r--r--rplugin/python3/deoplete/tests/test_filter.py41
-rw-r--r--rplugin/python3/deoplete/tests/test_util.py23
-rw-r--r--test/autoload/deoplete/util.vim (renamed from test/util.vim)0
-rw-r--r--test/conftest.py5
-rw-r--r--test/rplugin/python3/deoplete/test_filter.py34
-rw-r--r--test/rplugin/python3/deoplete/test_util.py19
11 files changed, 103 insertions, 90 deletions
diff --git a/.travis.yml b/.travis.yml
index 86acf30..a42f012 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,13 +8,11 @@ python:
- 3.5
install:
- - pip install neovim flake8 nose mock pytest mypy-lang
-
-before_script:
- - git clone https://github.com/syngan/vim-vimlint /tmp/vim-vimlint
- - git clone https://github.com/ynkdir/vim-vimlparser /tmp/vim-vimlparser
- - git clone https://github.com/thinca/vim-themis
+ # Install Neovim via Gist
+ # https://gist.github.com/lambdalisue/0f461f6a91743895394e63a9a1c65232
+ - curl -sL https://gist.githubusercontent.com/lambdalisue/0f461f6a91743895394e63a9a1c65232/raw/install_nvim_for_ci.sh | bash
+ - make install
script:
- - sh /tmp/vim-vimlint/bin/vimlint.sh -l /tmp/vim-vimlint -p /tmp/vim-vimlparser -e EVL103=1 -e EVL102.l:_=1 autoload
- - make test
+ - PATH="$HOME/neovim/bin:$PATH" make test
+ - make lint
diff --git a/Makefile b/Makefile
index d1f10df..8cf7129 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,32 @@
-test: vim-themis
- vim-themis/bin/themis --reporter spec test
- nosetests -v rplugin/python3
- flake8 rplugin/
+PATH := ./vim-themis/bin:$(PATH)
+export THEMIS_VIM := nvim
+export THEMIS_ARGS := -e -s --headless
+export THEMIS_HOME := ./vim-themis
+
+
+install: vim-themis
+ pip install neovim --upgrade
+ pip install pytest --upgrade
+ pip install flake8 --upgrade
+ pip install mypy-lang --upgrade
+ pip install vim-vint --upgrade
+
+lint:
+ vint --version
+ vint plugin
+ vint autoload
+ flake8 --version
+ flake8 rplugin/python3/deoplete
+ mypy --version
mypy --silent-imports rplugin/python3/deoplete
-# Use existing vim-themis install from ~/.vim, or clone it.
+test:
+ themis --version
+ themis test/autoload/*
+ pytest --version
+ pytest
+
vim-themis:
git clone https://github.com/thinca/vim-themis vim-themis; \
-.PHONY: test
+.PHONY: install lint test
diff --git a/autoload/deoplete/handler.vim b/autoload/deoplete/handler.vim
index 0435a4d..190b733 100644
--- a/autoload/deoplete/handler.vim
+++ b/autoload/deoplete/handler.vim
@@ -66,7 +66,7 @@ function! s:completion_begin(event) abort
\ 'b:deoplete_omni_patterns',
\ 'g:deoplete#omni_patterns',
\ 'g:deoplete#_omni_patterns'))
- if pattern != '' && &l:omnifunc != ''
+ if pattern !=# '' && &l:omnifunc !=# ''
\ && context.input =~# '\%('.pattern.'\)$'
call deoplete#mapping#_set_completeopt()
call feedkeys("\<C-x>\<C-o>", 'n')
@@ -92,7 +92,7 @@ function! s:is_skip(event, context) abort
if &paste
\ || mode() !=# 'i'
\ || (a:event !=# 'Manual' && disable_auto_complete)
- \ || (&l:completefunc != '' && &l:buftype =~# 'nofile')
+ \ || (&l:completefunc !=# '' && &l:buftype =~# 'nofile')
\ || (a:event ==# 'InsertEnter'
\ && has_key(g:deoplete#_context, 'position'))
return 1
@@ -103,7 +103,7 @@ function! s:is_skip(event, context) abort
let word = get(v:completed_item, 'word', '')
let delimiters = filter(copy(g:deoplete#delimiters),
\ 'strridx(word, v:val) == (len(word) - len(v:val))')
- if word == '' || empty(delimiters)
+ if word ==# '' || empty(delimiters)
return 1
endif
endif
@@ -127,7 +127,7 @@ function! s:is_skip_text(event) abort
\ 'b:deoplete_skip_chars', 'g:deoplete#skip_chars')
return (!pumvisible() && virtcol('.') != displaywidth)
- \ || (a:event !=# 'Manual' && input != ''
+ \ || (a:event !=# 'Manual' && input !=# ''
\ && index(skip_chars, input[-1:]) >= 0)
endfunction
@@ -145,7 +145,7 @@ function! s:on_insert_leave() abort
endfunction
function! s:complete_done() abort
- if get(v:completed_item, 'word', '') != ''
+ if get(v:completed_item, 'word', '') !=# ''
let word = v:completed_item.word
if !has_key(g:deoplete#_rank, word)
let g:deoplete#_rank[word] = 1
diff --git a/autoload/deoplete/init.vim b/autoload/deoplete/init.vim
index 956c1b4..f331aae 100644
--- a/autoload/deoplete/init.vim
+++ b/autoload/deoplete/init.vim
@@ -154,10 +154,10 @@ endfunction
function! deoplete#init#_context(event, sources) abort
let filetype = (exists('*context_filetype#get_filetype') ?
\ context_filetype#get_filetype() :
- \ (&filetype == '' ? 'nothing' : &filetype))
+ \ (&filetype ==# '' ? 'nothing' : &filetype))
let filetypes = exists('*context_filetype#get_filetypes') ?
\ context_filetype#get_filetypes() :
- \ &filetype == '' ? ['nothing'] :
+ \ &filetype ==# '' ? ['nothing'] :
\ deoplete#util#uniq([&filetype]
\ + split(&filetype, '\.'))
let same_filetypes = exists('*context_filetype#get_same_filetypes') ?
diff --git a/autoload/deoplete/util.vim b/autoload/deoplete/util.vim
index a209363..eb3f389 100644
--- a/autoload/deoplete/util.vim
+++ b/autoload/deoplete/util.vim
@@ -66,7 +66,7 @@ function! deoplete#util#get_input(event) abort
\ '^.*\%' . (mode ==# 'i' ? col('.') : col('.') - 1)
\ . 'c' . (mode ==# 'i' ? '' : '.'))
- if input =~ '^.\{-}\ze\S\+$'
+ if input =~# '^.\{-}\ze\S\+$'
let complete_str = matchstr(input, '\S\+$')
let input = matchstr(input, '^.\{-}\ze\S\+$')
else
@@ -96,14 +96,14 @@ function! s:vimoption2python(option) abort
let has_dash = 0
let patterns = []
for pattern in split(a:option, ',')
- if pattern == ''
+ if pattern ==# ''
" ,
call add(patterns, ',')
- elseif pattern == '\'
+ elseif pattern ==# '\'
call add(patterns, '\\')
- elseif pattern == '-'
+ elseif pattern ==# '-'
let has_dash = 1
- elseif pattern =~ '\d\+'
+ elseif pattern =~# '\d\+'
call add(patterns, substitute(pattern, '\d\+',
\ '\=nr2char(submatch(0))', 'g'))
else
diff --git a/rplugin/python3/deoplete/tests/test_filter.py b/rplugin/python3/deoplete/tests/test_filter.py
deleted file mode 100644
index 38c3dc2..0000000
--- a/rplugin/python3/deoplete/tests/test_filter.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from unittest import TestCase
-from nose.tools import eq_
-from deoplete.util import (
- fuzzy_escape, charwidth, strwidth, truncate, truncate_skipping)
-from deoplete.filter.converter_remove_overlap import overlap_length
-
-
-class FilterTestCase(TestCase):
-
- def test_fuzzy_escapse(self):
- eq_(fuzzy_escape('foo', 0), 'f[^f]*o[^o]*o[^o]*')
- eq_(fuzzy_escape('foo', 1), 'f[^f]*o[^o]*o[^o]*')
- eq_(fuzzy_escape('Foo', 1), 'F[^F]*[oO].*[oO].*')
-
- def test_overlap_length(self):
- eq_(overlap_length('foo bar', 'bar baz'), 3)
- eq_(overlap_length('foobar', 'barbaz'), 3)
- eq_(overlap_length('foob', 'baz'), 1)
- eq_(overlap_length('foobar', 'foobar'), 6)
- eq_(overlap_length('тест', 'ст'), len('ст'))
-
- def test_charwidth(self):
- eq_(charwidth('f'), 1)
- eq_(charwidth('あ'), 2)
-
- def test_strwidth(self):
- eq_(strwidth('foo bar'), 7)
- eq_(strwidth('あいうえ'), 8)
- eq_(strwidth('fooあい'), 7)
-
- def test_truncate(self):
- eq_(truncate('foo bar', 3), 'foo')
- eq_(truncate('fooあい', 5), 'fooあ')
- eq_(truncate('あいうえ', 4), 'あい')
- eq_(truncate('fooあい', 4), 'foo')
-
- def test_skipping(self):
- eq_(truncate_skipping('foo bar', 3, '..', 3), '..bar')
- eq_(truncate_skipping('foo bar', 6, '..', 3), 'f..bar')
- eq_(truncate_skipping('fooあい', 5, '..', 3), 'f..い')
- eq_(truncate_skipping('あいうえ', 6, '..', 2), 'あ..え')
diff --git a/rplugin/python3/deoplete/tests/test_util.py b/rplugin/python3/deoplete/tests/test_util.py
deleted file mode 100644
index 6cdd99e..0000000
--- a/rplugin/python3/deoplete/tests/test_util.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from unittest import TestCase
-from nose.tools import eq_
-from deoplete.util import (
- bytepos2charpos, charpos2bytepos, get_custom, globruntime)
-
-
-class UtilTestCase(TestCase):
-
- def test_pos(self):
- eq_(bytepos2charpos('utf-8', 'foo bar', 3), 3)
- eq_(bytepos2charpos('utf-8', 'あああ', 3), 1)
- eq_(charpos2bytepos('utf-8', 'foo bar', 3), 3)
- eq_(charpos2bytepos('utf-8', 'あああ', 3), 9)
-
- def test_custom(self):
- custom = {'_': {'mark': ''}, 'java': {'converters': []}}
- eq_(get_custom(custom, 'java', 'mark', 'foobar'), '')
- eq_(get_custom(custom, 'java', 'converters', 'foobar'), [])
- eq_(get_custom(custom, 'foo', 'mark', 'foobar'), '')
- eq_(get_custom(custom, 'foo', 'converters', 'foobar'), 'foobar')
-
- def test_globruntime(self):
- eq_(globruntime('/usr', 'bin'), ['/usr/bin'])
diff --git a/test/util.vim b/test/autoload/deoplete/util.vim
index e6ca889..e6ca889 100644
--- a/test/util.vim
+++ b/test/autoload/deoplete/util.vim
diff --git a/test/conftest.py b/test/conftest.py
new file mode 100644
index 0000000..83e2163
--- /dev/null
+++ b/test/conftest.py
@@ -0,0 +1,5 @@
+import os
+import sys
+
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+sys.path.insert(0, os.path.join(BASE_DIR, 'rplugin/python3'))
diff --git a/test/rplugin/python3/deoplete/test_filter.py b/test/rplugin/python3/deoplete/test_filter.py
new file mode 100644
index 0000000..3b3cda1
--- /dev/null
+++ b/test/rplugin/python3/deoplete/test_filter.py
@@ -0,0 +1,34 @@
+import deoplete.util as util
+
+def test_fuzzy_escapse(self):
+ assert fuzzy_escape('foo', 0) == 'f[^f]*o[^o]*o[^o]*'
+ assert fuzzy_escape('foo', 1) == 'f[^f]*o[^o]*o[^o]*'
+ assert fuzzy_escape('Foo', 1) == 'F[^F]*[oO].*[oO].*'
+
+def test_overlap_length(self):
+ assert overlap_length('foo bar', 'bar baz') == 3
+ assert overlap_length('foobar', 'barbaz') == 3
+ assert overlap_length('foob', 'baz') == 1
+ assert overlap_length('foobar', 'foobar') == 6
+ assert overlap_length('тест', 'ст') == len('ст')
+
+def test_charwidth(self):
+ assert charwidth('f') == 1
+ assert charwidth('あ') == 2
+
+def test_strwidth(self):
+ assert strwidth('foo bar') == 7
+ assert strwidth('あいうえ') == 8
+ assert strwidth('fooあい') == 7
+
+def test_truncate(self):
+ assert truncate('foo bar', 3) == 'foo'
+ assert truncate('fooあい', 5) == 'fooあ'
+ assert truncate('あいうえ', 4) == 'あい'
+ assert truncate('fooあい', 4) == 'foo'
+
+def test_skipping(self):
+ assert truncate_skipping('foo bar', 3, '..', 3) == '..bar'
+ assert truncate_skipping('foo bar', 6, '..', 3) == 'f..bar'
+ assert truncate_skipping('fooあい', 5, '..', 3) == 'f..い'
+ assert truncate_skipping('あいうえ', 6, '..', 2) == 'あ..え'
diff --git a/test/rplugin/python3/deoplete/test_util.py b/test/rplugin/python3/deoplete/test_util.py
new file mode 100644
index 0000000..7b48698
--- /dev/null
+++ b/test/rplugin/python3/deoplete/test_util.py
@@ -0,0 +1,19 @@
+import deoplete.util as util
+
+
+def test_pos():
+ assert util.bytepos2charpos('utf-8', 'foo bar', 3) == 3
+ assert util.bytepos2charpos('utf-8', 'あああ', 3) == 1
+ assert util.charpos2bytepos('utf-8', 'foo bar', 3) == 3
+ assert util.charpos2bytepos('utf-8', 'あああ', 3) == 9
+
+def test_custom(self):
+ custom = {'_': {'mark': ''}, 'java': {'converters': []}}
+ assert get_custom(custom, 'java', 'mark', 'foobar') == ''
+ assert get_custom(custom, 'java', 'converters', 'foobar') == []
+ assert get_custom(custom, 'foo', 'mark', 'foobar') == ''
+ assert get_custom(custom, 'foo', 'converters', 'foobar') == 'foobar'
+
+
+def test_globruntime(self):
+ assert globruntime('/usr', 'bin') == ['/usr/bin']