diff --git a/.travis.yml b/.travis.yml index a956fe8..405d54c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,17 @@ language: viml script: ./other/travis.sh +cache: + apt: true + directories: + - other/tmp +before_install: + - sudo apt-get -qq install software-properties-common + - sudo add-apt-repository -y ppa:neovim-ppa/unstable + - sudo apt-get -qq update + - sudo apt-get -qq install neovim + - sudo apt-get -qq install tree + - sudo apt-get -qq install python-dev python-pip python3-dev python3-pip + - sudo pip install pytest + - sudo pip install neovim + # - sudo apt-get -qq install nim + # - sudo apt-get -qq install nimble diff --git a/ftdetect/nim.vim b/ftdetect/nim.vim index 89e5925..632501e 100644 --- a/ftdetect/nim.vim +++ b/ftdetect/nim.vim @@ -2,6 +2,3 @@ if exists("s:loaded") finish endif let s:loaded = 1 - -au BufNewFile,BufRead *.nim set filetype=nim -au BufNewFile,BufRead *.nims set filetype=nims diff --git a/other/nvimcfg/init.vim b/other/nvimcfg/init.vim new file mode 100644 index 0000000..6930d46 --- /dev/null +++ b/other/nvimcfg/init.vim @@ -0,0 +1,17 @@ +if has('nvim') + runtime! plugin/python_setup.vim +endif + +call plug#begin('$HOME/.config/nvim/plugged') +Plug 'baabelfish/nvim-nim' +call plug#end() + +filetype plugin indent on + +if has("multi_byte") && has("starting") + if &termencoding == "" + let &termencoding = &encoding + endif + setglobal fileencoding=utf-8 + scriptencoding utf-8 +endif diff --git a/other/run_tests.sh b/other/run_tests.sh new file mode 100755 index 0000000..9b17312 --- /dev/null +++ b/other/run_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash +export NVIM_LISTEN_ADDRESS="/tmp/nvim" +nvim --headless& +nvimpid=$! +sleep 2 +sh -c "py.test -v tests/vim/**.py" +haderr=$? +sleep 1 +kill $nvimpid +wait +exit $haderr diff --git a/other/tests/vim/smoke.py b/other/tests/vim/smoke.py new file mode 100644 index 0000000..e8d810d --- /dev/null +++ b/other/tests/vim/smoke.py @@ -0,0 +1,24 @@ +from vimtest import cleanup, startNvim +from time import sleep + +nvim = startNvim() + + +def test_buffer(): + cleanup(nvim) + nvim.command("norm ihello world") + assert nvim.current.buffer[:] == ["hello world"] + + +def test_another(): + cleanup(nvim) + nvim.command("norm ihello world") + nvim.command("norm ggdG") + assert nvim.current.buffer[:] == [''] + + +def test_plugin_loading(): + cleanup(nvim) + nvim.command("e testi.nim") + assert nvim.eval("&ft") == "nim" + assert nvim.eval('exists(":NimUsages")') == 2 diff --git a/other/tests/vim/vimtest.py b/other/tests/vim/vimtest.py new file mode 100644 index 0000000..030890c --- /dev/null +++ b/other/tests/vim/vimtest.py @@ -0,0 +1,12 @@ +from neovim import attach + + +def cleanup(nvim): + nvim.command('bd!') + + +def startNvim(): + nvim = attach("socket", path="/tmp/nvim") + nvim.command("PlugInstall") + cleanup(nvim) + return nvim diff --git a/other/travis.sh b/other/travis.sh index 1193cb0..5b7e6de 100755 --- a/other/travis.sh +++ b/other/travis.sh @@ -2,6 +2,7 @@ current=$PWD + install_nim() { wget "http://nim-lang.org/download/nim-0.13.0.tar.xz" -O nim.tar.xz mkdir nim @@ -29,22 +30,32 @@ install_nimsuggest() { cd .. } -mkdir tmp -cd tmp -echo "Installing nim" -install_nim +if [[ ! -d "tmp" ]]; then + mkdir tmp + cd tmp -echo "Installing nimble" -install_nimble + echo "Installing nim" + install_nim -echo "Installing nimsuggest" -install_nimsuggest + echo "Installing nimble" + install_nimble -cd .. + echo "Installing nimsuggest" + install_nimsuggest + + cd .. +fi + +export PATH=$PATH:$current/tmp/nim/bin +export PATH=$PATH:$current/nimble/src +export PATH=$PATH:$current/nimble/nimsuggest echo "================================================================================" +echo -e "\nNeovim:" +nvim --version + echo -e "\nNim:" nim --version @@ -55,8 +66,21 @@ echo -e "\nNimsuggest:" nimsuggest --version echo "================================================================================" - -echo "Run tests in $PWD" cd $current/other -nim c tests/nimsuggest/suggestions.nim -nim c tests/edb/edb.nim + +curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +cp nvimcfg/init.vim ~/.config/nvim/ +mkdir -p "$HOME/.config/nvim/undodir" +mkdir -p "$HOME/.config/nvim/autoload" +mkdir -p "$HOME/.config/nvim/view" +cat ~/.config/nvim/autoload/plug.vim + +tree ~/.config/nvim + + +# echo "Run nim tests" +# nim c tests/nimsuggest/suggestions.nim + +echo "================================================================================" +echo "Run vim tests" +./run_tests.sh diff --git a/plugin/nim.vim b/plugin/nim.vim index 595e065..146720f 100644 --- a/plugin/nim.vim +++ b/plugin/nim.vim @@ -47,3 +47,6 @@ let g:nvim_nim_repl_height = 14 let g:nvim_nim_repl_vsplit = 0 let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"] + +au BufNewFile,BufRead *.nim setlocal filetype=nim +au BufNewFile,BufRead *.nims setlocal filetype=nims