From: Hiroshi Shirosaki Date: Wed, 9 Dec 2015 06:47:02 +0000 (+0900) Subject: Merge pull request #235 from jirislaby/patch-1 X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/bd875ab511fafa4504f36852a42927ef9c0e1fd1?hp=4b86376013d55c0230bd1f0ac8278d08bb803715 Merge pull request #235 from jirislaby/patch-1 Makefile: support DESTDIR --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/.travis.yml b/.travis.yml index 130c2af..4a78b6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,22 +4,19 @@ env: - TEST=latest before_script: | - cd .. if [ "$TEST" = "package" ]; then sudo apt-get -y update sudo apt-get -y install vim else + cd .. git clone --depth 1 https://github.com/vim/vim cd vim ./configure --with-features=huge make sudo make install export PATH="/usr/local/bin:$PATH" - cd - + cd "$TRAVIS_BUILD_DIR" fi - git clone https://github.com/godlygeek/tabular - git clone https://github.com/junegunn/vader.vim script: | - cd "$TRAVIS_BUILD_DIR" - ./test/run-tests.sh + make test diff --git a/Makefile b/Makefile index 4b2ed8d..9260a52 100644 --- a/Makefile +++ b/Makefile @@ -15,3 +15,21 @@ install: cp -v after/ftplugin/markdown.vim ${ADDONS}/after/ftplugin/markdown.vim mkdir -pv ${REGISTRY} cp -v registry/markdown.yaml ${REGISTRY}/markdown.yaml + +test: build/tabular build/vader.vim + test/run-tests.sh +.PHONY: test + +update: build/tabular build/vader.vim + cd build/tabular && git pull + cd build/vader.vim && git pull +.PHONY: update + +build/tabular: | build + git clone https://github.com/godlygeek/tabular build/tabular + +build/vader.vim: | build + git clone https://github.com/junegunn/vader.vim build/vader.vim + +build: + mkdir build diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index adac473..a140c25 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -6,27 +6,37 @@ " " original version from Steve Losh's gist: https://gist.github.com/1038710 -func! Foldexpr_markdown(lnum) - if (a:lnum == 1) - let l0 = '' - else - let l0 = getline(a:lnum-1) - endif - - let l1 = getline(a:lnum) +func! s:is_mkdCode(lnum) + return synIDattr(synID(a:lnum, 1, 0), 'name') == 'mkdCode' +endfunc - let l2 = getline(a:lnum+1) +func! s:effective_line(lnum) + let line = getline(a:lnum) + return (line !~ '^[=-#]' || s:is_mkdCode(a:lnum)) ? '' : line +endfunc +func! Foldexpr_markdown(lnum) + let l2 = s:effective_line(a:lnum+1) if l2 =~ '^==\+\s*' " next line is underlined (level 1) return '>1' elseif l2 =~ '^--\+\s*' " next line is underlined (level 2) return '>2' - elseif l1 =~ '^#' + endif + + let l1 = s:effective_line(a:lnum) + if l1 =~ '^#' " don't include the section title in the fold return '-1' - elseif l0 =~ '^#' + endif + + if (a:lnum == 1) + let l0 = '' + else + let l0 = s:effective_line(a:lnum-1) + endif + if l0 =~ '^#' " current line starts with hashes return '>'.matchend(l0, '^#\+') else diff --git a/test/README.md b/test/README.md index 1817e55..a13d6d2 100644 --- a/test/README.md +++ b/test/README.md @@ -1,7 +1,5 @@ -To run the tests, you must install [Vader](https://github.com/junegunn/vader.vim). +You can run the tests using the Makefile from the top directory: -Vader and other plugins must be installed in the same directory as this repository. + make test -Run the tests with: - - ./run-tests.sh +To run them manually please refer to the instructions/commands in the Makefile. diff --git a/test/folding.vader b/test/folding.vader new file mode 100644 index 0000000..ee20975 --- /dev/null +++ b/test/folding.vader @@ -0,0 +1,38 @@ +Before: + source ../after/ftplugin/markdown.vim + +After: + setlocal foldexpr=0 + setlocal foldmethod=manual + +Given markdown; +# Title + +## Chapter 1 + +``` +This is code block +# This is just a comment +``` + +## Capter 2 + +foobar + +Execute (fold level # in code block): + AssertEqual foldlevel(1), 0, '# Title' + AssertEqual foldlevel(3), 1, '## Chapter 1' + AssertEqual foldlevel(7), 2, '# This is just a comment' + AssertEqual foldlevel(8), 2, '```' + AssertEqual foldlevel(10), 1, '## Chapter 2' + AssertEqual foldlevel(12), 2, 'foobar' + +Given markdown; + +==+ Fold Level 1 + +--+ Fold Level 2 + +Execute (fold level ==+, --+): + AssertEqual foldlevel(2), 1, '==+' + AssertEqual foldlevel(4), 2, '--+' diff --git a/test/run-tests.sh b/test/run-tests.sh index c8c6213..731b3ce 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -1,3 +1,16 @@ #!/usr/bin/env bash -cd "$( dirname "${BASH_SOURCE[0]}" )" && vim -Nu vimrc -c 'Vader! *' > /dev/null +# Exit on error. +set -e + +cd "$( dirname "${BASH_SOURCE[0]}" )" + +for dep in ../build/tabular ../build/vader.vim; do + if [[ ! -d $dep ]]; then + echo "Missing dependency: $dep" + echo "You may just want to use 'make test'." + exit 1 + fi +done + +vim -Nu vimrc -c 'Vader! *' > /dev/null diff --git a/test/vimrc b/test/vimrc index 44df1b6..59c6163 100644 --- a/test/vimrc +++ b/test/vimrc @@ -1,7 +1,7 @@ set nocompatible set rtp+=../ -set rtp+=../../tabular/ -set rtp+=../../vader.vim/ +set rtp+=../build/tabular/ +set rtp+=../build/vader.vim/ filetype on filetype plugin on filetype indent on