diff options
51 files changed, 872 insertions, 434 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a6a9accea..93e153be53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,9 @@ endif() # Point CMake at any custom modules we may ship list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +# We don't support building in-tree. +include(PreventInTreeBuilds) + # Prefer our bundled versions of dependencies. set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies") if(CMAKE_CROSSCOMPILING AND NOT UNIX) @@ -13,6 +13,10 @@ CLINT_ERRORS_FILE_PATH := /reports/clint/errors.json BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \ echo "Unix Makefiles") +ifneq (,$(PREFIX)) + CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX:PATH="$(PREFIX)" +endif + ifeq (,$(BUILD_TOOL)) ifeq (Ninja,$(BUILD_TYPE)) ifneq ($(shell cmake --help 2>/dev/null | grep Ninja),) @@ -1,20 +1,24 @@ - +[](https://neovim.io) -[Website] | [Community] | [Wiki] | [Documentation] | [Mailing List] | [Twitter] | [Bountysource] +[Wiki](https://github.com/neovim/neovim/wiki) | +[Documentation](https://neovim.io/doc) | +[Twitter](https://twitter.com/Neovim) | +[Community](https://neovim.io/community/) | +[Gitter **Chat**](https://gitter.im/neovim/neovim) [](https://travis-ci.org/neovim/neovim) [](https://ci.appveyor.com/project/neovim/neovim/branch/master) [](https://waffle.io/neovim/neovim) [](https://coveralls.io/r/neovim/neovim) [](https://scan.coverity.com/projects/2227) -[](http://neovim.io/doc/reports/clang) -[](https://gitter.im/neovim/neovim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[](https://neovim.io/doc/reports/clang) +<a href="https://buildd.debian.org/neovim"><img src="https://www.debian.org/logos/openlogo-nd-25.png" width="13" height="15">Debian</a> Neovim is a project that seeks to aggressively refactor Vim in order to: - Simplify maintenance and encourage [contributions](CONTRIBUTING.md) - Split the work between multiple developers -- Enable the implementation of new/modern UIs without modifications to the core +- Enable advanced [external UIs] without modifications to the core - Improve extensibility with a new [plugin architecture](https://github.com/neovim/neovim/wiki/Plugin-UI-architecture) For more details, see @@ -45,7 +49,7 @@ See the [Roadmap]. How do I get it? ---------------- -There is a formula for OSX/homebrew, a PKGBUILD for Arch Linux, RPM, deb, and +There is a Debian package, homebrew formula, PKGBUILD for Arch Linux, RPM, and more. See [the wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim)! License @@ -74,15 +78,9 @@ See `LICENSE` for details. You can also sponsor the development of Vim. Vim sponsors can vote for features. The money goes to Uganda anyway. -[Website]: http://neovim.io -[Community]: http://neovim.io/community/ -[Wiki]: https://github.com/neovim/neovim/wiki -[Documentation]: http://neovim.io/doc -[Mailing List]: https://groups.google.com/forum/#!forum/neovim -[Twitter]: http://twitter.com/Neovim -[Bountysource]: https://www.bountysource.com/teams/neovim [license-commit]: https://github.com/neovim/neovim/commit/b17d9691a24099c9210289f16afb1a498a89d803 [nvim-features]: https://neovim.io/doc/user/vim_diff.html#nvim-features [Roadmap]: https://neovim.io/roadmap/ +[external UIs]: https://github.com/neovim/neovim/wiki/Related-projects#gui-projects <!-- vim: set tw=80: --> diff --git a/cmake/PreventInTreeBuilds.cmake b/cmake/PreventInTreeBuilds.cmake new file mode 100644 index 0000000000..9c0ce1c0a2 --- /dev/null +++ b/cmake/PreventInTreeBuilds.cmake @@ -0,0 +1,23 @@ +function(PreventInTreeBuilds) + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) + get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + + if("${srcdir}" STREQUAL "${bindir}") + message("") + message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message("Neovim doesn't support in-tree builds. It's recommended that you") + message("use a build/ subdirectory:") + message(" mkdir build") + message(" cd build") + message(" cmake <OPTIONS> ..") + message("") + message("Make sure to cleanup some CMake artifacts from this failed build") + message("with:") + message(" rm -rf CMakeFiles CMakeCache.txt") + message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + message("") + message(FATAL_ERROR "Stopping build.") + endif() +endfunction() + +PreventInTreeBuilds() diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index cf84f8c6a4..a16000aba8 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -142,12 +142,16 @@ configure_file ( find_program(WHOAMI_PROG whoami) find_program(HOSTNAME_PROG hostname) -if (NOT DEFINED USERNAME AND EXISTS ${WHOAMI_PROG}) +if (DEFINED ENV{USERNAME}) + set(USERNAME $ENV{USERNAME}) +elseif (NOT DEFINED USERNAME AND EXISTS ${WHOAMI_PROG}) execute_process(COMMAND ${WHOAMI_PROG} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE USERNAME) endif() -if (EXISTS ${HOSTNAME_PROG}) +if (DEFINED ENV{HOSTNAME}) + set(HOSTNAME $ENV{HOSTNAME}) +elseif (EXISTS ${HOSTNAME_PROG}) execute_process(COMMAND ${HOSTNAME_PROG} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE HOSTNAME) diff --git a/contrib/local.mk.example b/contrib/local.mk.example index a0b2d034e1..6959107ea2 100644 --- a/contrib/local.mk.example +++ b/contrib/local.mk.example @@ -2,7 +2,7 @@ # Individual entries must be uncommented to take effect. # By default, the installation prefix is '/usr/local'. -# CMAKE_EXTRA_FLAGS += -DCMAKE_INSTALL_PREFIX=/usr/local/nvim-latest +# PREFIX := /usr/local/nvim-latest # These CFLAGS can be used in addition to those specified in CMakeLists.txt: # CMAKE_EXTRA_FLAGS="-DCMAKE_C_FLAGS=-ftrapv -Wlogical-op" diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 8fa281e7e3..b1cfa8bf2b 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -100,26 +100,31 @@ function! s:version_info(python) abort \ 'import neovim; print(neovim.__file__)', \ '2>/dev/null'])) - let nvim_path = s:trim(system([ - \ 'python3', - \ '-c', - \ 'import neovim; print(neovim.__file__)' - \ ])) - " \ '2>/dev/null'])) - if empty(nvim_path) return [python_version, 'unable to find neovim executable', pypi_version, 'unable to get neovim executable'] endif + " Assuming that multiple versions of a package are installed, sort them + " numerically in descending order. + function! s:compare(metapath1, metapath2) + let a = matchstr(fnamemodify(a:metapath1, ':p:h:t'), '[0-9.]\+') + let b = matchstr(fnamemodify(a:metapath2, ':p:h:t'), '[0-9.]\+') + return a == b ? 0 : a > b ? 1 : -1 + endfunction + let nvim_version = 'unable to find neovim version' let base = fnamemodify(nvim_path, ':h') - for meta in glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1) - for meta_line in readfile(meta) + let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1) + let metas = sort(metas, 's:compare') + + if !empty(metas) + for meta_line in readfile(metas[0]) if meta_line =~# '^Version:' let nvim_version = matchstr(meta_line, '^Version: \zs\S\+') + break endif endfor - endfor + endif let version_status = 'unknown' if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version) @@ -148,7 +153,7 @@ endfunction function! s:check_python(version) abort call health#report_start('Python ' . a:version . ' provider') - let python_bin_name = 'python'.(a:version == 2 ? '2' : '3') + let python_bin_name = 'python'.(a:version == 2 ? '' : '3') let pyenv = resolve(exepath('pyenv')) let pyenv_root = exists('$PYENV_ROOT') ? resolve($PYENV_ROOT) : 'n' let venv = exists('$VIRTUAL_ENV') ? resolve($VIRTUAL_ENV) : '' diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index 110f80297a..1f30b91ab8 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -191,6 +191,7 @@ function! s:RegistrationCommands(host) abort let pattern = s:plugin_patterns[a:host] let paths = globpath(&rtp, 'rplugin/'.a:host.'/'.pattern, 0, 1) let paths = map(paths, 'tr(v:val,"\\","/")') " Normalize slashes #4795 + let paths = uniq(sort(paths)) if empty(paths) return [] endif @@ -260,11 +261,9 @@ endfunction function! remote#host#LoadErrorForHost(host, log) abort return 'Failed to load '. a:host . ' host. '. - \ 'You can try to see what happened '. - \ 'by starting Neovim with the environment variable '. - \ a:log . ' set to a file and opening the generated '. - \ 'log file. Also, the host stderr is available '. - \ 'in messages.' + \ 'You can try to see what happened by starting nvim with '. + \ a:log . ' set and opening the generated log file.'. + \ ' Also, the host stderr is available in messages.' endfunction diff --git a/runtime/compiler/gcc.vim b/runtime/compiler/gcc.vim index aee31d92c2..19ea2edc12 100644 --- a/runtime/compiler/gcc.vim +++ b/runtime/compiler/gcc.vim @@ -2,6 +2,7 @@ " Compiler: GNU C Compiler " Maintainer: Nikolai Weibull <now@bitwi.se> " Latest Revision: 2010-10-14 +" added line suggested by Anton Lindqvist 2016 Mar 31 if exists("current_compiler") finish @@ -24,6 +25,7 @@ CompilerSet errorformat= \%f:%l:\ %trror:\ %m, \%f:%l:\ %tarning:\ %m, \%f:%l:\ %m, + \%f:\\(%*[^\\)]\\):\ %m, \\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m, \%D%*\\a[%*\\d]:\ Entering\ directory\ [`']%f', \%X%*\\a[%*\\d]:\ Leaving\ directory\ [`']%f', diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index d108aca62f..2b69929cfe 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -41,3 +41,4 @@ Options ~ *'vi'* *'viminfo'* Deprecated alias to 'shada' option. + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index c505652b1b..249208911b 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -36,7 +36,9 @@ these differences. - 'autoindent' is set by default - 'autoread' is set by default - 'backspace' defaults to "indent,eol,start" +- 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|) - 'complete' doesn't include "i" +- 'directory' defaults to ~/.local/share/nvim/swap// (|xdg|), auto-created - 'display' defaults to "lastline" - 'encoding' defaults to "utf-8" - 'formatoptions' defaults to "tcqj" @@ -54,6 +56,7 @@ these differences. - 'tabpagemax' defaults to 50 - 'tags' defaults to "./tags;,tags" - 'ttyfast' is always set +- 'undodir' defaults to ~/.local/share/nvim/undo (|xdg|), auto-created - 'viminfo' includes "!" - 'wildmenu' is set by default diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim index 8aaf82e21f..828bc3120b 100644 --- a/runtime/indent/html.vim +++ b/runtime/indent/html.vim @@ -2,7 +2,7 @@ " Header: "{{{ " Maintainer: Bram Moolenaar " Original Author: Andy Wokula <anwoku@yahoo.de> -" Last Change: 2015 Sep 25 +" Last Change: 2016 Mar 30 " Version: 1.0 " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -240,13 +240,13 @@ call s:AddITags(s:indent_tags, [ \ 'sup', 'table', 'textarea', 'title', 'tt', 'u', 'ul', 'var', 'th', 'td', \ 'tr', 'tbody', 'tfoot', 'thead']) -" Tags added 2011 Sep 09 (especially HTML5 tags): +" New HTML5 elements: call s:AddITags(s:indent_tags, [ \ 'area', 'article', 'aside', 'audio', 'bdi', 'canvas', - \ 'command', 'datalist', 'details', 'embed', 'figure', 'footer', - \ 'header', 'group', 'keygen', 'mark', 'math', 'meter', 'nav', 'output', - \ 'progress', 'ruby', 'section', 'svg', 'texture', 'time', 'video', - \ 'wbr', 'text']) + \ 'command', 'data', 'datalist', 'details', 'embed', 'figcaption', + \ 'figure', 'footer', 'header', 'keygen', 'mark', 'meter', 'nav', 'output', + \ 'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary', 'svg', + \ 'time', 'track', 'video', 'wbr']) " Tags added for web components: call s:AddITags(s:indent_tags, [ diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 2ad87d1062..3d585267d7 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2016 Mar 19 +" Last Change: 2016 Apr 21 " If there already is an option window, jump to that one. if bufwinnr("option-window") > 0 diff --git a/runtime/synmenu.vim b/runtime/synmenu.vim index 76f60131f2..01dad3c7f2 100644 --- a/runtime/synmenu.vim +++ b/runtime/synmenu.vim @@ -61,6 +61,7 @@ an 50.10.320 &Syntax.AB.Ascii\ Doc :cal SetSyn("asciidoc")<CR> an 50.10.330 &Syntax.AB.ASP\ with\ VBScript :cal SetSyn("aspvbs")<CR> an 50.10.340 &Syntax.AB.ASP\ with\ Perl :cal SetSyn("aspperl")<CR> an 50.10.350 &Syntax.AB.Assembly.680x0 :cal SetSyn("asm68k")<CR> +an 50.10.355 &Syntax.AB.Assembly.AVR :cal SetSyn("avra")<CR> an 50.10.360 &Syntax.AB.Assembly.Flat :cal SetSyn("fasm")<CR> an 50.10.370 &Syntax.AB.Assembly.GNU :cal SetSyn("asm")<CR> an 50.10.380 &Syntax.AB.Assembly.GNU\ H-8300 :cal SetSyn("asmh8300")<CR> diff --git a/runtime/syntax/avra.vim b/runtime/syntax/avra.vim new file mode 100644 index 0000000000..ebf0aaff11 --- /dev/null +++ b/runtime/syntax/avra.vim @@ -0,0 +1,73 @@ +" Vim syntax file +" Language: AVR Assembler (AVRA) +" AVRA Home: http://avra.sourceforge.net/index.html +" AVRA Version: 1.3.0 +" Maintainer: Marius Ghita <mhitza@gmail.com> + +let s:cpo_save = &cpo +set cpo&vim + +setlocal iskeyword=a-z,A-Z,48-57,.,_ +" 'isident' is a global option, better not set it +" setlocal isident=a-z,A-Z,48-57,.,_ +syn case ignore + +syn keyword avraRegister r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 +syn keyword avraRegister r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 +syn keyword avraRegister r28 r29 r30 r31 + +syn keyword avraInstr add adc adiw sub subi sbc sbci sbiw and andi or ori eor +syn keyword avraInstr com neg sbr cbr inc dec tst clr ser mul muls mulsu fmul +syn keyword avraInstr fmuls fmulsu des rjmp ijmp eijmp jmp rcall icall eicall +syn keyword avraInstr call ret reti cpse cp cpc cpi sbrc sbrs sbic sbis brbs +syn keyword avraInstr brbc breq brne brcs brcc brsh brlo brmi brpl brge brlt +syn keyword avraInstr brhs brhc brts brtc brvs brvc brie brid mov movw ldi lds +syn keyword avraInstr ld ldd sts st std lpm elpm spm in out push pop xch las +syn keyword avraInstr lac lat lsl lsr rol ror asr swap bset bclr sbi cbi bst bld +syn keyword avraInstr sec clc sen cln sez clz sei cli ses cls sev clv set clt +syn keyword avraInstr seh clh break nop sleep wdr + +syn keyword avraDirective .byte .cseg .db .def .device .dseg .dw .endmacro .equ +syn keyword avraDirective .eseg .exit .include .list .listmac .macro .nolist +syn keyword avraDirective .org .set .define .undef .ifdef .ifndef .if .else +syn keyword avraDirective .elif .elseif .warning + +syn keyword avraOperator low high byte2 byte3 byte4 lwrd hwrd page exp2 log2 + +syn match avraNumericOperator "[-*/+]" +syn match avraUnaryOperator "!" +syn match avraBinaryOperator "<<\|>>\|<\|<=\|>\|>=\|==\|!=" +syn match avraBitwiseOperator "[~&^|]\|&&\|||" + +syn match avraBinaryNumber "\<0[bB][0-1]*\>" +syn match avraHexNumber "\<0[xX][0-9a-fA-F]\+\>" +syn match avraDecNumber "\<\(0\|[1-9]\d*\)\>" + +syn region avraComment start=";" end="$" +syn region avraString start="\"" end="\"\|$" + +syn match avraLabel "^\s*[^; \t]\+:" + +hi def link avraBinaryNumber avraNumber +hi def link avraHexNumber avraNumber +hi def link avraDecNumber avraNumber + +hi def link avraNumericOperator avraOperator +hi def link avraUnaryOperator avraOperator +hi def link avraBinaryOperator avraOperator +hi def link avraBitwiseOperator avraOperator + + +hi def link avraOperator operator +hi def link avraComment comment +hi def link avraDirective preproc +hi def link avraRegister type +hi def link avraNumber constant +hi def link avraString String +hi def link avraInstr keyword +hi def link avraLabel label + +let b:current_syntax = "avra" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/syntax/desktop.vim b/runtime/syntax/desktop.vim index 5b71e51192..27dac5c8ee 100644 --- a/runtime/syntax/desktop.vim +++ b/runtime/syntax/desktop.vim @@ -3,7 +3,8 @@ " according to freedesktop.org specification 0.9.4 " http://pdx.freedesktop.org/Standards/desktop-entry-spec/desktop-entry-spec-0.9.4.html " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2004 May 16 +" Last Change: 2016 Apr 02 +" (added "Keywords") " Version Info: desktop.vim 0.9.4-1.2 " For version 5.x: Clear all syntax items @@ -53,8 +54,8 @@ syn keyword dtBooleanKey StartupNotify ReadOnly Terminal Hidden NoDisplay nextgr syn keyword dtBooleanValue true false containedin=dtBoolean contained " String -syn match dtString /^\s*\<\(Encoding\|Icon\|Path\|Actions\|FSType\|MountPoint\|UnmountIcon\|URL\|Categories\|OnlyShowIn\|NotShowIn\|StartupWMClass\|FilePattern\|MimeType\)\>.*/ contains=dtStringKey,dtDelim transparent -syn keyword dtStringKey Type Encoding TryExec Exec Path Actions FSType MountPoint URL Categories OnlyShowIn NotShowIn StartupWMClass FilePattern MimeType nextgroup=dtDelim containedin=dtString contained +syn match dtString /^\s*\<\(Encoding\|Icon\|Path\|Actions\|FSType\|MountPoint\|UnmountIcon\|URL\|Keywords\|Categories\|OnlyShowIn\|NotShowIn\|StartupWMClass\|FilePattern\|MimeType\)\>.*/ contains=dtStringKey,dtDelim transparent +syn keyword dtStringKey Type Encoding TryExec Exec Path Actions FSType MountPoint URL Keywords Categories OnlyShowIn NotShowIn StartupWMClass FilePattern MimeType nextgroup=dtDelim containedin=dtString contained " Exec syn match dtExec /^\s*\<\(Exec\|TryExec\|SwallowExec\)\>.*/ contains=dtExecKey,dtDelim,dtExecParam transparent diff --git a/runtime/syntax/diff.vim b/runtime/syntax/diff.vim index 885feaebdd..b656cd97a6 100644 --- a/runtime/syntax/diff.vim +++ b/runtime/syntax/diff.vim @@ -2,7 +2,7 @@ " Language: Diff (context or unified) " Maintainer: Bram Moolenaar <Bram@vim.org> " Translations by Jakson Alves de Aquino. -" Last Change: 2015 Feb 03 +" Last Change: 2016 Apr 02 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -342,7 +342,7 @@ syn match diffLine "^\<\d\+\>.*" syn match diffLine "^\*\*\*\*.*" syn match diffLine "^---$" -"Some versions of diff have lines like "#c#" and "#d#" (where # is a number) +" Some versions of diff have lines like "#c#" and "#d#" (where # is a number) syn match diffLine "^\d\+\(,\d\+\)\=[cda]\d\+\>.*" syn match diffFile "^diff\>.*" @@ -352,12 +352,16 @@ syn match diffFile "^==== .*" syn match diffOldFile "^\*\*\* .*" syn match diffNewFile "^--- .*" +" Used by git +syn match diffIndexLine "^index \x\x\x\x.*" + syn match diffComment "^#.*" " Define the default highlighting. " Only used when an item doesn't have highlighting yet hi def link diffOldFile diffFile hi def link diffNewFile diffFile +hi def link diffIndexLine PreProc hi def link diffFile Type hi def link diffOnly Constant hi def link diffIdentical Constant diff --git a/runtime/syntax/help.vim b/runtime/syntax/help.vim index d133c6a804..b3c7f2a63e 100644 --- a/runtime/syntax/help.vim +++ b/runtime/syntax/help.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Vim help file " Maintainer: Bram Moolenaar (Bram@vim.org) -" Last Change: 2014 Feb 12 +" Last Change: 2016 Apr 01 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -41,6 +41,7 @@ syn match helpVim "NVIM REFERENCE.*" syn match helpOption "'[a-z]\{2,\}'" syn match helpOption "'t_..'" syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick +syn match helpCommand "\(^\|[^a-z"[]\)\zs`[^`]\+`\ze\([^a-z\t."']\|$\)"hs=s+1,he=e-1 contains=helpBacktick syn match helpHeader "\s*\zs.\{-}\ze\s\=\~$" nextgroup=helpIgnore syn match helpGraphic ".* \ze`$" nextgroup=helpIgnore if has("conceal") diff --git a/runtime/syntax/sshconfig.vim b/runtime/syntax/sshconfig.vim index 44b3c67a96..bd9f0a3c28 100644 --- a/runtime/syntax/sshconfig.vim +++ b/runtime/syntax/sshconfig.vim @@ -4,8 +4,8 @@ " Maintainer: Dominik Fischer <d dot f dot fischer at web dot de> " Contributor: Leonard Ehrenfried <leonard.ehrenfried@web.de> " Contributor: Karsten Hopp <karsten@redhat.com> -" Last Change: 2016 Mar 1 -" SSH Version: 7.2 +" Last Change: 2016 Apr 7 +" SSH Version: 7.2p2 " " Setup @@ -36,7 +36,7 @@ syn keyword sshconfigTodo TODO FIXME NOTE contained " Constants -syn keyword sshconfigYesNo yes no ask +syn keyword sshconfigYesNo yes no ask confirm syn keyword sshconfigYesNo any auto syn keyword sshconfigYesNo force autoask none @@ -139,6 +139,7 @@ syn keyword sshconfigHostSect Host syn keyword sshconfigMatch canonical exec host originalhost user localuser all syn keyword sshconfigKeyword AddressFamily +syn keyword sshconfigKeyword AddKeysToAgent syn keyword sshconfigKeyword BatchMode syn keyword sshconfigKeyword BindAddress syn keyword sshconfigKeyword CanonicalDomains diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index c855267137..d056e5b7bf 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Vim 7.4 script " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Apr 02, 2015 -" Version: 7.4-33 +" Last Change: March 29, 2016 +" Version: 7.4-45 " Automatically generated keyword lists: {{{1 " Quit when a syntax file was already loaded {{{2 @@ -58,6 +58,59 @@ syn keyword nvimHLGroup contained EndOfBuffer TermCursor TermCursorNC QuickFixLi syn case match " Special Vim Highlighting (not automatic) {{{1 +" Set up folding commands +if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[aflmpPrt]' + if g:vimsyn_folding =~# 'a' + com! -nargs=* VimFolda <args> fold + else + com! -nargs=* VimFolda <args> + endif + if g:vimsyn_folding =~# 'f' + com! -nargs=* VimFoldf <args> fold + else + com! -nargs=* VimFoldf <args> + endif + if g:vimsyn_folding =~# 'l' + com! -nargs=* VimFoldl <args> fold + else + com! -nargs=* VimFoldl <args> + endif + if g:vimsyn_folding =~# 'm' + com! -nargs=* VimFoldm <args> fold + else + com! -nargs=* VimFoldm <args> + endif + if g:vimsyn_folding =~# 'p' + com! -nargs=* VimFoldp <args> fold + else + com! -nargs=* VimFoldp <args> + endif + if g:vimsyn_folding =~# 'P' + com! -nargs=* VimFoldP <args> fold + else + com! -nargs=* VimFoldP <args> + endif + if g:vimsyn_folding =~# 'r' + com! -nargs=* VimFoldr <args> fold + else + com! -nargs=* VimFoldr <args> + endif + if g:vimsyn_folding =~# 't' + com! -nargs=* VimFoldt <args> fold + else + com! -nargs=* VimFoldt <args> + endif +else + com! -nargs=* VimFolda <args> + com! -nargs=* VimFoldf <args> + com! -nargs=* VimFoldl <args> + com! -nargs=* VimFoldm <args> + com! -nargs=* VimFoldp <args> + com! -nargs=* VimFoldP <args> + com! -nargs=* VimFoldr <args> + com! -nargs=* VimFoldt <args> +endif + " commands not picked up by the generator (due to non-standard format) syn keyword vimCommand contained py3 @@ -80,8 +133,8 @@ syn match vimNumber "\<0[xX]\x\+" syn match vimNumber "\%(^\|[^a-zA-Z]\)\zs#\x\{6}" " All vimCommands are contained by vimIsCommands. {{{2 -syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAddress,vimAutoCmd,vimCommand,vimIsCommand,vimExtCmd,vimFilter,vimLet,vimMap,vimMark,vimSet,vimSyntax,vimUserCmd,vimOnlyCommand -syn match vimIsCommand "\<\h\w*\>" contains=vimCommand,vimOnlyCommand +syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAddress,vimAutoCmd,vimIsCommand,vimExtCmd,vimFilter,vimLet,vimMap,vimMark,vimSet,vimSyntax,vimUserCmd +syn match vimIsCommand "\<\h\w*\>" contains=vimCommand syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>" syn match vimVar "\<[bwglsav]:\h[a-zA-Z0-9#_]*\>" syn match vimFBVar contained "\<[bwglsav]:\h[a-zA-Z0-9#_]*\>" @@ -113,7 +166,7 @@ syn keyword vimFTOption contained detect indent off on plugin " Augroup : vimAugroupError removed because long augroups caused sync'ing problems. {{{2 " ======= : Trade-off: Increasing synclines with slower editing vs augroup END error checking. syn cluster vimAugroupList contains=vimAugroup,vimIsCommand,vimCommand,vimUserCmd,vimExecute,vimNotFunc,vimFuncName,vimFunction,vimFunctionError,vimLineComment,vimMap,vimSpecFile,vimOper,vimNumber,vimOperParen,vimComment,vimString,vimSubst,vimMark,vimRegister,vimAddress,vimFilter,vimCmplxRepeat,vimComment,vimLet,vimSet,vimAutoCmd,vimRegion,vimSynLine,vimNotation,vimCtrlChar,vimFuncVar,vimContinue -if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'a' +if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'a' syn region vimAugroup fold matchgroup=vimAugroupKey start="\<aug\%[roup]\>\ze\s\+\K\k*" end="\<aug\%[roup]\>\ze\s\+[eE][nN][dD]\>" contains=vimAutoCmd,@vimAugroupList else syn region vimAugroup matchgroup=vimAugroupKey start="\<aug\%[roup]\>\ze\s\+\K\k*" end="\<aug\%[roup]\>\ze\s\+[eE][nN][dD]\>" contains=vimAutoCmd,@vimAugroupList @@ -130,7 +183,7 @@ syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperPa syn match vimOper "\(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\|=\)[?#]\{0,2}" skipwhite nextgroup=vimString,vimSpecFile syn match vimOper "||\|&&\|[-+.]" skipwhite nextgroup=vimString,vimSpecFile syn region vimOperParen matchgroup=vimParenSep start="(" end=")" contains=@vimOperGroup -syn region vimOperParen matchgroup=vimSep start="{" end="}" contains=@vimOperGroup nextgroup=vimVar,vimFuncVar +syn region vimOperParen matchgroup=vimSep start="{" end="}" contains=@vimOperGroup nextgroup=vimVar,vimFuncVar if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_noopererror") syn match vimOperError ")" endif @@ -141,7 +194,7 @@ syn cluster vimFuncList contains=vimCommand,vimFunctionError,vimFuncKey,Tag,vimF syn cluster vimFuncBodyList contains=vimAbb,vimAddress,vimAugroupKey,vimAutoCmd,vimCmplxRepeat,vimComment,vimComment,vimContinue,vimCtrlChar,vimEcho,vimEchoHL,vimExecute,vimIf,vimIsCommand,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimGlobal,vimHighlight,vimIsCommand,vimLet,vimLineComment,vimMap,vimMark,vimNorm,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSet,vimSpecFile,vimString,vimSubst,vimSynLine,vimUnmap,vimUserCommand,nvimUnmap,nvimMap syn match vimFunction "\<fu\%[nction]!\=\s\+\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\ze\s*(" contains=@vimFuncList nextgroup=vimFuncBody -if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'f' +if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f' syn region vimFuncBody contained fold start="\ze\s*(" matchgroup=vimCommand end="\<\(endf\>\|endfu\%[nction]\>\)" contains=@vimFuncBodyList else syn region vimFuncBody contained start="\ze\s*(" matchgroup=vimCommand end="\<\(endf\>\|endfu\%[nction]\>\)" contains=@vimFuncBodyList @@ -225,7 +278,7 @@ syn cluster vimSubstList contains=vimPatSep,vimPatRegion,vimPatSepErr,vimSubstTw syn cluster vimSubstRepList contains=vimSubstSubstr,vimSubstTwoBS,vimNotation syn cluster vimSubstList add=vimCollection syn match vimSubst "\(:\+\s*\|^\s*\||\s*\)\<\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)[:[:alpha:]]\@!" nextgroup=vimSubstPat -syn match vimSubst "s\%[ubstitute][:#[:alpha:]]\@!" nextgroup=vimSubstPat contained +syn match vimSubst "\%(^\|[^\\]\)s\%[ubstitute][:#[:alpha:]]\@!" nextgroup=vimSubstPat contained syn match vimSubst "/\zss\%[ubstitute]\ze/" nextgroup=vimSubstPat syn match vimSubst1 contained "s\%[ubstitute]\>" nextgroup=vimSubstPat syn region vimSubstPat contained matchgroup=vimSubstDelim start="\z([^a-zA-Z( \t[\]&]\)"rs=s+1 skip="\\\\\|\\\z1" end="\z1"re=e-1,me=e-1 contains=@vimSubstList nextgroup=vimSubstRep4 oneline @@ -267,7 +320,7 @@ syn match vimCmplxRepeat '[^a-zA-Z_/\\()]q[0-9a-zA-Z"]\>'lc=1 syn match vimCmplxRepeat '@[0-9a-z".=@:]\ze\($\|[^a-zA-Z]\>\)' " Set command and associated set-options (vimOptions) with comment {{{2 -syn region vimSet matchgroup=vimCommand start="\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skip="\%(\\\\\)*\\." end="$" matchgroup=vimNotation end="<[cC][rR]>" keepend oneline contains=vimSetEqual,vimOption,vimErrSetting,vimComment,vimSetString,vimSetMod,vimTermOption,vimOnlyOption +syn region vimSet matchgroup=vimCommand start="\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skip="\%(\\\\\)*\\." end="$" matchgroup=vimNotation end="<[cC][rR]>" keepend oneline contains=vimSetEqual,vimOption,vimErrSetting,vimComment,vimSetString,vimSetMod syn region vimSetEqual contained start="[=:]\|[-+^]=" skip="\\\\\|\\\s" end="[| \t]\|$"me=e-1 contains=vimCtrlChar,vimSetSep,vimNotation,vimEnvvar oneline syn region vimSetString contained start=+="+hs=s+1 skip=+\\\\\|\\"+ end=+"+ contains=vimCtrlChar syn match vimSetSep contained "[,:]" skipwhite nextgroup=vimCommand @@ -341,8 +394,8 @@ syn case match " User Function Highlighting {{{2 " (following Gautam Iyer's suggestion) " ========================== -syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%([a-zA-Z0-9_.]\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncName,vimUserFunc,vimExecute -syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%([a-zA-Z0-9_.]\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation +syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%([a-zA-Z0-9_]\+\.\)*\I[a-zA-Z0-9_.]*\)\ze\s*(" contains=vimFuncName,vimUserFunc,vimExecute +syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%([a-zA-Z0-9_]\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation syn match vimNotFunc "\<if\>\|\<el\%[seif]\>\|\<return\>\|\<while\>" " Errors And Warnings: {{{2 @@ -388,11 +441,16 @@ syn keyword vimSynType contained clear skipwhite nextgroup=vimGroupList " Syntax: cluster {{{2 syn keyword vimSynType contained cluster skipwhite nextgroup=vimClusterName -syn region vimClusterName contained matchgroup=vimGroupName start="\k\+" skip="\\\\\|\\|" matchgroup=vimSep end="$\||" contains=vimGroupAdd,vimGroupRem,vimSynContains,vimSynError +syn region vimClusterName contained matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|" matchgroup=vimSep end="$\||" contains=vimGroupAdd,vimGroupRem,vimSynContains,vimSynError syn match vimGroupAdd contained "add=" nextgroup=vimGroupList syn match vimGroupRem contained "remove=" nextgroup=vimGroupList syn cluster vimFuncBodyList add=vimSynType,vimGroupAdd,vimGroupRem +" Syntax: iskeyword {{{2 +syn keyword vimSynType contained iskeyword skipwhite nextgroup=vimIskList +syn match vimIskList contained '\S\+' contains=vimIskSep +syn match vimIskSep contained ',' + " Syntax: include {{{2 syn keyword vimSynType contained include skipwhite nextgroup=vimGroupList syn cluster vimFuncBodyList add=vimSynType @@ -400,14 +458,14 @@ syn cluster vimFuncBodyList add=vimSynType " Syntax: keyword {{{2 syn cluster vimSynKeyGroup contains=vimSynNextgroup,vimSynKeyOpt,vimSynKeyContainedin syn keyword vimSynType contained keyword skipwhite nextgroup=vimSynKeyRegion -syn region vimSynKeyRegion contained oneline keepend matchgroup=vimGroupName start="\k\+" skip="\\\\\|\\|" matchgroup=vimSep end="|\|$" contains=@vimSynKeyGroup +syn region vimSynKeyRegion contained oneline keepend matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|" matchgroup=vimSep end="|\|$" contains=@vimSynKeyGroup syn match vimSynKeyOpt contained "\<\(conceal\|contained\|transparent\|skipempty\|skipwhite\|skipnl\)\>" syn cluster vimFuncBodyList add=vimSynType " Syntax: match {{{2 syn cluster vimSynMtchGroup contains=vimMtchComment,vimSynContains,vimSynError,vimSynMtchOpt,vimSynNextgroup,vimSynRegPat,vimNotation syn keyword vimSynType contained match skipwhite nextgroup=vimSynMatchRegion -syn region vimSynMatchRegion contained keepend matchgroup=vimGroupName start="\k\+" matchgroup=vimSep end="|\|$" contains=@vimSynMtchGroup +syn region vimSynMatchRegion contained keepend matchgroup=vimGroupName start="\h\w*" matchgroup=vimSep end="|\|$" contains=@vimSynMtchGroup syn match vimSynMtchOpt contained "\<\(conceal\|transparent\|contained\|excludenl\|skipempty\|skipwhite\|display\|extend\|skipnl\|fold\)\>" if has("conceal") syn match vimSynMtchOpt contained "\<cchar=" nextgroup=vimSynMtchCchar @@ -422,7 +480,7 @@ syn keyword vimSynType contained enable list manual off on reset syn cluster vimSynRegPatGroup contains=vimPatSep,vimNotPatSep,vimSynPatRange,vimSynNotPatRange,vimSubstSubstr,vimPatRegion,vimPatSepErr,vimNotation syn cluster vimSynRegGroup contains=vimSynContains,vimSynNextgroup,vimSynRegOpt,vimSynReg,vimSynMtchGrp syn keyword vimSynType contained region skipwhite nextgroup=vimSynRegion -syn region vimSynRegion contained keepend matchgroup=vimGroupName start="\k\+" skip="\\\\\|\\|" end="|\|$" contains=@vimSynRegGroup +syn region vimSynRegion contained keepend matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|" end="|\|$" contains=@vimSynRegGroup syn match vimSynRegOpt contained "\<\(conceal\(ends\)\=\|transparent\|contained\|excludenl\|skipempty\|skipwhite\|display\|keepend\|oneline\|extend\|skipnl\|fold\)\>" syn match vimSynReg contained "\(start\|skip\|end\)="he=e-1 nextgroup=vimSynRegPat syn match vimSynMtchGrp contained "matchgroup=" nextgroup=vimGroup,vimHLGroup,vimOnlyHLGroup,nvimHLGroup @@ -448,9 +506,9 @@ syn keyword vimSyncRegion contained region skipwhite nextgroup=vimSynReg syn match vimSyncLinebreak contained "\<linebreaks=" skipwhite nextgroup=vimNumber syn keyword vimSyncLinecont contained linecont skipwhite nextgroup=vimSynRegPat syn match vimSyncLines contained "\(min\|max\)\=lines=" nextgroup=vimNumber -syn match vimSyncGroupName contained "\k\+" skipwhite nextgroup=vimSyncKey +syn match vimSyncGroupName contained "\h\w*" skipwhite nextgroup=vimSyncKey syn match vimSyncKey contained "\<groupthere\|grouphere\>" skipwhite nextgroup=vimSyncGroup -syn match vimSyncGroup contained "\k\+" skipwhite nextgroup=vimSynRegPat,vimSyncNone +syn match vimSyncGroup contained "\h\w*" skipwhite nextgroup=vimSynRegPat,vimSyncNone syn keyword vimSyncNone contained NONE " Additional IsCommand, here by reasons of precedence {{{2 @@ -531,9 +589,14 @@ syn region vimGlobal matchgroup=Statement start='\<v\%[global]!\=/' skip='\\.' e " Allows users to specify the type of embedded script highlighting " they want: (perl/python/ruby/tcl support) " g:vimsyn_embed == 0 : don't embed any scripts -" g:vimsyn_embed ~= 'P' : embed python (but only if vim supports it) +" g:vimsyn_embed =~# 'l' : embed lua (but only if vim supports it) +" g:vimsyn_embed =~# 'm' : embed mzscheme (but only if vim supports it) +" g:vimsyn_embed =~# 'p' : embed perl (but only if vim supports it) +" g:vimsyn_embed =~# 'P' : embed python (but only if vim supports it) +" g:vimsyn_embed =~# 'r' : embed ruby (but only if vim supports it) +" g:vimsyn_embed =~# 't' : embed tcl (but only if vim supports it) if !exists("g:vimsyn_embed") - let g:vimsyn_embed= "P" + let g:vimsyn_embed= "lmpPr" endif " [-- lua --] {{{3 @@ -546,9 +609,16 @@ if !filereadable(s:luapath) endif endfor endif - -syn region vimEmbedError start=+lua\s*<<\s*\z(.*\)$+ end=+^\z1$+ -syn region vimEmbedError start=+lua\s*<<\s*$+ end=+\.$+ +if (g:vimsyn_embed =~# 'l' && has("lua")) && filereadable(s:luapath) + unlet! b:current_syntax + exe "syn include @vimLuaScript ".s:luapath + VimFoldl syn region vimLuaRegion matchgroup=vimScriptDelim start=+lua\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimLuaScript + VimFoldl syn region vimLuaRegion matchgroup=vimScriptDelim start=+lua\s*<<\s*$+ end=+\.$+ contains=@vimLuaScript + syn cluster vimFuncBodyList add=vimLuaRegion +else + syn region vimEmbedError start=+lua\s*<<\s*\z(.*\)$+ end=+^\z1$+ + syn region vimEmbedError start=+lua\s*<<\s*$+ end=+\.$+ +endif unlet s:luapath " [-- perl --] {{{3 @@ -561,9 +631,16 @@ if !filereadable(s:perlpath) endif endfor endif - -syn region vimEmbedError start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ -syn region vimEmbedError start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ +if (g:vimsyn_embed =~# 'p' && has("perl")) && filereadable(s:perlpath) + unlet! b:current_syntax + exe "syn include @vimPerlScript ".s:perlpath + VimFoldp syn region vimPerlRegion matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPerlScript + VimFoldp syn region vimPerlRegion matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ contains=@vimPerlScript + syn cluster vimFuncBodyList add=vimPerlRegion +else + syn region vimEmbedError start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ + syn region vimEmbedError start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ +endif unlet s:perlpath " [-- ruby --] {{{3 @@ -576,9 +653,16 @@ if !filereadable(s:rubypath) endif endfor endif - -syn region vimEmbedError start=+rub[y]\s*<<\s*\z(.*\)$+ end=+^\z1$+ -syn region vimEmbedError start=+rub[y]\s*<<\s*$+ end=+\.$+ +if (g:vimsyn_embed =~# 'r' && has("ruby")) && filereadable(s:rubypath) + unlet! b:current_syntax + exe "syn include @vimRubyScript ".s:rubypath + VimFoldr syn region vimRubyRegion matchgroup=vimScriptDelim start=+rub[y]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimRubyScript + syn region vimRubyRegion matchgroup=vimScriptDelim start=+rub[y]\s*<<\s*$+ end=+\.$+ contains=@vimRubyScript + syn cluster vimFuncBodyList add=vimRubyRegion +else + syn region vimEmbedError start=+rub[y]\s*<<\s*\z(.*\)$+ end=+^\z1$+ + syn region vimEmbedError start=+rub[y]\s*<<\s*$+ end=+\.$+ +endif unlet s:rubypath " [-- python --] {{{3 @@ -591,16 +675,13 @@ if !filereadable(s:pythonpath) endif endfor endif -if g:vimsyn_embed =~ 'P' && filereadable(s:pythonpath) +if g:vimsyn_embed =~# 'P' && (has("python") || has("python3")) && filereadable(s:pythonpath) unlet! b:current_syntax exe "syn include @vimPythonScript ".s:pythonpath - if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'P' - syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript - syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript - else - syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript - syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript - endif + VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript + VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript + VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript + VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript syn cluster vimFuncBodyList add=vimPythonRegion else syn region vimEmbedError start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ @@ -625,11 +706,17 @@ if s:trytcl endif endfor endif - - syn region vimEmbedError start=+tc[l]\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ - syn region vimEmbedError start=+tc[l]\=\s*<<\s*$+ end=+\.$+ + if (g:vimsyn_embed =~# 't' && has("tcl")) && filereadable(s:tclpath) + unlet! b:current_syntax + exe "syn include @vimTclScript ".s:tclpath + VimFoldt syn region vimTclRegion matchgroup=vimScriptDelim start=+tc[l]\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimTclScript + VimFoldt syn region vimTclRegion matchgroup=vimScriptDelim start=+tc[l]\=\s*<<\s*$+ end=+\.$+ contains=@vimTclScript + syn cluster vimFuncBodyList add=vimTclScript + else + syn region vimEmbedError start=+tc[l]\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ + syn region vimEmbedError start=+tc[l]\=\s*<<\s*$+ end=+\.$+ + endif unlet s:tclpath - else syn region vimEmbedError start=+tc[l]\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ syn region vimEmbedError start=+tc[l]\=\s*<<\s*$+ end=+\.$+ @@ -646,9 +733,18 @@ if !filereadable(s:mzschemepath) endif endfor endif - -syn region vimEmbedError start=+mz\%[scheme]\s*<<\s*\z(.*\)$+ end=+^\z1$+ -syn region vimEmbedError start=+mz\%[scheme]\s*<<\s*$+ end=+\.$+ +if (g:vimsyn_embed =~# 'm' && has("mzscheme")) && filereadable(s:mzschemepath) + unlet! b:current_syntax + let iskKeep= &isk + exe "syn include @vimMzSchemeScript ".s:mzschemepath + let &isk= iskKeep + VimFoldm syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimMzSchemeScript + VimFoldm syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*$+ end=+\.$+ contains=@vimMzSchemeScript + syn cluster vimFuncBodyList add=vimMzSchemeRegion +else + syn region vimEmbedError start=+mz\%[scheme]\s*<<\s*\z(.*\)$+ end=+^\z1$+ + syn region vimEmbedError start=+mz\%[scheme]\s*<<\s*$+ end=+\.$+ +endif unlet s:mzschemepath " Synchronize (speed) {{{2 @@ -668,7 +764,6 @@ syn sync match vimAugroupSyncA groupthere NONE "\<aug\%[roup]\>\s\+[eE][nN][dD]" " Highlighting Settings {{{2 " ==================== - if !exists("g:vimsyn_noerror") hi def link vimBehaveError vimError hi def link vimCollClassErr vimError @@ -685,14 +780,11 @@ if !exists("g:vimsyn_noerror") hi def link vimSubstFlagErr vimError hi def link vimSynCaseError vimError hi def link vimBufnrWarn vimWarn - hi def link vimOnlyCommand vimError - hi def link vimTermOption vimError - hi def link vimOnlyOption vimError - hi def link vimOnlyHLGroup vimError endif hi def link vimAbb vimCommand hi def link vimAddress vimMark +hi def link vimAugroupError vimError hi def link vimAugroupKey vimCommand hi def link vimAuHighlight vimHighlight hi def link vimAutoCmdOpt vimOption @@ -748,6 +840,7 @@ hi def link vimHLGroup vimGroup hi def link nvimHLGroup vimHLGroup hi def link vimHLMod PreProc hi def link vimInsert vimString +hi def link vimIskSep Delimiter hi def link vimKeyCode vimSpecFile hi def link vimKeyword Statement hi def link vimLet vimCommand @@ -830,6 +923,7 @@ hi def link vimUserAttrbCmpltFunc Special hi def link vimUserAttrbCmplt vimSpecial hi def link vimUserAttrbKey vimOption hi def link vimUserAttrb vimSpecial +hi def link vimUserAttrbError Error hi def link vimUserCmdError Error hi def link vimUserCommand vimCommand hi def link vimUserFunc Normal @@ -841,6 +935,14 @@ let b:current_syntax = "vim" " --------------------------------------------------------------------- " Cleanup: {{{1 +delc VimFolda +delc VimFoldf +delc VimFoldl +delc VimFoldm +delc VimFoldp +delc VimFoldP +delc VimFoldr +delc VimFoldt let &cpo = s:keepcpo unlet s:keepcpo " vim:ts=18 fdm=marker diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 59582d0734..cbea6a05c9 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -156,7 +156,7 @@ foreach(sfile ${NEOVIM_SOURCES} ${GENERATED_API_DISPATCH}) get_filename_component(full_d ${sfile} PATH) file(RELATIVE_PATH d "${PROJECT_SOURCE_DIR}/src/nvim" "${full_d}") - if(${d} MATCHES "^[.][.]") + if(${d} MATCHES "^([.][.]|auto/)") file(RELATIVE_PATH d "${GENERATED_DIR}" "${full_d}") endif() get_filename_component(f ${sfile} NAME) diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index fc114bae16..d80ee7dc67 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -368,11 +368,10 @@ static inline void typval_encode_list_start(EncodedData *const edata, const size_t len) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL { - const Object obj = OBJECT_INIT; kv_push(edata->stack, ARRAY_OBJ(((Array) { .capacity = len, .size = 0, - .items = xmalloc(len * sizeof(*obj.data.array.items)), + .items = xmalloc(len * sizeof(*((Object *)NULL)->data.array.items)), }))); } @@ -409,11 +408,10 @@ static inline void typval_encode_dict_start(EncodedData *const edata, const size_t len) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL { - const Object obj = OBJECT_INIT; kv_push(edata->stack, DICTIONARY_OBJ(((Dictionary) { .capacity = len, .size = 0, - .items = xmalloc(len * sizeof(*obj.data.dictionary.items)), + .items = xmalloc(len * sizeof(*((Object *)NULL)->data.dictionary.items)), }))); } diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index b42ad1c18a..5fb011885e 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -276,30 +276,25 @@ bool buf_valid(buf_T *buf) return false; } -/* - * Close the link to a buffer. - * "action" is used when there is no longer a window for the buffer. - * It can be: - * 0 buffer becomes hidden - * DOBUF_UNLOAD buffer is unloaded - * DOBUF_DELETE buffer is unloaded and removed from buffer list - * DOBUF_WIPE buffer is unloaded and really deleted - * When doing all but the first one on the current buffer, the caller should - * get a new buffer very soon! - * - * The 'bufhidden' option can force freeing and deleting. - * - * When "abort_if_last" is TRUE then do not close the buffer if autocommands - * cause there to be only one window with this buffer. e.g. when ":quit" is - * supposed to close the window but autocommands close all other windows. - */ -void -close_buffer ( - win_T *win, /* if not NULL, set b_last_cursor */ - buf_T *buf, - int action, - int abort_if_last -) +/// Close the link to a buffer. +/// +/// @param win If not NULL, set b_last_cursor. +/// @param buf +/// @param action Used when there is no longer a window for the buffer. +/// Possible values: +/// 0 buffer becomes hidden +/// DOBUF_UNLOAD buffer is unloaded +/// DOBUF_DELETE buffer is unloaded and removed from buffer list +/// DOBUF_WIPE buffer is unloaded and really deleted +/// When doing all but the first one on the current buffer, the +/// caller should get a new buffer very soon! +/// The 'bufhidden' option can force freeing and deleting. +/// @param abort_if_last +/// If TRUE, do not close the buffer if autocommands cause +/// there to be only one window with this buffer. e.g. when +/// ":quit" is supposed to close the window but autocommands +/// close all other windows. +void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) { bool unload_buf = (action != 0); bool del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 892748ff5c..51c9fb1556 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1286,10 +1286,9 @@ bool edit(int cmdchar, bool startln, long count) { if (curbuf->terminal) { if (ex_normal_busy) { - // don't enter terminal mode from `ex_normal`, which can result in all - // kinds of havoc(such as terminal mode recursiveness). Instead, set a - // flag that allow us to force-set the value of `restart_edit` before - // `ex_normal` returns + // Do not enter terminal mode from ex_normal(), which would cause havoc + // (such as terminal-mode recursiveness). Instead set a flag to force-set + // the value of `restart_edit` before `ex_normal` returns. restart_edit = 'i'; force_restart_edit = true; } else { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0b1fd6670e..ac8b675834 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -405,7 +405,7 @@ typedef struct { LibuvProcess uv; PtyProcess pty; } proc; - Stream in, out, err; + Stream in, out, err; // Initialized in common_job_start(). Terminal *term; bool stopped; bool exited; @@ -21739,7 +21739,7 @@ static inline TerminalJobData *common_job_init(char **argv, if (!pty) { proc->err = &data->err; } - proc->cb = on_process_exit; + proc->cb = eval_job_process_exit_cb; proc->events = data->events; proc->detach = detach; proc->cwd = cwd; @@ -21923,7 +21923,7 @@ static void on_job_output(Stream *stream, TerminalJobData *data, RBuffer *buf, rbuffer_consumed(buf, count); } -static void on_process_exit(Process *proc, int status, void *d) +static void eval_job_process_exit_cb(Process *proc, int status, void *d) { TerminalJobData *data = d; if (data->term && !data->exited) { @@ -21947,9 +21947,15 @@ static void on_process_exit(Process *proc, int status, void *d) static void term_write(char *buf, size_t size, void *d) { - TerminalJobData *data = d; + TerminalJobData *job = d; + if (job->in.closed) { + // If the backing stream was closed abruptly, there may be write events + // ahead of the terminal close event. Just ignore the writes. + ILOG("write failed: stream is closed"); + return; + } WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree); - wstream_write(&data->in, wbuf); + wstream_write(&job->in, wbuf); } static void term_resize(uint16_t width, uint16_t height, void *d) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 0226499e78..6205daf0cb 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2116,6 +2116,14 @@ do_ecmd ( } } + // Re-editing a terminal buffer: skip most buffer re-initialization. + if (!other_file && curbuf->terminal) { + check_arg_idx(curwin); // Needed when called from do_argfile(). + maketitle(); // Title may show the arg index, e.g. "(2 of 5)". + retval = OK; + goto theend; + } + /* * if the file was changed we may not be allowed to abandon it * - if we are going to re-edit the same file diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 45407b7f12..9f83688e1e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6726,11 +6726,6 @@ do_exedit ( old_curwin == NULL ? curwin : NULL); } else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) || *eap->arg != NUL) { - // ":edit <blank>" is a no-op in terminal buffers. #2822 - if (curbuf->terminal != NULL && eap->cmdidx == CMD_edit && *eap->arg == NUL) { - return; - } - /* Can't edit another file when "curbuf_lock" is set. Only ":edit" * can bring us here, others are stopped earlier. */ if (*eap->arg != NUL && curbuf_locked()) @@ -7921,9 +7916,8 @@ static void ex_normal(exarg_T *eap) if (force_restart_edit) { force_restart_edit = false; } else { - // some function called was aware of ex_normal and decided to override the - // value of restart_edit anyway. So far only used in terminal mode(see - // terminal_enter() in edit.c) + // Some function (terminal_enter()) was aware of ex_normal and decided to + // override the value of restart_edit anyway. restart_edit = save_restart_edit; } p_im = save_insertmode; diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 7d4bfd0290..6acf7f395a 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -2105,7 +2105,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) props = enc_canon_props(p_encoding); if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) { p_mbenc_first = NULL; - int effective_cmap; + int effective_cmap = 0; for (cmap = 0; cmap < (int)ARRAY_SIZE(prt_ps_mbfonts); cmap++) if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap], &p_mbenc)) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 005f4dcc77..793babd4e5 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -320,14 +320,18 @@ int main(int argc, char **argv) // open terminals when opening files that start with term:// #define PROTO "term://" + do_cmdline_cmd("augroup nvim_terminal"); + do_cmdline_cmd("autocmd!"); do_cmdline_cmd("autocmd BufReadCmd " PROTO "* nested " - ":call termopen( " + ":if !exists('b:term_title')|call termopen( " // Capture the command string "matchstr(expand(\"<amatch>\"), " "'\\c\\m" PROTO "\\%(.\\{-}//\\%(\\d\\+:\\)\\?\\)\\?\\zs.*'), " // capture the working directory "{'cwd': get(matchlist(expand(\"<amatch>\"), " - "'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, '')})"); + "'\\c\\m" PROTO "\\(.\\{-}\\)//'), 1, '')})" + "|endif"); + do_cmdline_cmd("augroup END"); #undef PROTO /* Execute --cmd arguments. */ diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c08b9e8fcf..e6312f9c00 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1724,7 +1724,7 @@ int utf_class(int c) return 2; } -int utf_ambiguous_width(int c) +bool utf_ambiguous_width(int c) { return c >= 0x80 && (intable(ambiguous, ARRAY_SIZE(ambiguous), c) || intable(emoji_all, ARRAY_SIZE(emoji_all), c)); diff --git a/src/nvim/path.c b/src/nvim/path.c index a79b7139f1..6149e1ab99 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -903,17 +903,30 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) /* Shorten the filename while maintaining its uniqueness */ path_cutoff = get_path_cutoff(path, &path_ga); - /* we start at the end of the path */ - pathsep_p = path + len - 1; - - while (find_previous_pathsep(path, &pathsep_p)) - if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) - && is_unique(pathsep_p + 1, gap, i) - && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) { - sort_again = true; - memmove(path, pathsep_p + 1, STRLEN(pathsep_p)); - break; + // Don't assume all files can be reached without path when search + // pattern starts with **/, so only remove path_cutoff + // when possible. + if (pattern[0] == '*' && pattern[1] == '*' + && vim_ispathsep_nocolon(pattern[2]) + && path_cutoff != NULL + && vim_regexec(®match, path_cutoff, (colnr_T)0) + && is_unique(path_cutoff, gap, i)) { + sort_again = true; + memmove(path, path_cutoff, STRLEN(path_cutoff) + 1); + } else { + // Here all files can be reached without path, so get shortest + // unique path. We start at the end of the path. */ + pathsep_p = path + len - 1; + while (find_previous_pathsep(path, &pathsep_p)) { + if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) + && is_unique(pathsep_p + 1, gap, i) + && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) { + sort_again = true; + memmove(path, pathsep_p + 1, STRLEN(pathsep_p)); + break; + } } + } if (path_is_absolute_path(path)) { /* diff --git a/src/nvim/po/eo.po b/src/nvim/po/eo.po index 153eacc7b8..8a3cd50406 100644 --- a/src/nvim/po/eo.po +++ b/src/nvim/po/eo.po @@ -23,8 +23,8 @@ msgid "" msgstr "" "Project-Id-Version: Vim(Esperanto)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-13 23:42+0100\n" -"PO-Revision-Date: 2016-02-13 23:45+0100\n" +"POT-Creation-Date: 2016-03-29 23:03+0200\n" +"PO-Revision-Date: 2016-03-29 23:05+0200\n" "Last-Translator: Dominique PELLÉ <dominique.pelle@gmail.com>\n" "Language-Team: \n" "Language: eo\n" @@ -1346,7 +1346,6 @@ msgstr "E670: Miksaĵo de kodoprezento de helpa dosiero en lingvo: %s" msgid "E154: Duplicate tag \"%s\" in file %s/%s" msgstr "E154: Ripetita etikedo \"%s\" en dosiero %s/%s" -#: ../ex_cmds.c:5687 #, c-format msgid "E160: Unknown sign command: %s" msgstr "E160: Nekonata simbola komando: %s" @@ -1482,8 +1481,8 @@ msgstr "Serĉado de \"%s\"" #: ../ex_cmds2.c:2307 #, c-format -msgid "not found in 'runtimepath': \"%s\"" -msgstr "ne trovita en 'runtimepath': \"%s\"" +msgid "not found in '%s': \"%s\"" +msgstr "ne trovita en '%s: \"%s\"" #: ../ex_cmds2.c:2472 #, c-format @@ -6686,6 +6685,12 @@ msgstr "E446: Neniu dosiernomo sub la kursoro" #~ msgid "E232: Cannot create BalloonEval with both message and callback" #~ msgstr "E232: Ne eblas krei BalloonEval kun ambaŭ mesaĝo kaj reagfunkcio" +msgid "Yes" +msgstr "Jes" + +msgid "No" +msgstr "Ne" + # todo '_' is for hotkey, i guess? #~ msgid "Input _Methods" #~ msgstr "Enigaj _metodoj" diff --git a/src/nvim/po/fr.po b/src/nvim/po/fr.po index a16a939117..cd9f5a7eb2 100644 --- a/src/nvim/po/fr.po +++ b/src/nvim/po/fr.po @@ -645,7 +645,7 @@ msgstr "E708: [:] ne peut tre spcifi qu'en dernier" #: ../eval.c:2439 msgid "E709: [:] requires a List value" -msgstr "E709: [:] requiert une Liste" +msgstr "E709: [:] n?cessite une Liste" #: ../eval.c:2674 msgid "E710: List value has more items than target" @@ -1639,8 +1639,8 @@ msgstr "Recherche de \"%s\"" #: ../ex_cmds2.c:2307 #, c-format -msgid "not found in 'runtimepath': \"%s\"" -msgstr "introuvable dans 'runtimepath' : \"%s\"" +msgid "not found in '%s': \"%s\"" +msgstr "introuvable dans '%s' : \"%s\"" #: ../ex_cmds2.c:2472 #, c-format @@ -6877,6 +6877,12 @@ msgstr "E446: Aucun nom de fichier sous le curseur" #~ msgid "E232: Cannot create BalloonEval with both message and callback" #~ msgstr "E232: Impossible de crer un BalloonEval avec message ET callback" +msgid "Yes" +msgstr "Oui" + +msgid "No" +msgstr "Non" + # todo '_' is for hotkey, i guess? #~ msgid "Input _Methods" #~ msgstr "_Mthodes de saisie" diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 9a2eeda8b2..47dd640e59 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2210,8 +2210,8 @@ win_line ( ///< force wrapping int vcol_off = 0; ///< offset for concealed characters int did_wcol = false; - int match_conc = false; ///< cchar for match functions - int has_match_conc = false; ///< match wants to conceal + int match_conc = 0; ///< cchar for match functions + int has_match_conc = 0; ///< match wants to conceal int old_boguscols = 0; # define VCOL_HLC (vcol - vcol_off) # define FIX_FOR_BOGUSCOLS \ @@ -2656,7 +2656,7 @@ win_line ( // Repeat for the whole displayed line. for (;; ) { - has_match_conc = false; + has_match_conc = 0; // Skip this quickly when working on the text. if (draw_state != WL_LINE) { if (draw_state == WL_CMDLINE - 1 && n_extra == 0) { @@ -2906,10 +2906,10 @@ win_line ( shl->attr_cur = shl->attr; if (cur != NULL && syn_name2id((char_u *)"Conceal") == cur->hlg_id) { - has_match_conc = true; + has_match_conc = v == (long)shl->startcol ? 2 : 1; match_conc = cur->conceal_char; } else { - has_match_conc = match_conc = false; + has_match_conc = match_conc = 0; } } else if (v == (long)shl->endcol) { shl->attr_cur = 0; @@ -3633,11 +3633,11 @@ win_line ( if (wp->w_p_cole > 0 && (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp)) - && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc) + && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0) && !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - if (prev_syntax_id != syntax_seqnr + if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1) && (syn_get_sub_char() != NUL || match_conc || wp->w_p_cole == 1) && wp->w_p_cole != 3) { diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 8401343d7a..499716a7a8 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -366,10 +366,10 @@ void terminal_resize(Terminal *term, uint16_t width, uint16_t height) void terminal_enter(void) { buf_T *buf = curbuf; + assert(buf->terminal); // Should only be called when curbuf has a terminal. TerminalState state, *s = &state; memset(s, 0, sizeof(TerminalState)); s->term = buf->terminal; - assert(s->term && "should only be called when curbuf has a terminal"); // Ensure the terminal is properly sized. terminal_resize(s->term, 0, 0); diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 10d26bd8cf..4d21887240 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -41,6 +41,7 @@ NEW_TESTS = \ test_viml.res \ test_visual.res \ test_window_id.res \ + test_matchadd_conceal.res \ test_alot.res SCRIPTS_GUI := test16.out diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index f0efd6e4ed..7169b6076f 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -3,6 +3,7 @@ source test_assign.vim source test_cursor_func.vim +source test_ex_undo.vim source test_feedkeys.vim source test_cmdline.vim source test_menu.vim @@ -10,3 +11,4 @@ source test_popup.vim source test_regexp_utf8.vim source test_syn_attr.vim source test_unlet.vim +source test_matchadd_conceal_utf8.vim diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 902ec1c05d..006f6b82a8 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -152,3 +152,11 @@ func Test_getcompletion() call assert_fails('call getcompletion("", "burp")', 'E475:') endfunc + +func Test_expand_star_star() + call mkdir('a/b', 'p') + call writefile(['asdfasdf'], 'a/b/fileXname') + call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt') + call assert_equal('find a/b/fileXname', getreg(':')) + call delete('a', 'rf') +endfunc diff --git a/src/nvim/testdir/test_ex_undo.vim b/src/nvim/testdir/test_ex_undo.vim new file mode 100644 index 0000000000..44feb3680a --- /dev/null +++ b/src/nvim/testdir/test_ex_undo.vim @@ -0,0 +1,19 @@ +" Tests for :undo + +func Test_ex_undo() + new ex-undo + setlocal ul=10 + exe "normal ione\n\<Esc>" + setlocal ul=10 + exe "normal itwo\n\<Esc>" + setlocal ul=10 + exe "normal ithree\n\<Esc>" + call assert_equal(4, line('$')) + undo + call assert_equal(3, line('$')) + undo 1 + call assert_equal(2, line('$')) + undo 0 + call assert_equal(1, line('$')) + quit! +endfunc diff --git a/src/nvim/testdir/test_matchadd_conceal.vim b/src/nvim/testdir/test_matchadd_conceal.vim new file mode 100644 index 0000000000..bc1c28d6e9 --- /dev/null +++ b/src/nvim/testdir/test_matchadd_conceal.vim @@ -0,0 +1,262 @@ +" Test for matchadd() and conceal feature +if !has('conceal') + finish +endif + +function! s:screenline(lnum) abort + let line = [] + for c in range(1, winwidth(0)) + call add(line, nr2char(screenchar(a:lnum, c))) + endfor + return s:trim(join(line, '')) +endfunction + +function! s:trim(str) abort + return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') +endfunction + +function! Test_simple_matchadd() + new + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ') + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + quit! +endfunction + +function! Test_simple_matchadd_and_conceal() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#XThisXisXaXTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + quit! +endfunction + +function! Test_matchadd_and_conceallevel_3() + new + + setlocal conceallevel=3 + " set filetype and :syntax on to change screenattr() + setlocal filetype=conf + syntax on + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ThisisaTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 16)) + + " more matchadd() + " 1234567890123456 + let expect = '#Thisisa Test' + + call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'}) + redraw! + call assert_equal(expect, s:screenline(lnum)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2) , screenattr(lnum, 7)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 10), screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 10), screenattr(lnum, 16)) + + syntax off + quit! +endfunction + +function! Test_default_conceal_char() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + " 1234567890123456 + let expect = '#+This+is+a+Test' + let listchars_save = &listchars + set listchars=conceal:+ + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + let &listchars = listchars_save + quit! +endfunction + +function! Test_syn_and_match_conceal() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ZThisZisZaZTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) + syntax match MyConceal /\%2l / conceal containedin=ALL cchar=* + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + " 1234567890123456 + let expect = '#*This*is*a*Test' + call clearmatches() + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + syntax off + quit! +endfunction + +function! Test_clearmatches() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) + let a = getmatches() + call clearmatches() + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + " reset match using setmatches() + " 1234567890123456 + let expect = '#ZThisZisZaZTest' + call setmatches(a) + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + call assert_equal({'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': a[0].id, 'conceal': 'Z'}, a[0]) + + quit! +endfunction + +function! Test_using_matchaddpos() + new + setlocal concealcursor=n conceallevel=1 + " set filetype and :syntax on to change screenattr() + setlocal filetype=conf + syntax on + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#Pis a Test' + + call cursor(1, 1) + call matchaddpos('Conceal', [[2,2,6]], 10, -1, {'conceal': 'P'}) + let a = getmatches() + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 2)) + call assert_notequal(screenattr(lnum, 2) , screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 10)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16)) + call assert_equal(screenattr(lnum, 12), screenattr(lnum, 16)) + call assert_equal({'group': 'Conceal', 'id': a[0].id, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'}, a[0]) + + syntax off + quit! +endfunction + +function! Test_matchadd_repeat_conceal_with_syntax_off() + new + + " To test targets in the same line string is replaced with conceal char + " correctly, repeat 'TARGET' + 1put ='TARGET_TARGETTARGET' + call cursor(1, 1) + redraw + call assert_equal('TARGET_TARGETTARGET', s:screenline(2)) + + setlocal conceallevel=2 + call matchadd('Conceal', 'TARGET', 10, -1, {'conceal': 't'}) + + redraw + call assert_equal('t_tt', s:screenline(2)) + + quit! +endfunction diff --git a/src/nvim/testdir/test_matchadd_conceal_utf8.vim b/src/nvim/testdir/test_matchadd_conceal_utf8.vim new file mode 100644 index 0000000000..24c848a99c --- /dev/null +++ b/src/nvim/testdir/test_matchadd_conceal_utf8.vim @@ -0,0 +1,39 @@ +" Test for matchadd() and conceal feature using utf-8. +if !has('conceal') || !has('multi_byte') + finish +endif + +function! s:screenline(lnum) abort + let line = [] + for c in range(1, winwidth(0)) + call add(line, nr2char(screenchar(a:lnum, c))) + endfor + return s:trim(join(line, '')) +endfunction + +function! s:trim(str) abort + return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') +endfunction + +function! Test_match_using_multibyte_conceal_char() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ˑThisˑisˑaˑTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + quit! +endfunction diff --git a/src/nvim/testdir/test_syn_attr.vim b/src/nvim/testdir/test_syn_attr.vim index 809442eb94..94d6b8735f 100644 --- a/src/nvim/testdir/test_syn_attr.vim +++ b/src/nvim/testdir/test_syn_attr.vim @@ -16,9 +16,13 @@ func Test_missing_attr() call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui')) if has('gui') - hi Mine guifg=blue guibg=red font=something + let fontname = getfontname() + if fontname == '' + let fontname = 'something' + endif + exe 'hi Mine guifg=blue guibg=red font=' . escape(fontname, ' \') call assert_equal('blue', synIDattr(hlID("Mine"), "fg", 'gui')) call assert_equal('red', synIDattr(hlID("Mine"), "bg", 'gui')) - call assert_equal('something', synIDattr(hlID("Mine"), "font", 'gui')) + call assert_equal(fontname, synIDattr(hlID("Mine"), "font", 'gui')) endif endfunc diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 04b5868d2c..f03d8b87fa 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -174,7 +174,7 @@ static void terminfo_stop(UI *ui) unibi_out(ui, data->unibi_ext.disable_bracketed_paste); // Disable focus reporting unibi_out(ui, data->unibi_ext.disable_focus_reporting); - flush_buf(ui); + flush_buf(ui, true); uv_tty_reset_mode(); uv_close((uv_handle_t *)&data->output_handle, NULL); uv_run(&data->write_loop, UV_RUN_DEFAULT); @@ -601,7 +601,7 @@ static void tui_flush(UI *ui) unibi_goto(ui, grid->row, grid->col); - flush_buf(ui); + flush_buf(ui, true); } static void suspend_event(void **argv) @@ -774,7 +774,7 @@ static void out(void *ctx, const char *str, size_t len) size_t available = data->bufsize - data->bufpos; if (len > available) { - flush_buf(ui); + flush_buf(ui, false); } memcpy(data->buf + data->bufpos, str, len); @@ -910,13 +910,13 @@ end: unibi_set_if_empty(ut, unibi_clr_eos, "\x1b[J"); } -static void flush_buf(UI *ui) +static void flush_buf(UI *ui, bool toggle_cursor) { uv_write_t req; uv_buf_t buf; TUIData *data = ui->data; - if (!data->busy) { + if (toggle_cursor && !data->busy) { // not busy and the cursor is invisible(see below). Append a "cursor // normal" command to the end of the buffer. data->bufsize += CNORM_COMMAND_MAX_SIZE; @@ -930,7 +930,7 @@ static void flush_buf(UI *ui) uv_run(&data->write_loop, UV_RUN_DEFAULT); data->bufpos = 0; - if (!data->busy) { + if (toggle_cursor && !data->busy) { // not busy and cursor is visible(see above), append a "cursor invisible" // command to the beginning of the buffer for the next flush unibi_out(ui, unibi_cursor_invisible); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 648d633e07..eb500414a7 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -397,14 +397,14 @@ static void send_output(uint8_t **ptr) size_t clen = (size_t)mb_ptr2len(p); UI_CALL(put, p, (size_t)clen); col++; - if (utf_ambiguous_width(*p)) { - pending_cursor_update = true; - flush_cursor_update(); - } else if (mb_ptr2cells(p) > 1) { + if (mb_ptr2cells(p) > 1) { // double cell character, blank the next cell UI_CALL(put, NULL, 0); col++; } + if (utf_ambiguous_width(utf_ptr2char(p))) { + pending_cursor_update = true; + } if (col >= width) { ui_linefeed(); } diff --git a/src/nvim/version.c b/src/nvim/version.c index a81d8f89c5..f4a81f223b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -122,7 +122,7 @@ static int included_patches[] = { // 2322, // 2321, // 2320, - // 2319, + // 2319 NA // 2318, // 2317, // 2316 NA @@ -163,11 +163,11 @@ static int included_patches[] = { // 2281 NA // 2280, // 2279, - // 2278, + // 2278 NA // 2277, // 2276, // 2275, - // 2274, + 2274, // 2273, // 2272, // 2271 NA @@ -209,7 +209,7 @@ static int included_patches[] = { // 2235, // 2234 NA // 2233, - // 2232, + // 2232 NA // 2231, // 2230, // 2229, @@ -326,7 +326,7 @@ static int included_patches[] = { // 2118 NA // 2117, // 2116 NA - // 2115, + // 2115 NA // 2114 NA // 2113, 2112, @@ -496,7 +496,7 @@ static int included_patches[] = { // 1948, // 1947 NA // 1946 NA - // 1945, + // 1945 NA // 1944 NA // 1943 NA // 1942 NA @@ -630,14 +630,14 @@ static int included_patches[] = { // 1814 NA // 1813, // 1812, - // 1811, + // 1811 NA // 1810 NA 1809, 1808, // 1807 NA 1806, - // 1805, - // 1804, + // 1805 NA + // 1804 NA // 1803 NA // 1802, // 1801 NA @@ -647,7 +647,7 @@ static int included_patches[] = { // 1797 NA // 1796 NA // 1795 NA - // 1794, + // 1794 NA // 1793, // 1792 NA // 1791 NA @@ -672,14 +672,14 @@ static int included_patches[] = { // 1773 NA // 1772 NA // 1771 NA - // 1770, + // 1770 NA // 1769, // 1768, // 1767 NA // 1766 NA 1765, // 1764 NA - // 1763, + 1763, // 1762, // 1761, // 1760 NA @@ -693,7 +693,7 @@ static int included_patches[] = { // 1753, // 1752, // 1751, - // 1750, + // 1750 NA // 1749 NA // 1748, // 1747 NA @@ -703,7 +703,7 @@ static int included_patches[] = { // 1743 NA // 1742, // 1741, - // 1740, + 1740, // 1739, // 1738, // 1737 NA @@ -790,7 +790,7 @@ static int included_patches[] = { // 1656, // 1655 NA 1654, - // 1653, + // 1653 NA 1652, // 1651 NA // 1650, @@ -894,7 +894,7 @@ static int included_patches[] = { 1552, 1551, 1550, - // 1549, + 1549, 1548, 1547, 1546, diff --git a/src/nvim/window.c b/src/nvim/window.c index e9a66ad907..0be586c606 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -482,7 +482,7 @@ wingotofile: } static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, - long Prenum) + int64_t Prenum) { size_t len = xstrlcpy((char *)bufp, cmd, bufsize); diff --git a/test/functional/ex_cmds/arg_spec.lua b/test/functional/ex_cmds/arg_spec.lua new file mode 100644 index 0000000000..e66dc62491 --- /dev/null +++ b/test/functional/ex_cmds/arg_spec.lua @@ -0,0 +1,30 @@ +local helpers = require("test.functional.helpers")(after_each) +local eq, execute, funcs = helpers.eq, helpers.execute, helpers.funcs +local ok = helpers.ok +local clear = helpers.clear + +describe(":argument", function() + before_each(function() + clear() + end) + + it("does not restart :terminal buffer", function() + execute("terminal") + helpers.feed([[<C-\><C-N>]]) + execute("argadd") + helpers.feed([[<C-\><C-N>]]) + local bufname_before = funcs.bufname("%") + local bufnr_before = funcs.bufnr("%") + helpers.ok(nil ~= string.find(bufname_before, "^term://")) -- sanity + + execute("argument 1") + helpers.feed([[<C-\><C-N>]]) + + local bufname_after = funcs.bufname("%") + local bufnr_after = funcs.bufnr("%") + eq("\n["..bufname_before.."] ", helpers.eval('execute("args")')) + ok(funcs.line('$') > 1) + eq(bufname_before, bufname_after) + eq(bufnr_before, bufnr_after) + end) +end) diff --git a/test/functional/ex_cmds/edit_spec.lua b/test/functional/ex_cmds/edit_spec.lua new file mode 100644 index 0000000000..9e197d7466 --- /dev/null +++ b/test/functional/ex_cmds/edit_spec.lua @@ -0,0 +1,26 @@ +local helpers = require("test.functional.helpers")(after_each) +local eq, execute, funcs = helpers.eq, helpers.execute, helpers.funcs +local ok = helpers.ok +local clear = helpers.clear + +describe(":edit", function() + before_each(function() + clear() + end) + + it("without arguments does not restart :terminal buffer", function() + execute("terminal") + helpers.feed([[<C-\><C-N>]]) + local bufname_before = funcs.bufname("%") + local bufnr_before = funcs.bufnr("%") + helpers.ok(nil ~= string.find(bufname_before, "^term://")) -- sanity + + execute("edit") + + local bufname_after = funcs.bufname("%") + local bufnr_after = funcs.bufnr("%") + ok(funcs.line('$') > 1) + eq(bufname_before, bufname_after) + eq(bufnr_before, bufnr_after) + end) +end) diff --git a/test/functional/legacy/match_conceal_spec.lua b/test/functional/legacy/match_conceal_spec.lua deleted file mode 100644 index d95b07d695..0000000000 --- a/test/functional/legacy/match_conceal_spec.lua +++ /dev/null @@ -1,228 +0,0 @@ --- Test for matchadd() and conceal feature - -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local expect = helpers.expect -local source = helpers.source - -describe('match_conceal', function() - before_each(function() - clear() - - source([[ - set wildchar=^E - 10new - vsp - vert resize 20 - put =\"\#\ This\ is\ a\ Test\" - norm! mazt - - fu! ScreenChar(width, lines) - let c='' - for j in range(1,a:lines) - for i in range(1,a:width) - let c.=nr2char(screenchar(j, i)) - endfor - let c.="\n" - endfor - return c - endfu - - fu! ScreenAttr(line, pos, eval) - let g:attr=[] - for col in a:pos - call add(g:attr, screenattr(a:line,col)) - endfor - " In case all values are zero, probably the terminal - " isn't set correctly, so catch that case - let null = (eval(join(g:attr, '+')) == 0) - let str=substitute(a:eval, '\d\+', 'g:attr[&]', 'g') - if null || eval(str) - let g:attr_test="OK: ". str - else - let g:attr_test="FAILED: ".str - let g:attr_test.="\n". join(g:attr, ' ') - let g:attr_test.="\n TERM: ". &term - endif - endfu - - fu! DoRecordScreen() - wincmd l - $put =printf(\"\n%s\", g:test) - $put =g:line - $put =g:attr_test - wincmd p - endfu - ]]) - end) - - it('is working', function() - source([=[ - let g:test ="Test 1: simple addmatch()" - call matchadd('Conceal', '\%2l ') - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - - let g:test ="Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest)" - norm! 'azt - call clearmatches() - syntax on - set concealcursor=n conceallevel=1 - call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - - let g:test ="Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest)" - norm! 'azt - set conceallevel=3 - call clearmatches() - call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 1==3 && 1==4 && 0!=5") - call DoRecordScreen() - - let g:test ="Test 4: more match() (should be: #Thisisa Test)" - norm! 'azt - call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'}) - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 0!=3 && 3==4 && 0!=5 && 3!=5") - call DoRecordScreen() - - let g:test ="Test 5/1: default conceal char (should be: # This is a Test)" - norm! 'azt - call clearmatches() - set conceallevel=1 - call matchadd('Conceal', '\%2l ', 10, -1, {}) - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - let g:test ="Test 5/2: default conceal char (should be: #+This+is+a+Test)" - norm! 'azt - set listchars=conceal:+ - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - set listchars&vi - - let g:test ="Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest)" - norm! 'azt - call clearmatches() - set conceallevel=1 - call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) - syn match MyConceal /\%2l / conceal containedin=ALL cchar=* - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - let g:test ="Test 6/2: syn and match conceal (should be: #*This*is*a*Test)" - norm! 'azt - call clearmatches() - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - - let g:test ="Test 7/1: clear matches" - norm! 'azt - syn on - call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) - let a=getmatches() - call clearmatches() - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 0==2 && 0==3 && 0==4 && 0==5") - call DoRecordScreen() - $put =a - call setmatches(a) - norm! 'azt - let g:test ="Test 7/2: reset match using setmatches()" - norm! 'azt - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - - let g:test ="Test 8: using matchaddpos() (should be #Pis a Test" - norm! 'azt - call clearmatches() - call matchaddpos('Conceal', [[2,2,6]], 10, -1, {'conceal': 'P'}) - let a=getmatches() - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1!=2 && 0==2 && 0==3 && 0!=4 && 0!=5 && 4==5") - call DoRecordScreen() - $put =a - - let g:test ="Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest)" - norm! 'azt - call clearmatches() - call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) - redraw! - let line=ScreenChar(winwidth(0),1) - call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") - call DoRecordScreen() - ]=]) - - expect([=[ - - # This is a Test - - Test 1: simple addmatch() - # This is a Test - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest) - #XThisXisXaXTest - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest) - #ThisisaTest - OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]!=g:attr[5] - - Test 4: more match() (should be: #Thisisa Test) - #Thisisa Test - OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[0]!=g:attr[3] && g:attr[3]==g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[3]!=g:attr[5] - - Test 5/1: default conceal char (should be: # This is a Test) - # This is a Test - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 5/2: default conceal char (should be: #+This+is+a+Test) - #+This+is+a+Test - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest) - #ZThisZisZaZTest - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 6/2: syn and match conceal (should be: #*This*is*a*Test) - #*This*is*a*Test - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 7/1: clear matches - # This is a Test - OK: g:attr[0]==g:attr[1] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]==g:attr[4] && g:attr[0]==g:attr[5] - {'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': 10, 'conceal': 'Z'} - - Test 7/2: reset match using setmatches() - #ZThisZisZaZTest - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - - Test 8: using matchaddpos() (should be #Pis a Test - #Pis a Test - OK: g:attr[0]!=g:attr[1] && g:attr[1]!=g:attr[2] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]!=g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[4]==g:attr[5] - {'group': 'Conceal', 'id': 11, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'} - - Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest) - #ˑThisˑisˑaˑTest - OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5]]=]) - end) -end) diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua index 9902b101f6..1dfc4c17ba 100644 --- a/test/functional/legacy/undolevels_spec.lua +++ b/test/functional/legacy/undolevels_spec.lua @@ -10,7 +10,7 @@ describe('undolevel', function() func FillBuffer() for i in range(1,13) put=i - " Set 'undolevels' to split undo. + " Set 'undolevels' to split undo. exe "setg ul=" . &g:ul endfor endfunc @@ -48,6 +48,10 @@ describe('undolevel', function() call assert_equal(50, &g:undolevels) call assert_equal(-123456, &l:undolevels) + " Drop created windows + set ul& + new + only! endfunc call Test_global_local_undolevels() diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 6f929f17e4..09b4eaa8d5 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -13,13 +13,19 @@ describe(':terminal', function() clear() screen = Screen.new(50, 4) screen:attach({rgb=false}) + -- shell-test.c is a fake shell that prints its arguments and exits. nvim('set_option', 'shell', nvim_dir..'/shell-test') nvim('set_option', 'shellcmdflag', 'EXE') - end) + -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints + -- the {cmd} and exits immediately . + local function terminal_run_fake_shell_cmd(cmd) + execute("terminal "..(cmd and cmd or "")) + end + it('with no argument, acts like termopen()', function() - execute('terminal') + terminal_run_fake_shell_cmd() wait() screen:expect([[ ready $ | @@ -30,7 +36,7 @@ describe(':terminal', function() end) it('executes a given command through the shell', function() - execute('terminal echo hi') + terminal_run_fake_shell_cmd('echo hi') wait() screen:expect([[ ready $ echo hi | @@ -41,7 +47,7 @@ describe(':terminal', function() end) it('allows quotes and slashes', function() - execute([[terminal echo 'hello' \ "world"]]) + terminal_run_fake_shell_cmd([[echo 'hello' \ "world"]]) wait() screen:expect([[ ready $ echo 'hello' \ "world" | @@ -58,4 +64,16 @@ describe(':terminal', function() -- Verify that BufNew actually fired (else the test is invalid). eq('foo', eval('&shell')) end) + + it('ignores writes if the backing stream closes', function() + terminal_run_fake_shell_cmd() + helpers.feed('iiXXXXXXX') + wait() + -- Race: Though the shell exited (and streams were closed by SIGCHLD + -- handler), :terminal cleanup is pending on the main-loop. + -- This write should be ignored (not crash, #5445). + helpers.feed('iiYYYYYYY') + wait() + end) + end) |