diff options
181 files changed, 1702 insertions, 1235 deletions
diff --git a/cmake.config/CMakeLists.txt b/cmake.config/CMakeLists.txt index f3cc803cf5..d30c522aa2 100644 --- a/cmake.config/CMakeLists.txt +++ b/cmake.config/CMakeLists.txt @@ -79,6 +79,17 @@ int main(void) } " HAVE_PWD_FUNCS) +check_c_source_compiles(" +#include <intrin.h> + +int main(void) +{ + unsigned long index; + unsigned char mask = 0x8000; + _BitScanForward64(&index, mask); + return 0; +} +" HAVE_BITSCANFORWARD64) if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") check_c_source_compiles(" diff --git a/cmake.config/config.h.in b/cmake.config/config.h.in index 47fbb5bafe..af4e13fc11 100644 --- a/cmake.config/config.h.in +++ b/cmake.config/config.h.in @@ -52,3 +52,4 @@ #cmakedefine HAVE_EXECINFO_BACKTRACE #cmakedefine HAVE_BUILTIN_ADD_OVERFLOW #cmakedefine HAVE_WIMPLICIT_FALLTHROUGH_FLAG +#cmakedefine HAVE_BITSCANFORWARD64 diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt index a6d44ca752..84f2500247 100644 --- a/cmake.deps/deps.txt +++ b/cmake.deps/deps.txt @@ -1,8 +1,8 @@ LIBUV_URL https://github.com/libuv/libuv/archive/v1.48.0.tar.gz LIBUV_SHA256 8c253adb0f800926a6cbd1c6576abae0bc8eb86a4f891049b72f9e5b7dc58f33 -MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/c-6.0.0.tar.gz -MSGPACK_SHA256 af6f3cf25edb220aa2140b09bb5bdd73ddf00938194bd94ebe5c92090cccb466 +MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/c-6.0.1.tar.gz +MSGPACK_SHA256 58d5fe49d0ee2b374d60a61aabf8028b2c92004e6f11bff04e74b639fc8ad541 LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/d06beb0480c5d1eb53b3343e78063950275aa281.tar.gz LUAJIT_SHA256 6abd146a1dfa240a965748f63221633446affa2a715e3eb03879136e3efb95f4 @@ -55,7 +55,7 @@ TREESITTER_PYTHON_URL https://github.com/tree-sitter/tree-sitter-python/archive/ TREESITTER_PYTHON_SHA256 720304a603271fa89e4430a14d6a81a023d6d7d1171b1533e49c0ab44f1e1c13 TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.21.0.tar.gz TREESITTER_BASH_SHA256 f0515efda839cfede851adb24ac154227fbc0dfb60c6c11595ecfa9087d43ceb -TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.1.tar.gz -TREESITTER_MARKDOWN_SHA256 d5dee1f57807a633062d03e19ad59d9b5e28f882da1ebe69a2e31f1df5b308ca +TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.3.tar.gz +TREESITTER_MARKDOWN_SHA256 4909d6023643f1afc3ab219585d4035b7403f3a17849782ab803c5f73c8a31d5 TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.2.tar.gz TREESITTER_SHA256 0c829523b876d4a37e1bd46a655c133a93669c0fe98fcd84972b168849c27afc diff --git a/runtime/compiler/ant.vim b/runtime/compiler/ant.vim index 0605c69fab..6219b01c36 100644 --- a/runtime/compiler/ant.vim +++ b/runtime/compiler/ant.vim @@ -2,16 +2,13 @@ " Compiler: ant " Maintainer: Johannes Zellner <johannes@zellner.org> " Last Change: Mi, 13 Apr 2005 22:50:07 CEST +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "ant" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/bcc.vim b/runtime/compiler/bcc.vim index 5bd284a581..2d9d4fbb36 100644 --- a/runtime/compiler/bcc.vim +++ b/runtime/compiler/bcc.vim @@ -2,16 +2,13 @@ " Compiler: bcc - Borland C " Maintainer: Emile van Raaij (eraaij@xs4all.nl) " Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "bcc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " A workable errorformat for Borland C CompilerSet errorformat=%*[^0-9]%n\ %f\ %l:\ %m diff --git a/runtime/compiler/bdf.vim b/runtime/compiler/bdf.vim index 7e08cdddaa..2aaa93bc27 100644 --- a/runtime/compiler/bdf.vim +++ b/runtime/compiler/bdf.vim @@ -3,6 +3,7 @@ " Previous Maintainer: Nikolai Weibull <now@bitwi.se> " Contributors: Enno Nagel " Last Change: 2024 Mar 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -12,10 +13,6 @@ let current_compiler = "bdf" let s:cpo_save = &cpo set cpo-=C -if exists(":CompilerSet") != 2 " Older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=bdftopcf\ $* CompilerSet errorformat=%ABDF\ %trror\ on\ line\ %l:\ %m, \%-Z%p^, diff --git a/runtime/compiler/cargo.vim b/runtime/compiler/cargo.vim index aa9b01e93c..bbea45dee7 100644 --- a/runtime/compiler/cargo.vim +++ b/runtime/compiler/cargo.vim @@ -2,6 +2,7 @@ " Compiler: Cargo Compiler " Maintainer: Damien Radtke <damienradtke@gmail.com> " Latest Revision: 2023-09-11 +" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) " For bugs, patches and license go to https://github.com/rust-lang/rust.vim if exists('current_compiler') @@ -15,10 +16,6 @@ let s:save_cpo = &cpo set cpo&vim " vint: +ProhibitAbbreviationOption -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if exists('g:cargo_makeprg_params') execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*' else diff --git a/runtime/compiler/checkstyle.vim b/runtime/compiler/checkstyle.vim index 4ebd9e15b5..3c17ee45bf 100644 --- a/runtime/compiler/checkstyle.vim +++ b/runtime/compiler/checkstyle.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Checkstyle " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Aug 2 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "checkstyle" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/cm3.vim b/runtime/compiler/cm3.vim index 3de51282e6..0ec360855c 100644 --- a/runtime/compiler/cm3.vim +++ b/runtime/compiler/cm3.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Critical Mass Modula-3 Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2021 Apr 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "cm3" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/context.vim b/runtime/compiler/context.vim index cb78c96df0..3d626ffa60 100644 --- a/runtime/compiler/context.vim +++ b/runtime/compiler/context.vim @@ -9,10 +9,6 @@ endif let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " If makefile exists and we are not asked to ignore it, we use standard make " (do not redefine makeprg) if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) || @@ -20,11 +16,12 @@ if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) || let current_compiler = 'context' " The following assumes that the current working directory is set to the " directory of the file to be typeset - let &l:makeprg = get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun')) + let s:makeprg = get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun')) \ . ' --script context --autogenerate --nonstopmode --synctex=' \ . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0') \ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', '')) \ . ' ' . shellescape(expand('%:p:t')) + execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ') else let current_compiler = 'make' endif diff --git a/runtime/compiler/cs.vim b/runtime/compiler/cs.vim index 4f6dd3cdfd..123dff854f 100644 --- a/runtime/compiler/cs.vim +++ b/runtime/compiler/cs.vim @@ -3,6 +3,7 @@ " Maintainer: Yichao Zhou (broken.zhou@gmail.com) " Previous Maintainer: Joseph H. Yao (hyao@sina.com) " Last Change: Jul 22, 2019 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -11,10 +12,6 @@ let current_compiler = "cs" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat& CompilerSet errorformat+=%f(%l\\,%v):\ %t%*[^:]:\ %m, \%trror%*[^:]:\ %m, diff --git a/runtime/compiler/csslint.vim b/runtime/compiler/csslint.vim index 14c4289a24..608cc74864 100644 --- a/runtime/compiler/csslint.vim +++ b/runtime/compiler/csslint.vim @@ -1,16 +1,13 @@ " Vim compiler file " Compiler: csslint for CSS -" Maintainer: Daniel Moch <daniel@danielmoch.com> -" Last Change: 2016 May 21 +" Maintainer: Daniel Moch <daniel@danielmoch.com> +" Last Change: 2016 May 21 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "csslint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=csslint\ --format=compact CompilerSet errorformat=%-G,%-G%f:\ lint\ free!,%f:\ line\ %l\\,\ col\ %c\\,\ %trror\ -\ %m,%f:\ line\ %l\\,\ col\ %c\\,\ %tarning\ -\ %m,%f:\ line\ %l\\,\ col\ %c\\,\ %m diff --git a/runtime/compiler/cucumber.vim b/runtime/compiler/cucumber.vim index 17ce3627c1..8089a5ee5c 100644 --- a/runtime/compiler/cucumber.vim +++ b/runtime/compiler/cucumber.vim @@ -2,16 +2,13 @@ " Compiler: Cucumber " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Last Change: 2016 Aug 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "cucumber" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/dart.vim b/runtime/compiler/dart.vim index f9ebfe1b27..9577236bee 100644 --- a/runtime/compiler/dart.vim +++ b/runtime/compiler/dart.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart VM " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dart" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dart2js.vim b/runtime/compiler/dart2js.vim index b6a4e4d530..a05dead2a9 100644 --- a/runtime/compiler/dart2js.vim +++ b/runtime/compiler/dart2js.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart to JavaScript Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dart2js" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dart2native.vim b/runtime/compiler/dart2native.vim index 51bdab0cc3..6604fc4bd4 100644 --- a/runtime/compiler/dart2native.vim +++ b/runtime/compiler/dart2native.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart to Native Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dart2native" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dartanalyser.vim b/runtime/compiler/dartanalyser.vim index e691d80b61..48a976a016 100644 --- a/runtime/compiler/dartanalyser.vim +++ b/runtime/compiler/dartanalyser.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart Analyzer " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dartanalyzer" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dartdevc.vim b/runtime/compiler/dartdevc.vim index e8d1988ed6..16e4ed7ced 100644 --- a/runtime/compiler/dartdevc.vim +++ b/runtime/compiler/dartdevc.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart Development Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dartdevc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dartdoc.vim b/runtime/compiler/dartdoc.vim index 26b38d8dd4..78f0d241a4 100644 --- a/runtime/compiler/dartdoc.vim +++ b/runtime/compiler/dartdoc.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart Documentation Generator " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dartdoc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/dartfmt.vim b/runtime/compiler/dartfmt.vim index 2e4ab02ad3..d204df8a73 100644 --- a/runtime/compiler/dartfmt.vim +++ b/runtime/compiler/dartfmt.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Dart Formatter " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 May 08 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "dartfmt" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/decada.vim b/runtime/compiler/decada.vim index 0bf5487c89..11b0cb412a 100644 --- a/runtime/compiler/decada.vim +++ b/runtime/compiler/decada.vim @@ -14,6 +14,7 @@ " 08.09.2006 MK Correct double load protection. " Help Page: compiler-decada "------------------------------------------------------------------------------ +" Last Change: 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if (exists("current_compiler") && current_compiler == "decada") || version < 700 finish @@ -34,13 +35,6 @@ if !exists("g:decada") call g:decada.Set_Session () endif -if exists(":CompilerSet") != 2 - " - " plugin loaded by other means then the "compiler" command - " - command -nargs=* CompilerSet setlocal <args> -endif - execute "CompilerSet makeprg=" . escape (g:decada.Make_Command, ' ') execute "CompilerSet errorformat=" . escape (g:decada.Error_Format, ' ') diff --git a/runtime/compiler/dot.vim b/runtime/compiler/dot.vim index 773a6fb269..145411ebd3 100644 --- a/runtime/compiler/dot.vim +++ b/runtime/compiler/dot.vim @@ -2,16 +2,13 @@ " Compiler: ATT dot " Maintainer: Marcos Macedo <bar4ka@bol.com.br> " Last Change: 2024 March 21 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "dot" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=dot\ -T$*\ \"%:p\"\ -o\ \"%:p:r.$*\" " matches error messages as below skipping final part after line number " Error: ./file.dot: syntax error in line 1 near 'rankdir' diff --git a/runtime/compiler/dotnet.vim b/runtime/compiler/dotnet.vim index ac64084663..1290357221 100644 --- a/runtime/compiler/dotnet.vim +++ b/runtime/compiler/dotnet.vim @@ -2,6 +2,7 @@ " Compiler: dotnet build (.NET CLI) " Maintainer: Nick Jensen <nickspoon@gmail.com> " Last Change: 2022-12-06 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " License: Vim (see :h license) " Repository: https://github.com/nickspoons/vim-cs @@ -10,10 +11,6 @@ if exists("current_compiler") endif let current_compiler = "dotnet" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/erlang.vim b/runtime/compiler/erlang.vim index e22887e05e..b30b5c11e7 100644 --- a/runtime/compiler/erlang.vim +++ b/runtime/compiler/erlang.vim @@ -2,6 +2,7 @@ " Compiler: Erlang " Maintainer: Dmitry Vasiliev <dima at hlabs dot org> " Last Change: 2019 Jul 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish diff --git a/runtime/compiler/eruby.vim b/runtime/compiler/eruby.vim index a81a3f3b77..815d082f86 100644 --- a/runtime/compiler/eruby.vim +++ b/runtime/compiler/eruby.vim @@ -3,17 +3,13 @@ " Maintainer: Doug Kearns <dougkearns@gmail.com> " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2018 Jan 25 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "eruby" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/eslint.vim b/runtime/compiler/eslint.vim index 7d57acbdf4..db7a665991 100644 --- a/runtime/compiler/eslint.vim +++ b/runtime/compiler/eslint.vim @@ -2,15 +2,12 @@ " Compiler: ESLint for JavaScript " Maintainer: Romain Lafourcade <romainlafourcade@gmail.com> " Last Change: 2020 August 20 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "eslint" -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=npx\ eslint\ --format\ compact CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%# diff --git a/runtime/compiler/fbc.vim b/runtime/compiler/fbc.vim index 1c29392da8..afedc32dff 100644 --- a/runtime/compiler/fbc.vim +++ b/runtime/compiler/fbc.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: FreeBASIC Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2015 Jan 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "fbc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/fortran_F.vim b/runtime/compiler/fortran_F.vim index d9cb47cc1f..7f6ec818e0 100644 --- a/runtime/compiler/fortran_F.vim +++ b/runtime/compiler/fortran_F.vim @@ -3,17 +3,14 @@ " URL: http://www.unb.ca/chem/ajit/compiler/fortran_F.vim " Maintainer: Ajit J. Thakkar (ajit AT unb.ca); <http://www.unb.ca/chem/ajit/> " Version: 0.2 -" Last Change: 2004 Mar 27 +" Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "fortran_F" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cposet=&cpoptions set cpoptions-=C diff --git a/runtime/compiler/fortran_cv.vim b/runtime/compiler/fortran_cv.vim index bc217bdc66..ea46d99af4 100644 --- a/runtime/compiler/fortran_cv.vim +++ b/runtime/compiler/fortran_cv.vim @@ -2,16 +2,13 @@ " Compiler: Compaq Visual Fortran " Maintainer: Joh.-G. Simon (johann-guenter.simon@linde-le.com) " Last Change: 11/05/2002 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "fortran_cv" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cposet = &cpoptions set cpoptions-=C diff --git a/runtime/compiler/fortran_elf90.vim b/runtime/compiler/fortran_elf90.vim index 34c33cfaf8..903701e8e6 100644 --- a/runtime/compiler/fortran_elf90.vim +++ b/runtime/compiler/fortran_elf90.vim @@ -4,17 +4,14 @@ " URL: http://www.unb.ca/chem/ajit/compiler/fortran_elf90.vim " Maintainer: Ajit J. Thakkar (ajit AT unb.ca); <http://www.unb.ca/chem/ajit/> " Version: 0.2 -" Last Change: 2004 Mar 27 +" Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "fortran_elf90" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cposet=&cpoptions set cpoptions-=C diff --git a/runtime/compiler/fortran_g77.vim b/runtime/compiler/fortran_g77.vim index 744ce6a334..dcac2a7c9a 100644 --- a/runtime/compiler/fortran_g77.vim +++ b/runtime/compiler/fortran_g77.vim @@ -2,6 +2,7 @@ " Compiler: g77 (GNU Fortran) " Maintainer: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> " Last Change: $Date: 2004/06/13 18:17:36 $ +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " $Revision: 1.1 $ if exists("current_compiler") @@ -9,10 +10,6 @@ if exists("current_compiler") endif let current_compiler = "fortran_g77" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/fortran_lf95.vim b/runtime/compiler/fortran_lf95.vim index 685fee7b4a..2cb71589b2 100644 --- a/runtime/compiler/fortran_lf95.vim +++ b/runtime/compiler/fortran_lf95.vim @@ -3,17 +3,14 @@ " URL: http://www.unb.ca/chem/ajit/compiler/fortran_lf95.vim " Maintainer: Ajit J. Thakkar (ajit AT unb.ca); <http://www.unb.ca/chem/ajit/> " Version: 0.2 -" Last Change: 2004 Mar 27 +" Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "fortran_lf95" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cposet=&cpoptions set cpoptions-=C diff --git a/runtime/compiler/fpc.vim b/runtime/compiler/fpc.vim index de8e2fe3dc..0d321ab4c7 100644 --- a/runtime/compiler/fpc.vim +++ b/runtime/compiler/fpc.vim @@ -2,16 +2,13 @@ " Compiler: FPC 2.1 " Maintainer: Jaroslaw Blasiok <jaro3000@o2.pl> " Last Change: 2005 October 07 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "fpc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " NOTE: compiler must be run with -vb to write whole source path, not only file " name. CompilerSet errorformat=%f(%l\\,%c)\ %m diff --git a/runtime/compiler/g95.vim b/runtime/compiler/g95.vim index ecb3212cbe..e0b3a688f2 100644 --- a/runtime/compiler/g95.vim +++ b/runtime/compiler/g95.vim @@ -2,6 +2,7 @@ " Maintainer: H Xu <xuhdev@gmail.com> " Version: 0.1.3 " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " Homepage: http://www.vim.org/scripts/script.php?script_id=3492 " https://bitbucket.org/xuhdev/compiler-g95.vim " License: Same as Vim @@ -13,10 +14,6 @@ let current_compiler = 'g95' let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat= \%AIn\ file\ %f:%l, \%-C%p1, diff --git a/runtime/compiler/gawk.vim b/runtime/compiler/gawk.vim index a109eb8642..f2a360d5f3 100644 --- a/runtime/compiler/gawk.vim +++ b/runtime/compiler/gawk.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: GNU Awk " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "gawk" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/gcc.vim b/runtime/compiler/gcc.vim index 30e5149f9f..7b6ebb98f4 100644 --- a/runtime/compiler/gcc.vim +++ b/runtime/compiler/gcc.vim @@ -1,10 +1,11 @@ " Vim compiler file -" Compiler: GNU C Compiler -" Previous Maintainer: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2010-10-14 -" changed pattern for entering/leaving directories -" by Daniel Hahler, 2019 Jul 12 -" added line suggested by Anton Lindqvist 2016 Mar 31 +" Compiler: GNU C Compiler +" Previous Maintainer: Nikolai Weibull <now@bitwi.se> +" Last Change: 2010 Oct 14 +" changed pattern for entering/leaving directories +" by Daniel Hahler, 2019 Jul 12 +" added line suggested by Anton Lindqvist 2016 Mar 31 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish diff --git a/runtime/compiler/gfortran.vim b/runtime/compiler/gfortran.vim index 1e4e5cf4f4..1fea3bcb18 100644 --- a/runtime/compiler/gfortran.vim +++ b/runtime/compiler/gfortran.vim @@ -2,6 +2,7 @@ " Maintainer: H Xu <xuhdev@gmail.com> " Version: 0.1.3 " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " Homepage: http://www.vim.org/scripts/script.php?script_id=3496 " https://bitbucket.org/xuhdev/compiler-gfortran.vim " License: Same as Vim @@ -13,10 +14,6 @@ let current_compiler = 'gfortran' let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat= \%A%f:%l.%c:, \%-Z%trror:\ %m, diff --git a/runtime/compiler/gjs.vim b/runtime/compiler/gjs.vim index e033764030..b1be8cf3e6 100644 --- a/runtime/compiler/gjs.vim +++ b/runtime/compiler/gjs.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: GJS (Gnome JavaScript Bindings) " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "gjs" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/gm2.vim b/runtime/compiler/gm2.vim index 5053912200..954da9d0e7 100644 --- a/runtime/compiler/gm2.vim +++ b/runtime/compiler/gm2.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: GNU Modula-2 Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2024 Jan 04 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "gm2" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/gnat.vim b/runtime/compiler/gnat.vim index 3ad1eb4e3f..086edbede3 100644 --- a/runtime/compiler/gnat.vim +++ b/runtime/compiler/gnat.vim @@ -52,13 +52,6 @@ if !exists("g:gnat") call g:gnat.Set_Session () endif -if exists(":CompilerSet") != 2 - " - " plugin loaded by other means then the "compiler" command - " - command -nargs=* CompilerSet setlocal <args> -endif - execute "CompilerSet makeprg=" . escape (g:gnat.Get_Command('Make'), ' ') execute "CompilerSet errorformat=" . escape (g:gnat.Error_Format, ' ') diff --git a/runtime/compiler/go.vim b/runtime/compiler/go.vim index cf638f23d6..9c1a6f3119 100644 --- a/runtime/compiler/go.vim +++ b/runtime/compiler/go.vim @@ -2,16 +2,13 @@ " Compiler: Go " Maintainer: David Barnett (https://github.com/google/vim-ft-go) " Last Change: 2014 Aug 16 +" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists('current_compiler') finish endif let current_compiler = 'go' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - let s:save_cpo = &cpo set cpo-=C diff --git a/runtime/compiler/haml.vim b/runtime/compiler/haml.vim index 9464c3dc85..99c171d76c 100644 --- a/runtime/compiler/haml.vim +++ b/runtime/compiler/haml.vim @@ -2,16 +2,13 @@ " Compiler: Haml " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Last Change: 2016 Aug 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "haml" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/hare.vim b/runtime/compiler/hare.vim index c0fa68cc00..c98bbb9c63 100644 --- a/runtime/compiler/hare.vim +++ b/runtime/compiler/hare.vim @@ -2,6 +2,7 @@ " Compiler: Hare Compiler " Maintainer: Amelia Clarke <me@rsaihe.dev> " Last Change: 2022-09-21 +" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists("g:current_compiler") finish @@ -11,10 +12,6 @@ let g:current_compiler = "hare" let s:cpo_save = &cpo set cpo&vim -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if filereadable("Makefile") || filereadable("makefile") CompilerSet makeprg=make else diff --git a/runtime/compiler/hp_acc.vim b/runtime/compiler/hp_acc.vim index 15d5ce5f19..f6ccc57c73 100644 --- a/runtime/compiler/hp_acc.vim +++ b/runtime/compiler/hp_acc.vim @@ -3,6 +3,7 @@ " Maintainer: Matthias Ulrich <matthias-ulrich@web.de> " URL: http://www.subhome.de/vim/hp_acc.vim " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " " aCC --version says: "HP ANSI C++ B3910B A.03.13" " This compiler has been tested on: @@ -22,10 +23,6 @@ let current_compiler = "hp_acc" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%A%trror\ %n\:\ \"%f\"\\,\ line\ %l\ \#\ %m, \%A%tarning\ (suggestion)\ %n\:\ \"%f\"\\,\ line\ %l\ \#\ %m\ %#, \%A%tarning\ %n\:\ \"%f\"\\,\ line\ %l\ \#\ %m\ %#, diff --git a/runtime/compiler/icc.vim b/runtime/compiler/icc.vim index 751fba65c7..37958f1c94 100644 --- a/runtime/compiler/icc.vim +++ b/runtime/compiler/icc.vim @@ -2,16 +2,13 @@ " Compiler: icc - Intel C++ " Maintainer: Peter Puck <PtrPck@netscape.net> " Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "icc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " I think that Intel is calling the compiler icl under Windows CompilerSet errorformat=%-Z%p^,%f(%l):\ remark\ #%n:%m,%f(%l)\ :\ (col.\ %c)\ remark:\ %m,%E%f(%l):\ error:\ %m,%E%f(%l):\ error:\ #%n:\ %m,%W%f(%l):\ warning\ #%n:\ %m,%W%f(%l):\ warning:\ %m,%-C%.%# diff --git a/runtime/compiler/icon.vim b/runtime/compiler/icon.vim index 40f67930f7..8b46af2a13 100644 --- a/runtime/compiler/icon.vim +++ b/runtime/compiler/icon.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Icon Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2022 Jun 16 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "icont" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/ifort.vim b/runtime/compiler/ifort.vim index 3a60d0cd12..8c58ba685d 100644 --- a/runtime/compiler/ifort.vim +++ b/runtime/compiler/ifort.vim @@ -2,6 +2,7 @@ " Maintainer: H Xu <xuhdev@gmail.com> " Version: 0.1.1 " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " Homepage: http://www.vim.org/scripts/script.php?script_id=3497 " https://bitbucket.org/xuhdev/compiler-ifort.vim " License: Same as Vim @@ -13,10 +14,6 @@ let current_compiler = 'ifort' let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat= \%A%f(%l):\ %trror\ \#%n:\ %m, \%A%f(%l):\ %tarning\ \#%n:\ %m, diff --git a/runtime/compiler/intel.vim b/runtime/compiler/intel.vim index 254d13b6d8..cde62b1c48 100644 --- a/runtime/compiler/intel.vim +++ b/runtime/compiler/intel.vim @@ -2,6 +2,7 @@ " Compiler: Intel C++ 7.1 " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "intel" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%E%f(%l):\ error:\ %m, \%W%f(%l):\ warning:\ %m, \%I%f(%l):\ remark\ #%n:\ %m, diff --git a/runtime/compiler/irix5_c.vim b/runtime/compiler/irix5_c.vim index f440e74f05..f70bfb1ea7 100644 --- a/runtime/compiler/irix5_c.vim +++ b/runtime/compiler/irix5_c.vim @@ -2,6 +2,7 @@ " Compiler: SGI IRIX 5.3 cc " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "irix5_c" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=\%Ecfe:\ Error:\ %f\\,\ line\ %l:\ %m, \%Wcfe:\ Warning:\ %n:\ %f\\,\ line\ %l:\ %m, \%Wcfe:\ Warning\ %n:\ %f\\,\ line\ %l:\ %m, diff --git a/runtime/compiler/irix5_cpp.vim b/runtime/compiler/irix5_cpp.vim index 0112dc1cbc..85ab8c67f2 100644 --- a/runtime/compiler/irix5_cpp.vim +++ b/runtime/compiler/irix5_cpp.vim @@ -2,6 +2,7 @@ " Compiler: SGI IRIX 5.3 CC or NCC " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "irix5_cpp" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%E\"%f\"\\,\ line\ %l:\ error(%n):\ , \%E\"%f\"\\,\ line\ %l:\ error(%n):\ %m, \%W\"%f\"\\,\ line\ %l:\ warning(%n):\ %m, diff --git a/runtime/compiler/javac.vim b/runtime/compiler/javac.vim index 8507efd67c..f5fe84124f 100644 --- a/runtime/compiler/javac.vim +++ b/runtime/compiler/javac.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Java Development Kit Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Oct 21 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "javac" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/jest.vim b/runtime/compiler/jest.vim index a4bb549de1..663123c30f 100644 --- a/runtime/compiler/jest.vim +++ b/runtime/compiler/jest.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Jest " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2021 Nov 20 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "jest" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/jikes.vim b/runtime/compiler/jikes.vim index 2d4500e894..f12c2cf5f1 100644 --- a/runtime/compiler/jikes.vim +++ b/runtime/compiler/jikes.vim @@ -2,6 +2,7 @@ " Compiler: Jikes " Maintainer: Dan Sharp <dwsharp at hotmail dot com> " Last Change: 2019 Jul 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " URL: http://dwsharp.users.sourceforge.net/vim/compiler if exists("current_compiler") @@ -9,10 +10,6 @@ if exists("current_compiler") endif let current_compiler = "jikes" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " Jikes defaults to printing output on stderr CompilerSet makeprg=jikes\ -Xstdout\ +E\ \"%:S\" CompilerSet errorformat=%f:%l:%v:%*\\d:%*\\d:%*\\s%m diff --git a/runtime/compiler/jjs.vim b/runtime/compiler/jjs.vim index 09a973683a..543d9ca3d4 100644 --- a/runtime/compiler/jjs.vim +++ b/runtime/compiler/jjs.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Nashorn Shell " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2018 Jan 9 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "jjs" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/jshint.vim b/runtime/compiler/jshint.vim index 865591cd2b..9879ef49e5 100644 --- a/runtime/compiler/jshint.vim +++ b/runtime/compiler/jshint.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: JSHint " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "jshint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/jsonlint.vim b/runtime/compiler/jsonlint.vim index 5466dcc7f4..6283b1b01f 100644 --- a/runtime/compiler/jsonlint.vim +++ b/runtime/compiler/jsonlint.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: JSON Lint " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "jsonlint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/mcs.vim b/runtime/compiler/mcs.vim index 94a1848d4a..0c265b3de5 100644 --- a/runtime/compiler/mcs.vim +++ b/runtime/compiler/mcs.vim @@ -3,6 +3,7 @@ " Maintainer: Jarek Sobiecki <harijari@go2.pl> " Contributors: Peter Collingbourne and Enno Nagel " Last Change: 2024 Mar 29 +" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -12,10 +13,6 @@ let current_compiler = "mcs" let s:cpo_save = &cpo set cpo-=C -if exists(":CompilerSet") != 2 " Older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=mcs CompilerSet errorformat= \%D%.%#Project\ \"%f/%[%^/\"]%#\"%.%#, diff --git a/runtime/compiler/mips_c.vim b/runtime/compiler/mips_c.vim index a0ebfe7ba2..544f314a1a 100644 --- a/runtime/compiler/mips_c.vim +++ b/runtime/compiler/mips_c.vim @@ -2,6 +2,7 @@ " Compiler: SGI IRIX 6.5 MIPS C (cc) " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "mips_c" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%Ecc\-%n\ %.%#:\ ERROR\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Wcc\-%n\ %.%#:\ WARNING\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Icc\-%n\ %.%#:\ REMARK\ File\ =\ %f\%\\,\ Line\ =\ %l, diff --git a/runtime/compiler/mipspro_c89.vim b/runtime/compiler/mipspro_c89.vim index 20eb70d3fe..4d6bdabeef 100644 --- a/runtime/compiler/mipspro_c89.vim +++ b/runtime/compiler/mipspro_c89.vim @@ -2,6 +2,7 @@ " Compiler: SGI IRIX 6.5 MIPSPro C (c89) " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "mipspro_c89" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%Ecc\-%n\ %.%#:\ ERROR\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Wcc\-%n\ %.%#:\ WARNING\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Icc\-%n\ %.%#:\ REMARK\ File\ =\ %f\%\\,\ Line\ =\ %l, diff --git a/runtime/compiler/mipspro_cpp.vim b/runtime/compiler/mipspro_cpp.vim index 2f43af8455..9aac2a6564 100644 --- a/runtime/compiler/mipspro_cpp.vim +++ b/runtime/compiler/mipspro_cpp.vim @@ -2,6 +2,7 @@ " Compiler: SGI IRIX 6.5 MIPSPro C++ (CC) " Maintainer: David Harrison <david_jr@users.sourceforge.net> " Last Change: 2012 Apr 30 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "mipspro_cpp" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=%Ecc\-%n\ %.%#:\ ERROR\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Wcc\-%n\ %.%#:\ WARNING\ File\ =\ %f\%\\,\ Line\ =\ %l, \%Icc\-%n\ %.%#:\ REMARK\ File\ =\ %f\%\\,\ Line\ =\ %l, diff --git a/runtime/compiler/modelsim_vcom.vim b/runtime/compiler/modelsim_vcom.vim index 184b403996..8c6b8063ad 100644 --- a/runtime/compiler/modelsim_vcom.vim +++ b/runtime/compiler/modelsim_vcom.vim @@ -3,6 +3,7 @@ " Maintainer: Paul Baleme <pbaleme@mail.com> " Contributors: Enno Nagel " Last Change: 2024 Mar 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " Thanks to: allanherriman@hotmail.com if exists("current_compiler") @@ -10,10 +11,6 @@ if exists("current_compiler") endif let current_compiler = "modelsim_vcom" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=vcom "setlocal errorformat=\*\*\ %tRROR:\ %f(%l):\ %m,%tRROR:\ %f(%l):\ %m,%tARNING\[%*[0-9]\]:\ %f(%l):\ %m,\*\*\ %tRROR:\ %m,%tRROR:\ %m,%tARNING\[%*[0-9]\]:\ %m diff --git a/runtime/compiler/msbuild.vim b/runtime/compiler/msbuild.vim index 3652ca0e04..c871efaf3d 100644 --- a/runtime/compiler/msbuild.vim +++ b/runtime/compiler/msbuild.vim @@ -2,6 +2,7 @@ " Compiler: Microsoft Visual Studio C# " Maintainer: Chiel ten Brinke (ctje92@gmail.com) " Last Change: 2013 May 13 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -10,10 +11,6 @@ let current_compiler = "msbuild" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=\ %#%f(%l\\\,%c):\ %m CompilerSet makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true diff --git a/runtime/compiler/msvc.vim b/runtime/compiler/msvc.vim index 0d5660c103..3d40de5b7f 100644 --- a/runtime/compiler/msvc.vim +++ b/runtime/compiler/msvc.vim @@ -2,6 +2,7 @@ " Compiler: Microsoft Visual C " Maintainer: The Vim Project <https://github.com/vim/vim> " Last Change: 2023 Aug 10 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " Former Maintainer: Bram Moolenaar <Bram@vim.org> if exists("current_compiler") diff --git a/runtime/compiler/neato.vim b/runtime/compiler/neato.vim index 102c16e72b..0f36734130 100644 --- a/runtime/compiler/neato.vim +++ b/runtime/compiler/neato.vim @@ -2,16 +2,13 @@ " Compiler: ATT neato " Maintainer: Marcos Macedo <bar4ka@bol.com.br> " Last Change: 2024 March 21 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "neato" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=neato\ -T$*\ \"%:p\"\ -o\ \"%:p:r.$*\" " matches error messages as below skipping final part after line number " Error: ./file.dot: syntax error in line 1 near 'rankdir' diff --git a/runtime/compiler/ocaml.vim b/runtime/compiler/ocaml.vim index faa8af1f5f..754289fc14 100644 --- a/runtime/compiler/ocaml.vim +++ b/runtime/compiler/ocaml.vim @@ -3,6 +3,7 @@ " Maintainer: Markus Mottl <markus.mottl@gmail.com> " URL: https://github.com/ocaml/vim-ocaml " Last Change: +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " 2020 Mar 28 - Improved error format (Thomas Leonard) " 2017 Nov 26 - Improved error format (Markus Mottl) " 2013 Aug 27 - Added a new OCaml error format (Markus Mottl) diff --git a/runtime/compiler/onsgmls.vim b/runtime/compiler/onsgmls.vim index 68925ef459..4306f99de5 100644 --- a/runtime/compiler/onsgmls.vim +++ b/runtime/compiler/onsgmls.vim @@ -2,16 +2,13 @@ " Compiler: onsgmls " Maintainer: Robert Rowsome <rowsome@wam.umd.edu> " Last Change: 2019 Jul 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "onsgmls" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/pbx.vim b/runtime/compiler/pbx.vim index 9e81ea7355..5a45f7ffe0 100644 --- a/runtime/compiler/pbx.vim +++ b/runtime/compiler/pbx.vim @@ -2,16 +2,13 @@ " Compiler: Apple Project Builder " Maintainer: Alexander von Below (public@vonBelow.Com) " Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "pbx" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " The compiler actually is gcc, so the errorformat is unchanged CompilerSet errorformat& diff --git a/runtime/compiler/perl.vim b/runtime/compiler/perl.vim index 21e384fb85..6aeaac3fa1 100644 --- a/runtime/compiler/perl.vim +++ b/runtime/compiler/perl.vim @@ -6,16 +6,13 @@ " Bugs/requests: https://github.com/vim-perl/vim-perl/issues " License: Vim License (see :help license) " Last Change: 2021 Nov 2 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "perl" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:savecpo = &cpo set cpo&vim diff --git a/runtime/compiler/perlcritic.vim b/runtime/compiler/perlcritic.vim index cf0678eeb2..4b5f34dd2e 100644 --- a/runtime/compiler/perlcritic.vim +++ b/runtime/compiler/perlcritic.vim @@ -6,16 +6,13 @@ " Bugs/requests: https://github.com/vim-perl/vim-perl/issues " License: Vim License (see :help license) " Last Change: 2021 Oct 20 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "perlcritic" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/php.vim b/runtime/compiler/php.vim index 92f93b89fc..f5d521098b 100644 --- a/runtime/compiler/php.vim +++ b/runtime/compiler/php.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: PHP CLI " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2013 Jun 25 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "php" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/podchecker.vim b/runtime/compiler/podchecker.vim index 2cd4e13660..20faaa4bcc 100644 --- a/runtime/compiler/podchecker.vim +++ b/runtime/compiler/podchecker.vim @@ -6,16 +6,13 @@ " Bugs/requests: https://github.com/vim-perl/vim-perl/issues " License: Vim License (see :help license) " Last Change: 2021 Oct 20 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "podchecker" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/powershell.vim b/runtime/compiler/powershell.vim index 445a2f6d97..821fea4085 100644 --- a/runtime/compiler/powershell.vim +++ b/runtime/compiler/powershell.vim @@ -3,16 +3,14 @@ " URL: https://github.com/PProvost/vim-ps1 " Contributors: Enno Nagel " Last Change: 2024 Mar 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) +" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg) if exists("current_compiler") finish endif let current_compiler = "powershell" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C @@ -38,7 +36,7 @@ let g:ps1_efm_show_error_categories = get(g:, 'ps1_efm_show_error_categories', 0 " Use absolute path because powershell requires explicit relative paths " (./file.ps1 is okay, but # expands to file.ps1) -let makeprg = g:ps1_makeprg_cmd .. ' %:p:S' +let s:makeprg = g:ps1_makeprg_cmd .. ' %:p:S' " Parse file, line, char from callstacks: " Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a @@ -51,7 +49,7 @@ let makeprg = g:ps1_makeprg_cmd .. ' %:p:S' " + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException " + FullyQualifiedErrorId : CommandNotFoundException -execute 'CompilerSet makeprg=' .. escape(makeprg, ' ') +execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ') " Showing error in context with underlining. CompilerSet errorformat=%+G+%m diff --git a/runtime/compiler/pylint.vim b/runtime/compiler/pylint.vim index 93079ce61d..14e9696dbb 100644 --- a/runtime/compiler/pylint.vim +++ b/runtime/compiler/pylint.vim @@ -2,15 +2,12 @@ " Compiler: Pylint for Python " Maintainer: Daniel Moch <daniel@danielmoch.com> " Last Change: 2016 May 20 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "pylint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=pylint\ --output-format=text\ --msg-template=\"{path}:{line}:{column}:{C}:\ [{symbol}]\ {msg}\"\ --reports=no CompilerSet errorformat=%A%f:%l:%c:%t:\ %m,%A%f:%l:\ %m,%A%f:(%l):\ %m,%-Z%p^%.%#,%-G%.%# diff --git a/runtime/compiler/pyunit.vim b/runtime/compiler/pyunit.vim index 2a4ea92b68..2368346dd2 100644 --- a/runtime/compiler/pyunit.vim +++ b/runtime/compiler/pyunit.vim @@ -2,15 +2,12 @@ " Compiler: Unit testing tool for Python " Maintainer: Max Ischenko <mfi@ukr.net> " Last Change: 2004 Mar 27 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "pyunit" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m diff --git a/runtime/compiler/raco.vim b/runtime/compiler/raco.vim index bd10859aa9..d35d86b8c2 100644 --- a/runtime/compiler/raco.vim +++ b/runtime/compiler/raco.vim @@ -3,12 +3,9 @@ " Maintainer: D. Ben Knoble <ben.knoble+github@gmail.com> " URL: https://github.com/benknoble/vim-racket " Last Change: 2022 Aug 12 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) let current_compiler = 'raco' -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=raco CompilerSet errorformat=%f:%l:%c:%m diff --git a/runtime/compiler/racomake.vim b/runtime/compiler/racomake.vim index dae95fec42..bd2c327037 100644 --- a/runtime/compiler/racomake.vim +++ b/runtime/compiler/racomake.vim @@ -3,12 +3,9 @@ " Maintainer: D. Ben Knoble <ben.knoble+github@gmail.com> " URL: https://github.com/benknoble/vim-racket " Last Change: 2022 Aug 12 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) let current_compiler = 'racomake' -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=raco\ make\ --\ % CompilerSet errorformat=%f:%l:%c:%m diff --git a/runtime/compiler/racosetup.vim b/runtime/compiler/racosetup.vim index 1efe8a15a2..e16faf081a 100644 --- a/runtime/compiler/racosetup.vim +++ b/runtime/compiler/racosetup.vim @@ -3,12 +3,9 @@ " Maintainer: D. Ben Knoble <ben.knoble+github@gmail.com> " URL: https://github.com/benknoble/vim-racket " Last Change: 2022 Aug 12 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) let current_compiler = 'racosetup' -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=raco\ setup CompilerSet errorformat=%f:%l:%c:%m diff --git a/runtime/compiler/racotest.vim b/runtime/compiler/racotest.vim index d2a1a3c0f3..3ac11737d2 100644 --- a/runtime/compiler/racotest.vim +++ b/runtime/compiler/racotest.vim @@ -3,12 +3,9 @@ " Maintainer: D. Ben Knoble <ben.knoble+github@gmail.com> " URL: https://github.com/benknoble/vim-racket " Last Change: 2022 Aug 12 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) let current_compiler = 'racotest' -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=raco\ test\ % CompilerSet errorformat=location:%f:%l:%c diff --git a/runtime/compiler/rake.vim b/runtime/compiler/rake.vim index 3d11a31f89..5b3c7f4092 100644 --- a/runtime/compiler/rake.vim +++ b/runtime/compiler/rake.vim @@ -4,16 +4,13 @@ " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Last Change: 2018 Mar 02 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "rake" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/rhino.vim b/runtime/compiler/rhino.vim index 30f3dd3252..b6fc9c8d8c 100644 --- a/runtime/compiler/rhino.vim +++ b/runtime/compiler/rhino.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Rhino Shell (JavaScript in Java) " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "rhino" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/rspec.vim b/runtime/compiler/rspec.vim index 0cfce04572..ee848f703a 100644 --- a/runtime/compiler/rspec.vim +++ b/runtime/compiler/rspec.vim @@ -4,16 +4,13 @@ " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Last Change: 2018 Aug 07 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "rspec" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/rst.vim b/runtime/compiler/rst.vim index 392bea6ae0..72b6a58b67 100644 --- a/runtime/compiler/rst.vim +++ b/runtime/compiler/rst.vim @@ -2,7 +2,8 @@ " Compiler: sphinx >= 1.0.8, http://www.sphinx-doc.org " Description: reStructuredText Documentation Format " Previous Maintainer: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2017-03-31 +" Last Change: 2017 Mar 31 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -12,10 +13,6 @@ let current_compiler = "rst" let s:cpo_save = &cpo set cpo&vim -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat= \%f\\:%l:\ %tEBUG:\ %m, \%f\\:%l:\ %tNFO:\ %m, diff --git a/runtime/compiler/rubocop.vim b/runtime/compiler/rubocop.vim index 7764b4ad20..9d2f01499f 100644 --- a/runtime/compiler/rubocop.vim +++ b/runtime/compiler/rubocop.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: RuboCop " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "rubocop" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/ruby.vim b/runtime/compiler/ruby.vim index 82d4d1c876..70dff5bf24 100644 --- a/runtime/compiler/ruby.vim +++ b/runtime/compiler/ruby.vim @@ -5,16 +5,13 @@ " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Last Change: 2019 Jan 06 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "ruby" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/rubyunit.vim b/runtime/compiler/rubyunit.vim index 48e8fa41ab..e59873fa21 100644 --- a/runtime/compiler/rubyunit.vim +++ b/runtime/compiler/rubyunit.vim @@ -4,16 +4,13 @@ " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns <dougkearns@gmail.com> " Last Change: 2014 Mar 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "rubyunit" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/rustc.vim b/runtime/compiler/rustc.vim index efcf24ed80..b3c8091987 100644 --- a/runtime/compiler/rustc.vim +++ b/runtime/compiler/rustc.vim @@ -14,10 +14,6 @@ let s:save_cpo = &cpo set cpo&vim " vint: +ProhibitAbbreviationOption -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if get(g:, 'rustc_makeprg_no_percent', 0) CompilerSet makeprg=rustc else diff --git a/runtime/compiler/sass.vim b/runtime/compiler/sass.vim index 9c540ac443..d0ed65cfa5 100644 --- a/runtime/compiler/sass.vim +++ b/runtime/compiler/sass.vim @@ -2,16 +2,13 @@ " Compiler: Sass " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Last Change: 2016 Aug 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "sass" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/scdoc.vim b/runtime/compiler/scdoc.vim index c37969f89c..364ddc179c 100644 --- a/runtime/compiler/scdoc.vim +++ b/runtime/compiler/scdoc.vim @@ -2,6 +2,7 @@ " Compiler: scdoc " Maintainer: Gregory Anders <contact@gpanders.com> " Last Updated: 2019-10-24 +" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) " Upstream: https://github.com/gpanders/vim-scdoc if exists('current_compiler') @@ -9,9 +10,5 @@ if exists('current_compiler') endif let current_compiler = 'scdoc' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=scdoc\ <\ %\ 2>&1 CompilerSet errorformat=Error\ at\ %l:%c:\ %m,%-G%.%# diff --git a/runtime/compiler/se.vim b/runtime/compiler/se.vim index 38fd10c131..c9332277e5 100644 --- a/runtime/compiler/se.vim +++ b/runtime/compiler/se.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: se (Liberty Eiffel Compiler) " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2013 Jun 29 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "se" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/shellcheck.vim b/runtime/compiler/shellcheck.vim index 7550439aa2..5eeddc69c1 100644 --- a/runtime/compiler/shellcheck.vim +++ b/runtime/compiler/shellcheck.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: ShellCheck " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Sep 4 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "shellcheck" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/sml.vim b/runtime/compiler/sml.vim index a0b13b6c8a..e829e20e8c 100644 --- a/runtime/compiler/sml.vim +++ b/runtime/compiler/sml.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: SML/NJ Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2022 Feb 09 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "sml" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/spectral.vim b/runtime/compiler/spectral.vim index bd13c51f43..f1ea8653e5 100644 --- a/runtime/compiler/spectral.vim +++ b/runtime/compiler/spectral.vim @@ -2,16 +2,13 @@ " Compiler: Spectral for YAML " Maintainer: Romain Lafourcade <romainlafourcade@gmail.com> " Last Change: 2021 July 21 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "spectral" -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=spectral\ lint\ %\ -f\ text CompilerSet errorformat=%f:%l:%c\ %t%.%\\{-}\ %m diff --git a/runtime/compiler/splint.vim b/runtime/compiler/splint.vim index 3d7ada6d1d..e00460149c 100644 --- a/runtime/compiler/splint.vim +++ b/runtime/compiler/splint.vim @@ -3,6 +3,7 @@ " Maintainer: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> " Splint Home: http://www.splint.org/ " Last Change: 2019 Jul 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) " $Revision: 1.3 $ if exists("current_compiler") @@ -10,10 +11,6 @@ if exists("current_compiler") endif let current_compiler = "splint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo-=C diff --git a/runtime/compiler/standard.vim b/runtime/compiler/standard.vim index 50b7c97ca7..fdc79ae2ba 100644 --- a/runtime/compiler/standard.vim +++ b/runtime/compiler/standard.vim @@ -2,15 +2,12 @@ " Compiler: Standard for JavaScript " Maintainer: Romain Lafourcade <romainlafourcade@gmail.com> " Last Change: 2020 August 20 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "standard" -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=npx\ standard CompilerSet errorformat=%f:%l:%c:\ %m,%-G%.%# diff --git a/runtime/compiler/stylelint.vim b/runtime/compiler/stylelint.vim index 784a61d46a..22acea9eb0 100644 --- a/runtime/compiler/stylelint.vim +++ b/runtime/compiler/stylelint.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Stylelint " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Jun 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "stylelint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/tcl.vim b/runtime/compiler/tcl.vim index 81af185f5e..1e6d1f39e1 100644 --- a/runtime/compiler/tcl.vim +++ b/runtime/compiler/tcl.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: tcl " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2004 Nov 27 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "tcl" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=tcl CompilerSet errorformat=%EError:\ %m,%+Z\ %\\{4}(file\ \"%f\"\ line\ %l),%-G%.%# diff --git a/runtime/compiler/tex.vim b/runtime/compiler/tex.vim index 0925d17680..282b3a0588 100644 --- a/runtime/compiler/tex.vim +++ b/runtime/compiler/tex.vim @@ -3,6 +3,8 @@ " Maintainer: Artem Chuprina <ran@ran.pp.ru> " Contributors: Enno Nagel " Last Change: 2024 Mar 29 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) +" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg) if exists("current_compiler") finish @@ -10,10 +12,6 @@ endif let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - " If makefile exists and we are not asked to ignore it, we use standard make " (do not redefine makeprg) if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') || @@ -28,8 +26,8 @@ if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') || else let current_compiler = "latex" endif - let makeprg=current_compiler .. ' -interaction=nonstopmode' - execute 'CompilerSet makeprg=' .. escape(makeprg, ' ') + let s:makeprg=current_compiler .. ' -interaction=nonstopmode' + execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ') else let current_compiler = 'make' endif diff --git a/runtime/compiler/tidy.vim b/runtime/compiler/tidy.vim index 3f8e68ebf2..9e72207862 100644 --- a/runtime/compiler/tidy.vim +++ b/runtime/compiler/tidy.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: HTML Tidy " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Sep 4 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "tidy" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/ts-node.vim b/runtime/compiler/ts-node.vim index 14f0ea790c..1b46d3bf5a 100644 --- a/runtime/compiler/ts-node.vim +++ b/runtime/compiler/ts-node.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: TypeScript Runner " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "node" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/tsc.vim b/runtime/compiler/tsc.vim index a246fc7751..76f525baa6 100644 --- a/runtime/compiler/tsc.vim +++ b/runtime/compiler/tsc.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: TypeScript Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "tsc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/typedoc.vim b/runtime/compiler/typedoc.vim index 3be06f3d4e..7a152e85fd 100644 --- a/runtime/compiler/typedoc.vim +++ b/runtime/compiler/typedoc.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: TypeDoc " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "typedoc" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/xbuild.vim b/runtime/compiler/xbuild.vim index b508a4616a..42c7c65f53 100644 --- a/runtime/compiler/xbuild.vim +++ b/runtime/compiler/xbuild.vim @@ -2,6 +2,7 @@ " Compiler: Mono C# " Maintainer: Chiel ten Brinke (ctje92@gmail.com) " Last Change: 2013 May 13 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -11,10 +12,6 @@ let current_compiler = "xbuild" let s:keepcpo= &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet errorformat=\ %#%f(%l\\\,%c):\ %m CompilerSet makeprg=xbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true diff --git a/runtime/compiler/xmllint.vim b/runtime/compiler/xmllint.vim index 79d38b4d14..16eebb45ce 100644 --- a/runtime/compiler/xmllint.vim +++ b/runtime/compiler/xmllint.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Libxml2 Command-Line Tool " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Jul 30 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "xmllint" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/xmlwf.vim b/runtime/compiler/xmlwf.vim index 3de9d08d55..2e38ca4aba 100644 --- a/runtime/compiler/xmlwf.vim +++ b/runtime/compiler/xmlwf.vim @@ -2,6 +2,7 @@ " Compiler: xmlwf " Maintainer: Robert Rowsome <rowsome@wam.umd.edu> " Last Change: 2019 Jul 23 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish @@ -11,10 +12,6 @@ let current_compiler = "xmlwf" let s:cpo_save = &cpo set cpo&vim -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=xmlwf\ %:S CompilerSet errorformat=%f:%l%c:%m diff --git a/runtime/compiler/xo.vim b/runtime/compiler/xo.vim index 525657d4bb..74804ca6d0 100644 --- a/runtime/compiler/xo.vim +++ b/runtime/compiler/xo.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: XO " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2019 Jul 10 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "xo" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/compiler/yamllint.vim b/runtime/compiler/yamllint.vim index 889b04b63c..88e2efb27a 100644 --- a/runtime/compiler/yamllint.vim +++ b/runtime/compiler/yamllint.vim @@ -2,15 +2,12 @@ " Compiler: Yamllint for YAML " Maintainer: Romain Lafourcade <romainlafourcade@gmail.com> " Last Change: 2021 July 21 +" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition) if exists("current_compiler") finish endif let current_compiler = "yamllint" -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - CompilerSet makeprg=yamllint\ -f\ parsable diff --git a/runtime/compiler/zig.vim b/runtime/compiler/zig.vim index 2cc6831329..44014a3775 100644 --- a/runtime/compiler/zig.vim +++ b/runtime/compiler/zig.vim @@ -10,10 +10,6 @@ let current_compiler = "zig" let s:save_cpo = &cpo set cpo&vim -if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> -endif - " a subcommand must be provided for the this compiler (test, build-exe, etc) if has('patch-7.4.191') CompilerSet makeprg=zig\ \$*\ \%:S diff --git a/runtime/compiler/zig_build.vim b/runtime/compiler/zig_build.vim index 0441267b64..5a61c9f423 100644 --- a/runtime/compiler/zig_build.vim +++ b/runtime/compiler/zig_build.vim @@ -1,6 +1,7 @@ " Vim compiler file " Compiler: Zig Compiler (zig build) " Upstream: https://github.com/ziglang/zig.vim +" Last Change: 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists('current_compiler') finish @@ -11,11 +12,6 @@ let current_compiler = 'zig_build' let s:save_cpo = &cpo set cpo&vim - -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if exists('g:zig_build_makeprg_params') execute 'CompilerSet makeprg=zig\ build\ '.escape(g:zig_build_makeprg_params, ' \|"').'\ $*' else diff --git a/runtime/compiler/zig_build_exe.vim b/runtime/compiler/zig_build_exe.vim index 20f0bb3366..259d0e267b 100644 --- a/runtime/compiler/zig_build_exe.vim +++ b/runtime/compiler/zig_build_exe.vim @@ -1,6 +1,7 @@ " Vim compiler file " Compiler: Zig Compiler (zig build-exe) " Upstream: https://github.com/ziglang/zig.vim +" Last Change: 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists('current_compiler') finish @@ -11,11 +12,6 @@ let current_compiler = 'zig_build_exe' let s:save_cpo = &cpo set cpo&vim - -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if has('patch-7.4.191') CompilerSet makeprg=zig\ build-exe\ \%:S\ \$* else diff --git a/runtime/compiler/zig_test.vim b/runtime/compiler/zig_test.vim index a82d2a6378..dafeb6f1e3 100644 --- a/runtime/compiler/zig_test.vim +++ b/runtime/compiler/zig_test.vim @@ -1,6 +1,7 @@ " Vim compiler file " Compiler: Zig Compiler (zig test) " Upstream: https://github.com/ziglang/zig.vim +" Last Change: 2024 Apr 05 by The Vim Project (removed :CompilerSet definition) if exists('current_compiler') finish @@ -11,11 +12,6 @@ let current_compiler = 'zig_test' let s:save_cpo = &cpo set cpo&vim - -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal <args> -endif - if has('patch-7.4.191') CompilerSet makeprg=zig\ test\ \%:S\ \$* else diff --git a/runtime/compiler/zsh.vim b/runtime/compiler/zsh.vim index 5703c1fc44..bd195582c1 100644 --- a/runtime/compiler/zsh.vim +++ b/runtime/compiler/zsh.vim @@ -1,17 +1,13 @@ " Vim compiler file " Compiler: Zsh " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Sep 6 +" Last Change: 2024 Apr 03 if exists("current_compiler") finish endif let current_compiler = "zsh" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - let s:cpo_save = &cpo set cpo&vim diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index c88513ad75..cafb5636df 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1268,7 +1268,6 @@ executable({expr}) *executable()* The result is a Number: 1 exists 0 does not exist - -1 not implemented on this system |exepath()| can be used to get the full path of an executable. execute({command} [, {silent}]) *execute()* @@ -1588,6 +1587,7 @@ feedkeys({string} [, {mode}]) *feedkeys()* 't' Handle keys as if typed; otherwise they are handled as if coming from a mapping. This matters for undo, opening folds, etc. + 'L' Lowlevel input. Other flags are not used. 'i' Insert the string instead of appending (see above). 'x' Execute commands until typeahead is empty. This is similar to using ":normal!". You can call feedkeys() diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index bf62dba539..a64d722177 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -443,18 +443,18 @@ You can define the special menu "PopUp". This is the menu that is displayed when the right mouse button is pressed, if 'mousemodel' is set to popup or popup_setpos. -The default "PopUp" menu is: > - aunmenu PopUp - vnoremenu PopUp.Cut "+x - vnoremenu PopUp.Copy "+y - anoremenu PopUp.Paste "+gP - vnoremenu PopUp.Paste "+P - vnoremenu PopUp.Delete "_x - nnoremenu PopUp.Select\ All ggVG - vnoremenu PopUp.Select\ All gg0oG$ - inoremenu PopUp.Select\ All <C-Home><C-O>VG - anoremenu PopUp.-1- <Nop> - anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR> +The default "PopUp" menu is: >vim + vnoremenu PopUp.Cut "+x + vnoremenu PopUp.Copy "+y + anoremenu PopUp.Paste "+gP + vnoremenu PopUp.Paste "+P + vnoremenu PopUp.Delete "_x + nnoremenu PopUp.Select\ All ggVG + vnoremenu PopUp.Select\ All gg0oG$ + inoremenu PopUp.Select\ All <C-Home><C-O>VG + anoremenu PopUp.Inspect <Cmd>Inspect<CR> + anoremenu PopUp.-1- <Nop> + anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR> < Showing What Menus Are Mapped To *showing-menus* diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 5aa274637b..c219762c3f 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -346,6 +346,8 @@ The following new APIs and features were added. • |extmarks| option `scoped`: only show the extmarks in its namespace's scope. +• Added built-in |commenting| support. + ============================================================================== CHANGED FEATURES *news-changed* diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 56750420e9..1c03a61d55 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -2500,13 +2500,9 @@ When you write a compiler file and put it in your personal runtime directory variable to make the default file skip the settings. *:CompilerSet* The second mechanism is to use ":set" for ":compiler!" and ":setlocal" for -":compiler". Vim defines the ":CompilerSet" user command for this. However, -older Vim versions don't, thus your plugin should define it then. This is an -example: > +":compiler". Vim defines the ":CompilerSet" user command for this. This is +an example: > - if exists(":CompilerSet") != 2 - command -nargs=* CompilerSet setlocal <args> - endif CompilerSet errorformat& " use the default 'errorformat' CompilerSet makeprg=nmake diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 33f57580c7..aa05d2bbb2 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -557,5 +557,43 @@ LessInitFunc in your vimrc, for example: > set nocursorcolumn nocursorline endfunc < +============================================================================== +3. Commenting *commenting* + +Nvim supports commenting and uncommenting of lines based on 'commentstring'. + +Acting on a single line behaves as follows: +- If the line matches 'commentstring', the comment markers are removed (e.g. + `/*foo*/` is transformed to `foo`). +- Otherwise the comment markers are added to the current line (e.g. `foo` is + transformed to `/*foo*/`). Blank lines are ignored. + +Acting on multiple lines behaves as follows: +- If each affected non-blank line matches 'commentstring', then all comment + markers are removed. +- Otherwise all affected lines are converted to comments; blank lines are + transformed to empty comments (e.g. `/**/`). Comment markers are aligned to + the least indented line. + +If the filetype of the buffer is associated with a language for which a +|treesitter| parser is installed, then |vim.filetype.get_option()| is called +to look up the value of 'commentstring' corresponding to the cursor position. +(This can be different from the buffer's 'commentstring' in case of +|treesitter-language-injections|.) + + *gc* *gc-default* +gc{motion} Comment or uncomment lines covered by {motion}. + + *gcc* *gcc-default* +gcc Comment or uncomment [count] lines starting at cursor. + + *v_gc* *v_gc-default* +{Visual}gc Comment or uncomment the selected line(s). + + *o_gc* *o_gc-default* +gc Text object for the largest contiguous block of + non-blank commented lines around the cursor (e.g. + `gcgc` uncomments a comment block; `dgc` deletes it). + Works only in Operator-pending mode. vim:noet:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index a76166abf7..82f3fe9b1b 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -134,6 +134,8 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y". - @ |v_@-default| - # |v_#-default| - * |v_star-default| +- gc |gc-default| |v_gc-default| |o_gc-default| +- gcc |gcc-default| - Nvim LSP client defaults |lsp-defaults| - K |K-lsp-default| diff --git a/runtime/lua/nvim/health.lua b/runtime/lua/nvim/health.lua index 585c8deaee..35d293bee6 100644 --- a/runtime/lua/nvim/health.lua +++ b/runtime/lua/nvim/health.lua @@ -1,18 +1,6 @@ local M = {} local health = require('vim.health') -local fn_bool = function(key) - return function(...) - return vim.fn[key](...) == 1 - end -end - -local has = fn_bool('has') -local executable = fn_bool('executable') -local empty = fn_bool('empty') -local filereadable = fn_bool('filereadable') -local filewritable = fn_bool('filewritable') - local shell_error = function() return vim.v.shell_error ~= 0 end @@ -62,11 +50,11 @@ local function check_config() local init_lua = vim.fn.stdpath('config') .. '/init.lua' local init_vim = vim.fn.stdpath('config') .. '/init.vim' - local vimrc = empty(vim.env.MYVIMRC) and init_lua or vim.env.MYVIMRC + local vimrc = vim.env.MYVIMRC or init_lua - if not filereadable(vimrc) and not filereadable(init_vim) then + if vim.fn.filereadable(vimrc) == 0 and vim.fn.filereadable(init_vim) == 0 then ok = false - local has_vim = filereadable(vim.fn.expand('~/.vimrc')) + local has_vim = vim.fn.filereadable(vim.fn.expand('~/.vimrc')) == 1 health.warn( ('%s user config file: %s'):format( -1 == vim.fn.getfsize(vimrc) and 'Missing' or 'Unreadable', @@ -77,7 +65,7 @@ local function check_config() end -- If $VIM is empty we don't care. Else make sure it is valid. - if not empty(vim.env.VIM) and not filereadable(vim.env.VIM .. '/runtime/doc/nvim.txt') then + if vim.env.VIM and vim.fn.filereadable(vim.env.VIM .. '/runtime/doc/nvim.txt') == 0 then ok = false health.error('$VIM is invalid: ' .. vim.env.VIM) end @@ -121,17 +109,17 @@ local function check_config() local writeable = true local shadaopt = vim.fn.split(vim.o.shada, ',') local shadafile = ( - empty(vim.o.shada) and vim.o.shada + vim.o.shada == '' and vim.o.shada or vim.fn.substitute(vim.fn.matchstr(shadaopt[#shadaopt], '^n.\\+'), '^n', '', '') ) shadafile = ( - empty(vim.o.shadafile) - and (empty(shadafile) and vim.fn.stdpath('state') .. '/shada/main.shada' or vim.fn.expand( + vim.o.shadafile == '' + and (shadafile == '' and vim.fn.stdpath('state') .. '/shada/main.shada' or vim.fn.expand( shadafile )) or (vim.o.shadafile == 'NONE' and '' or vim.o.shadafile) ) - if not empty(shadafile) and empty(vim.fn.glob(shadafile)) then + if shadafile ~= '' and vim.fn.glob(shadafile) == '' then -- Since this may be the first time Nvim has been run, try to create a shada file. if not pcall(vim.cmd.wshada) then writeable = false @@ -139,12 +127,15 @@ local function check_config() end if not writeable - or (not empty(shadafile) and (not filereadable(shadafile) or not filewritable(shadafile))) + or ( + shadafile ~= '' + and (vim.fn.filereadable(shadafile) == 0 or vim.fn.filewritable(shadafile) ~= 1) + ) then ok = false health.error( 'shada file is not ' - .. ((not writeable or filereadable(shadafile)) and 'writeable' or 'readable') + .. ((not writeable or vim.fn.filereadable(shadafile) == 1) and 'writeable' or 'readable') .. ':\n' .. shadafile ) @@ -160,7 +151,7 @@ local function check_performance() -- Check buildtype local buildtype = vim.fn.matchstr(vim.fn.execute('version'), [[\v\cbuild type:?\s*[^\n\r\t ]+]]) - if empty(buildtype) then + if buildtype == '' then health.error('failed to get build type from :version') elseif vim.regex([[\v(MinSizeRel|Release|RelWithDebInfo)]]):match_str(buildtype) then health.ok(buildtype) @@ -196,12 +187,12 @@ local function check_rplugin_manifest() local require_update = false local handle_path = function(path) local python_glob = vim.fn.glob(path .. '/rplugin/python*', true, true) - if empty(python_glob) then + if vim.tbl_isempty(python_glob) then return end local python_dir = python_glob[1] - local python_version = vim.fn.fnamemodify(python_dir, ':t') + local python_version = vim.fs.basename(python_dir) local scripts = vim.fn.glob(python_dir .. '/*.py', true, true) vim.list_extend(scripts, vim.fn.glob(python_dir .. '/*/__init__.py', true, true)) @@ -213,12 +204,12 @@ local function check_rplugin_manifest() script = vim.fn.tr(vim.fn.fnamemodify(script, ':h'), '\\', '/') end if not existing_rplugins[script] then - local msg = vim.fn.printf('"%s" is not registered.', vim.fn.fnamemodify(path, ':t')) + local msg = vim.fn.printf('"%s" is not registered.', vim.fs.basename(path)) if python_version == 'pythonx' then - if not has('python3') then + if vim.fn.has('python3') == 0 then msg = msg .. ' (python3 not available)' end - elseif not has(python_version) then + elseif vim.fn.has(python_version) == 0 then msg = msg .. vim.fn.printf(' (%s not available)', python_version) else require_update = true @@ -232,7 +223,7 @@ local function check_rplugin_manifest() end end - for _, path in ipairs(vim.fn.map(vim.fn.split(vim.o.runtimepath, ','), 'resolve(v:val)')) do + for _, path in ipairs(vim.fn.map(vim.split(vim.o.runtimepath, ','), 'resolve(v:val)')) do handle_path(path) end @@ -244,7 +235,7 @@ local function check_rplugin_manifest() end local function check_tmux() - if empty(vim.env.TMUX) or not executable('tmux') then + if not vim.env.TMUX or vim.fn.executable('tmux') == 0 then return end @@ -255,7 +246,7 @@ local function check_tmux() if shell_error() then health.error('command failed: ' .. cmd .. '\n' .. out) return 'error' - elseif empty(val) then + elseif val == '' then cmd = 'tmux show-option -qvgs ' .. option -- try session scope out = vim.fn.system(vim.fn.split(cmd)) val = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g') @@ -274,7 +265,7 @@ local function check_tmux() { 'set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10', suggest_faq } local tmux_esc_time = get_tmux_option('escape-time') if tmux_esc_time ~= 'error' then - if empty(tmux_esc_time) then + if tmux_esc_time == '' then health.error('`escape-time` is not set', suggestions) elseif tonumber(tmux_esc_time) > 300 then health.error('`escape-time` (' .. tmux_esc_time .. ') is higher than 300ms', suggestions) @@ -286,7 +277,7 @@ local function check_tmux() -- check focus-events local tmux_focus_events = get_tmux_option('focus-events') if tmux_focus_events ~= 'error' then - if empty(tmux_focus_events) or tmux_focus_events ~= 'on' then + if tmux_focus_events == '' or tmux_focus_events ~= 'on' then health.warn( "`focus-events` is not enabled. |'autoread'| may not work.", { '(tmux 1.9+ only) Set `focus-events` in ~/.tmux.conf:\nset-option -g focus-events on' } @@ -301,7 +292,7 @@ local function check_tmux() local cmd = 'tmux show-option -qvg default-terminal' local out = vim.fn.system(vim.fn.split(cmd)) local tmux_default_term = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g') - if empty(tmux_default_term) then + if tmux_default_term == '' then cmd = 'tmux show-option -qvgs default-terminal' out = vim.fn.system(vim.fn.split(cmd)) tmux_default_term = vim.fn.substitute(out, [[\v(\s|\r|\n)]], '', 'g') @@ -341,7 +332,7 @@ local function check_tmux() end local function check_terminal() - if not executable('infocmp') then + if vim.fn.executable('infocmp') == 0 then return end @@ -354,13 +345,12 @@ local function check_terminal() if shell_error() and ( - not has('win32') - or empty( - vim.fn.matchstr( + vim.fn.has('win32') == 0 + or vim.fn.matchstr( out, [[infocmp: couldn't open terminfo file .\+\%(conemu\|vtpcon\|win32con\)]] ) - ) + == '' ) then health.error('command failed: ' .. cmd .. '\n' .. out) @@ -368,14 +358,14 @@ local function check_terminal() health.info( vim.fn.printf( 'key_backspace (kbs) terminfo entry: `%s`', - (empty(kbs_entry) and '? (not found)' or kbs_entry) + (kbs_entry == '' and '? (not found)' or kbs_entry) ) ) health.info( vim.fn.printf( 'key_dc (kdch1) terminfo entry: `%s`', - (empty(kbs_entry) and '? (not found)' or kdch1_entry) + (kbs_entry == '' and '? (not found)' or kdch1_entry) ) ) end diff --git a/runtime/lua/provider/clipboard/health.lua b/runtime/lua/provider/clipboard/health.lua index dc33cb0ab0..e44f7d32cc 100644 --- a/runtime/lua/provider/clipboard/health.lua +++ b/runtime/lua/provider/clipboard/health.lua @@ -1,5 +1,4 @@ local health = vim.health -local executable = health.executable local M = {} @@ -8,8 +7,8 @@ function M.check() if os.getenv('TMUX') - and executable('tmux') - and executable('pbpaste') + and vim.fn.executable('tmux') == 1 + and vim.fn.executable('pbpaste') == 1 and not health.cmd_ok('pbpaste') then local tmux_version = string.match(vim.fn.system('tmux -V'), '%d+%.%d+') diff --git a/runtime/lua/provider/node/health.lua b/runtime/lua/provider/node/health.lua index a434f8a92b..b4dca2f482 100644 --- a/runtime/lua/provider/node/health.lua +++ b/runtime/lua/provider/node/health.lua @@ -1,5 +1,4 @@ local health = vim.health -local executable = health.executable local iswin = vim.loop.os_uname().sysname == 'Windows_NT' local M = {} @@ -12,8 +11,12 @@ function M.check() end if - not executable('node') - or (not executable('npm') and not executable('yarn') and not executable('pnpm')) + vim.fn.executable('node') == 0 + or ( + vim.fn.executable('npm') == 0 + and vim.fn.executable('yarn') == 0 + and vim.fn.executable('pnpm') == 0 + ) then health.warn( '`node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.', @@ -50,9 +53,9 @@ function M.check() health.info('Nvim node.js host: ' .. host) local manager = 'npm' - if executable('yarn') then + if vim.fn.executable('yarn') == 1 then manager = 'yarn' - elseif executable('pnpm') then + elseif vim.fn.executable('pnpm') == 1 then manager = 'pnpm' end diff --git a/runtime/lua/provider/python/health.lua b/runtime/lua/provider/python/health.lua index 333890b62b..a5bd738063 100644 --- a/runtime/lua/provider/python/health.lua +++ b/runtime/lua/provider/python/health.lua @@ -1,5 +1,4 @@ local health = vim.health -local executable = health.executable local iswin = vim.loop.os_uname().sysname == 'Windows_NT' local M = {} @@ -60,7 +59,7 @@ local function check_bin(bin) if not is(bin, 'file') and (not iswin or not is(bin .. '.exe', 'file')) then health.error('"' .. bin .. '" was not found.') return false - elseif not executable(bin) then + elseif vim.fn.executable(bin) == 0 then health.error('"' .. bin .. '" is not executable.') return false end @@ -69,7 +68,7 @@ end -- Fetch the contents of a URL. local function download(url) - local has_curl = executable('curl') + local has_curl = vim.fn.executable('curl') == 1 if has_curl and vim.fn.system({ 'curl', '-V' }):find('Protocols:.*https') then local out, rc = health.system({ 'curl', '-sL', url }, { stderr = true, ignore_error = true }) if rc ~= 0 then @@ -77,7 +76,7 @@ local function download(url) else return out end - elseif executable('python') then + elseif vim.fn.executable('python') == 1 then local script = "try:\n\ from urllib.request import urlopen\n\ except ImportError:\n\ @@ -284,7 +283,7 @@ function M.check() if path_bin ~= vim.fs.normalize(python_exe) and vim.tbl_contains(python_multiple, path_bin) - and executable(path_bin) + and vim.fn.executable(path_bin) == 1 then python_multiple[#python_multiple + 1] = path_bin end @@ -472,7 +471,7 @@ function M.check() bin_dir, table.concat( vim.tbl_map(function(v) - return vim.fn.fnamemodify(v, ':t') + return vim.fs.basename(v) end, venv_bins), ', ' ) diff --git a/runtime/lua/provider/ruby/health.lua b/runtime/lua/provider/ruby/health.lua index 04f6e303e6..4d859597a4 100644 --- a/runtime/lua/provider/ruby/health.lua +++ b/runtime/lua/provider/ruby/health.lua @@ -1,5 +1,4 @@ local health = vim.health -local executable = health.executable local iswin = vim.loop.os_uname().sysname == 'Windows_NT' local M = {} @@ -11,7 +10,7 @@ function M.check() return end - if not executable('ruby') or not executable('gem') then + if vim.fn.executable('ruby') == 0 or vim.fn.executable('gem') == 0 then health.warn( '`ruby` and `gem` must be in $PATH.', 'Install Ruby and verify that `ruby` and `gem` commands work.' diff --git a/runtime/lua/vim/_comment.lua b/runtime/lua/vim/_comment.lua new file mode 100644 index 0000000000..e9cd662c9d --- /dev/null +++ b/runtime/lua/vim/_comment.lua @@ -0,0 +1,266 @@ +---@nodoc +---@class vim._comment.Parts +---@field left string Left part of comment +---@field right string Right part of comment + +--- Get 'commentstring' at cursor +---@param ref_position integer[] +---@return string +local function get_commentstring(ref_position) + local buf_cs = vim.bo.commentstring + + local has_ts_parser, ts_parser = pcall(vim.treesitter.get_parser) + if not has_ts_parser then + return buf_cs + end + + -- Try to get 'commentstring' associated with local tree-sitter language. + -- This is useful for injected languages (like markdown with code blocks). + local row, col = ref_position[1] - 1, ref_position[2] + local ref_range = { row, col, row, col + 1 } + + -- - Get 'commentstring' from the deepest LanguageTree which both contains + -- reference range and has valid 'commentstring' (meaning it has at least + -- one associated 'filetype' with valid 'commentstring'). + -- In simple cases using `parser:language_for_range()` would be enough, but + -- it fails for languages without valid 'commentstring' (like 'comment'). + local ts_cs, res_level = nil, 0 + + ---@param lang_tree vim.treesitter.LanguageTree + local function traverse(lang_tree, level) + if not lang_tree:contains(ref_range) then + return + end + + local lang = lang_tree:lang() + local filetypes = vim.treesitter.language.get_filetypes(lang) + for _, ft in ipairs(filetypes) do + local cur_cs = vim.filetype.get_option(ft, 'commentstring') + if cur_cs ~= '' and level > res_level then + ts_cs = cur_cs + end + end + + for _, child_lang_tree in pairs(lang_tree:children()) do + traverse(child_lang_tree, level + 1) + end + end + traverse(ts_parser, 1) + + return ts_cs or buf_cs +end + +--- Compute comment parts from 'commentstring' +---@param ref_position integer[] +---@return vim._comment.Parts +local function get_comment_parts(ref_position) + local cs = get_commentstring(ref_position) + + if cs == nil or cs == '' then + vim.api.nvim_echo({ { "Option 'commentstring' is empty.", 'WarningMsg' } }, true, {}) + return { left = '', right = '' } + end + + if not (type(cs) == 'string' and cs:find('%%s') ~= nil) then + error(vim.inspect(cs) .. " is not a valid 'commentstring'.") + end + + -- Structure of 'commentstring': <left part> <%s> <right part> + local left, right = cs:match('^(.-)%%s(.-)$') + return { left = left, right = right } +end + +--- Make a function that checks if a line is commented +---@param parts vim._comment.Parts +---@return fun(line: string): boolean +local function make_comment_check(parts) + local l_esc, r_esc = vim.pesc(parts.left), vim.pesc(parts.right) + + -- Commented line has the following structure: + -- <possible whitespace> <left> <anything> <right> <possible whitespace> + local nonblank_regex = '^%s-' .. l_esc .. '.*' .. r_esc .. '%s-$' + + -- Commented blank line can have any amoung of whitespace around parts + local blank_regex = '^%s-' .. vim.trim(l_esc) .. '%s*' .. vim.trim(r_esc) .. '%s-$' + + return function(line) + return line:find(nonblank_regex) ~= nil or line:find(blank_regex) ~= nil + end +end + +--- Compute comment-related information about lines +---@param lines string[] +---@param parts vim._comment.Parts +---@return string indent +---@return boolean is_commented +local function get_lines_info(lines, parts) + local comment_check = make_comment_check(parts) + + local is_commented = true + local indent_width = math.huge + ---@type string + local indent + + for _, l in ipairs(lines) do + -- Update lines indent: minimum of all indents except blank lines + local _, indent_width_cur, indent_cur = l:find('^(%s*)') + + -- Ignore blank lines completely when making a decision + if indent_width_cur < l:len() then + -- NOTE: Copying actual indent instead of recreating it with `indent_width` + -- allows to handle both tabs and spaces + if indent_width_cur < indent_width then + ---@diagnostic disable-next-line:cast-local-type + indent_width, indent = indent_width_cur, indent_cur + end + + -- Update comment info: commented if every non-blank line is commented + if is_commented then + is_commented = comment_check(l) + end + end + end + + -- `indent` can still be `nil` in case all `lines` are empty + return indent or '', is_commented +end + +--- Compute whether a string is blank +---@param x string +---@return boolean is_blank +local function is_blank(x) + return x:find('^%s*$') ~= nil +end + +--- Make a function which comments a line +---@param parts vim._comment.Parts +---@param indent string +---@return fun(line: string): string +local function make_comment_function(parts, indent) + local prefix, nonindent_start, suffix = indent .. parts.left, indent:len() + 1, parts.right + local blank_comment = indent .. vim.trim(parts.left) .. vim.trim(parts.right) + + return function(line) + if is_blank(line) then + return blank_comment + end + return prefix .. line:sub(nonindent_start) .. suffix + end +end + +--- Make a function which uncomments a line +---@param parts vim._comment.Parts +---@return fun(line: string): string +local function make_uncomment_function(parts) + local l_esc, r_esc = vim.pesc(parts.left), vim.pesc(parts.right) + local nonblank_regex = '^(%s*)' .. l_esc .. '(.*)' .. r_esc .. '(%s-)$' + local blank_regex = '^(%s*)' .. vim.trim(l_esc) .. '(%s*)' .. vim.trim(r_esc) .. '(%s-)$' + + return function(line) + -- Try both non-blank and blank regexes + local indent, new_line, trail = line:match(nonblank_regex) + if new_line == nil then + indent, new_line, trail = line:match(blank_regex) + end + + -- Return original if line is not commented + if new_line == nil then + return line + end + + -- Prevent trailing whitespace + if is_blank(new_line) then + indent, trail = '', '' + end + + return indent .. new_line .. trail + end +end + +--- Comment/uncomment buffer range +---@param line_start integer +---@param line_end integer +---@param ref_position? integer[] +local function toggle_lines(line_start, line_end, ref_position) + ref_position = ref_position or { line_start, 0 } + local parts = get_comment_parts(ref_position) + local lines = vim.api.nvim_buf_get_lines(0, line_start - 1, line_end, false) + local indent, is_comment = get_lines_info(lines, parts) + + local f = is_comment and make_uncomment_function(parts) or make_comment_function(parts, indent) + + -- Direct `nvim_buf_set_lines()` essentially removes both regular and + -- extended marks (squashes to empty range at either side of the region) + -- inside region. Use 'lockmarks' to preserve regular marks. + -- Preserving extmarks is not a universally good thing to do: + -- - Good for non-highlighting in text area extmarks (like showing signs). + -- - Debatable for highlighting in text area (like LSP semantic tokens). + -- Mostly because it causes flicker as highlighting is preserved during + -- comment toggling. + package.loaded['vim._comment']._lines = vim.tbl_map(f, lines) + local lua_cmd = string.format( + 'vim.api.nvim_buf_set_lines(0, %d, %d, false, package.loaded["vim._comment"]._lines)', + line_start - 1, + line_end + ) + vim.cmd.lua({ lua_cmd, mods = { lockmarks = true } }) + package.loaded['vim._comment']._lines = nil +end + +--- Operator which toggles user-supplied range of lines +---@param mode string? +---|"'line'" +---|"'char'" +---|"'block'" +local function operator(mode) + -- Used without arguments as part of expression mapping. Otherwise it is + -- called as 'operatorfunc'. + if mode == nil then + vim.o.operatorfunc = "v:lua.require'vim._comment'.operator" + return 'g@' + end + + -- Compute target range + local mark_from, mark_to = "'[", "']" + local lnum_from, col_from = vim.fn.line(mark_from), vim.fn.col(mark_from) + local lnum_to, col_to = vim.fn.line(mark_to), vim.fn.col(mark_to) + + -- Do nothing if "from" mark is after "to" (like in empty textobject) + if (lnum_from > lnum_to) or (lnum_from == lnum_to and col_from > col_to) then + return + end + + -- NOTE: use cursor position as reference for possibly computing local + -- tree-sitter-based 'commentstring'. Recompute every time for a proper + -- dot-repeat. In Visual and sometimes Normal mode it uses start position. + toggle_lines(lnum_from, lnum_to, vim.api.nvim_win_get_cursor(0)) + return '' +end + +--- Select contiguous commented lines at cursor +local function textobject() + local lnum_cur = vim.fn.line('.') + local parts = get_comment_parts({ lnum_cur, vim.fn.col('.') }) + local comment_check = make_comment_check(parts) + + if not comment_check(vim.fn.getline(lnum_cur)) then + return + end + + -- Compute commented range + local lnum_from = lnum_cur + while (lnum_from >= 2) and comment_check(vim.fn.getline(lnum_from - 1)) do + lnum_from = lnum_from - 1 + end + + local lnum_to = lnum_cur + local n_lines = vim.api.nvim_buf_line_count(0) + while (lnum_to <= n_lines - 1) and comment_check(vim.fn.getline(lnum_to + 1)) do + lnum_to = lnum_to + 1 + end + + -- Select range linewise for operator to act upon + vim.cmd('normal! ' .. lnum_from .. 'GV' .. lnum_to .. 'G') +end + +return { operator = operator, textobject = textobject, toggle_lines = toggle_lines } diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 6223082622..90d05f67a5 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -1,3 +1,31 @@ +--- Default user commands +do + vim.api.nvim_create_user_command('Inspect', function(cmd) + if cmd.bang then + vim.print(vim.inspect_pos()) + else + vim.show_pos() + end + end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true }) + + vim.api.nvim_create_user_command('InspectTree', function(cmd) + if cmd.mods ~= '' or cmd.count ~= 0 then + local count = cmd.count ~= 0 and cmd.count or '' + local new = cmd.mods ~= '' and 'new' or 'vnew' + + vim.treesitter.inspect_tree({ + command = ('%s %s%s'):format(cmd.mods, count, new), + }) + else + vim.treesitter.inspect_tree() + end + end, { desc = 'Inspect treesitter language tree for buffer', count = true }) + + vim.api.nvim_create_user_command('EditQuery', function(cmd) + vim.treesitter.query.edit(cmd.fargs[1]) + end, { desc = 'Edit treesitter query', nargs = '?' }) +end + --- Default mappings do --- Default maps for * and # in visual mode. @@ -86,6 +114,24 @@ do do_open(table.concat(vim.iter(lines):map(vim.trim):totable())) end, { desc = gx_desc }) end + + --- Default maps for built-in commenting + do + local operator_rhs = function() + return require('vim._comment').operator() + end + vim.keymap.set({ 'n', 'x' }, 'gc', operator_rhs, { expr = true, desc = 'Toggle comment' }) + + local line_rhs = function() + return require('vim._comment').operator() .. '_' + end + vim.keymap.set('n', 'gcc', line_rhs, { expr = true, desc = 'Toggle comment line' }) + + local textobject_rhs = function() + require('vim._comment').textobject() + end + vim.keymap.set({ 'o' }, 'gc', textobject_rhs, { desc = 'Comment textobject' }) + end end --- Default menus @@ -93,7 +139,6 @@ do --- Right click popup menu -- TODO VimScript, no l10n vim.cmd([[ - aunmenu * vnoremenu PopUp.Cut "+x vnoremenu PopUp.Copy "+y anoremenu PopUp.Paste "+gP @@ -102,6 +147,7 @@ do nnoremenu PopUp.Select\ All ggVG vnoremenu PopUp.Select\ All gg0oG$ inoremenu PopUp.Select\ All <C-Home><C-O>VG + anoremenu PopUp.Inspect <Cmd>Inspect<CR> anoremenu PopUp.-1- <Nop> anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR> ]]) diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index caddd4dde2..c114c3b212 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -1598,11 +1598,10 @@ function vim.fn.eventhandler() end --- The result is a Number: --- 1 exists --- 0 does not exist ---- -1 not implemented on this system --- |exepath()| can be used to get the full path of an executable. --- --- @param expr any ---- @return 0|1|-1 +--- @return 0|1 function vim.fn.executable(expr) end --- Execute {command} and capture its output. @@ -1959,6 +1958,7 @@ function vim.fn.extendnew(expr1, expr2, expr3) end --- 't' Handle keys as if typed; otherwise they are handled as --- if coming from a mapping. This matters for undo, --- opening folds, etc. +--- 'L' Lowlevel input. Other flags are not used. --- 'i' Insert the string instead of appending (see above). --- 'x' Execute commands until typeahead is empty. This is --- similar to using ":normal!". You can call feedkeys() diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 1198a9972f..9b1fd80b82 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1293,6 +1293,7 @@ local filename = { jbuild = 'dune', ['dune-workspace'] = 'dune', ['dune-project'] = 'dune', + Earthfile = 'earthfile', ['.editorconfig'] = 'editorconfig', ['elinks.conf'] = 'elinks', ['mix.lock'] = 'elixir', diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua index f6f7abef8f..9e9c557ad3 100644 --- a/runtime/lua/vim/health.lua +++ b/runtime/lua/vim/health.lua @@ -386,7 +386,7 @@ local path2name = function(path) path = path:gsub('^.*/lua/', '') -- Remove the filename (health.lua) - path = vim.fn.fnamemodify(path, ':h') + path = vim.fs.dirname(path) -- Change slashes to dots path = path:gsub('/', '.') @@ -497,11 +497,4 @@ function M._check(mods, plugin_names) vim.print('') end -local fn_bool = function(key) - return function(...) - return vim.fn[key](...) == 1 - end -end -M.executable = fn_bool('executable') - return M diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index f73f97b8cd..09064b9510 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -579,6 +579,7 @@ function Client:initialize() initializationOptions = config.init_options, capabilities = self.capabilities, trace = self._trace, + workDoneToken = '1', } self:_run_callbacks( diff --git a/runtime/plugin/nvim.lua b/runtime/plugin/nvim.lua deleted file mode 100644 index 743d3044b6..0000000000 --- a/runtime/plugin/nvim.lua +++ /dev/null @@ -1,24 +0,0 @@ -vim.api.nvim_create_user_command('Inspect', function(cmd) - if cmd.bang then - vim.print(vim.inspect_pos()) - else - vim.show_pos() - end -end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true }) - -vim.api.nvim_create_user_command('InspectTree', function(cmd) - if cmd.mods ~= '' or cmd.count ~= 0 then - local count = cmd.count ~= 0 and cmd.count or '' - local new = cmd.mods ~= '' and 'new' or 'vnew' - - vim.treesitter.inspect_tree({ - command = ('%s %s%s'):format(cmd.mods, count, new), - }) - else - vim.treesitter.inspect_tree() - end -end, { desc = 'Inspect treesitter language tree for buffer', count = true }) - -vim.api.nvim_create_user_command('EditQuery', function(cmd) - vim.treesitter.query.edit(cmd.fargs[1]) -end, { desc = 'Edit treesitter query', nargs = '?' }) diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm index 86f9a67344..6547bea7ae 100644 --- a/runtime/queries/bash/highlights.scm +++ b/runtime/queries/bash/highlights.scm @@ -124,10 +124,15 @@ (test_operator) @operator (command_substitution - "$(" @punctuation.bracket) + "$(" @punctuation.special + ")" @punctuation.special) (process_substitution - "<(" @punctuation.bracket) + [ + "<(" + ">(" + ] @punctuation.special + ")" @punctuation.special) (arithmetic_expansion [ @@ -170,12 +175,11 @@ "trap" "type" "typeset" "ulimit" "umask" "unalias" "wait")) (command - argument: - [ - (word) @variable.parameter - (concatenation - (word) @variable.parameter) - ]) + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + ]) (number) @number diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index e22aac997f..c901b96f31 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -142,9 +142,6 @@ (char_literal) @character -((preproc_arg) @function.macro - (#set! "priority" 90)) - (preproc_defined) @function.macro ((field_expression @@ -263,18 +260,16 @@ function: (identifier) @function.call) (call_expression - function: - (field_expression - field: (field_identifier) @function.call)) + function: (field_expression + field: (field_identifier) @function.call)) (function_declarator declarator: (identifier) @function) (function_declarator - declarator: - (parenthesized_declarator - (pointer_declarator - declarator: (field_identifier) @function))) + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (field_identifier) @function))) (preproc_function_def name: (identifier) @function.macro) diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm index 053d8116da..0c8f07f290 100644 --- a/runtime/queries/lua/highlights.scm +++ b/runtime/queries/lua/highlights.scm @@ -180,27 +180,24 @@ (vararg_expression) @variable.parameter.builtin (function_declaration - name: - [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) (function_declaration - name: - (method_index_expression - method: (identifier) @function.method)) + name: (method_index_expression + method: (identifier) @function.method)) (assignment_statement (variable_list . - name: - [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) (expression_list . value: (function_definition))) @@ -211,14 +208,13 @@ value: (function_definition))) (function_call - name: - [ - (identifier) @function.call - (dot_index_expression - field: (identifier) @function.call) - (method_index_expression - method: (identifier) @function.method.call) - ]) + name: [ + (identifier) @function.call + (dot_index_expression + field: (identifier) @function.call) + (method_index_expression + method: (identifier) @function.method.call) + ]) (function_call (identifier) @function.builtin @@ -253,21 +249,19 @@ (dot_index_expression field: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: - (arguments - . - (_) - . - (string - content: (string_content) @string.regexp))) + arguments: (arguments + . + (_) + . + (string + content: (string_content) @string.regexp))) ;("123"):match("%d+") (function_call (method_index_expression method: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: - (arguments - . - (string - content: (string_content) @string.regexp))) + arguments: (arguments + . + (string + content: (string_content) @string.regexp))) diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm index a76f764d76..4345c71ce8 100644 --- a/runtime/queries/lua/injections.scm +++ b/runtime/queries/lua/injections.scm @@ -1,67 +1,69 @@ ((function_call - name: - [ - (identifier) @_cdef_identifier - (_ - _ - (identifier) @_cdef_identifier) - ] - arguments: - (arguments - (string - content: _ @injection.content))) + name: [ + (identifier) @_cdef_identifier + (_ + _ + (identifier) @_cdef_identifier) + ] + arguments: (arguments + (string + content: _ @injection.content))) (#set! injection.language "c") (#eq? @_cdef_identifier "cdef")) ((function_call name: (_) @_vimcmd_identifier - arguments: - (arguments - (string - content: _ @injection.content))) + arguments: (arguments + (string + content: _ @injection.content))) (#set! injection.language "vim") (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2")) ((function_call name: (_) @_vimcmd_identifier - arguments: - (arguments - (string - content: _ @injection.content) .)) + arguments: (arguments + (string + content: _ @injection.content) .)) (#set! injection.language "query") (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse")) ((function_call name: (_) @_vimcmd_identifier - arguments: - (arguments - . - (_) - . - (string - content: _ @_method) - . - (string - content: _ @injection.content))) + arguments: (arguments + . + (_) + . + (string + content: _ @_method) + . + (string + content: _ @injection.content))) (#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify") (#eq? @_method "nvim_exec_lua") (#set! injection.language "lua")) +; exec_lua [[ ... ]] in functionaltests +((function_call + name: (identifier) @_function + arguments: (arguments + (string + content: (string_content) @injection.content))) + (#eq? @_function "exec_lua") + (#set! injection.language "lua")) + ; vim.api.nvim_create_autocmd("FileType", { command = "injected here" }) (function_call name: (_) @_vimcmd_identifier - arguments: - (arguments - . - (_) - . - (table_constructor - (field - name: (identifier) @_command - value: - (string - content: (_) @injection.content))) .) + arguments: (arguments + . + (_) + . + (table_constructor + (field + name: (identifier) @_command + value: (string + content: (_) @injection.content))) .) ; limit so only 2-argument functions gets matched before pred handle (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") (#eq? @_command "command") @@ -69,31 +71,29 @@ (function_call name: (_) @_user_cmd - arguments: - (arguments - . - (_) - . - (string - content: (_) @injection.content) - . - (_) .) + arguments: (arguments + . + (_) + . + (string + content: (_) @injection.content) + . + (_) .) (#eq? @_user_cmd "vim.api.nvim_create_user_command") (#set! injection.language "vim")) (function_call name: (_) @_user_cmd - arguments: - (arguments - . - (_) - . - (_) - . - (string - content: (_) @injection.content) - . - (_) .) + arguments: (arguments + . + (_) + . + (_) + . + (string + content: (_) @injection.content) + . + (_) .) ; Limiting predicate handling to only functions with 4 arguments (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") (#set! injection.language "vim")) diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm index ac582e3f9b..4b445e02f3 100644 --- a/runtime/queries/markdown/highlights.scm +++ b/runtime/queries/markdown/highlights.scm @@ -111,6 +111,12 @@ ((block_quote) @markup.quote (#set! "priority" 90)) +([ + (plus_metadata) + (minus_metadata) +] @keyword.directive + (#set! "priority" 90)) + [ (block_continuation) (block_quote_marker) diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm index fea97bed32..4d62aeff06 100644 --- a/runtime/queries/python/highlights.scm +++ b/runtime/queries/python/highlights.scm @@ -35,9 +35,8 @@ ((assignment left: (identifier) @type.definition - right: - (call - function: (identifier) @_func)) + right: (call + function: (identifier) @_func)) (#any-of? @_func "TypeVar" "NewType")) ; Function calls @@ -45,18 +44,16 @@ function: (identifier) @function.call) (call - function: - (attribute - attribute: (identifier) @function.method.call)) + function: (attribute + attribute: (identifier) @function.method.call)) ((call function: (identifier) @constructor) (#lua-match? @constructor "^%u")) ((call - function: - (attribute - attribute: (identifier) @constructor)) + function: (attribute + attribute: (identifier) @constructor)) (#lua-match? @constructor "^%u")) ; Decorators @@ -82,7 +79,7 @@ ((decorator (identifier) @attribute.builtin) - (#any-of? @attribute.builtin "classmethod" "property")) + (#any-of? @attribute.builtin "classmethod" "property" "staticmethod")) ; Builtin functions ((call @@ -109,10 +106,9 @@ ((call function: (identifier) @_isinstance - arguments: - (argument_list - (_) - (identifier) @type)) + arguments: (argument_list + (_) + (identifier) @type)) (#eq? @_isinstance "isinstance")) ; Normal parameters @@ -211,18 +207,16 @@ (string) @string.documentation @spell)) (class_definition - body: - (block - . - (expression_statement - (string) @string.documentation @spell))) + body: (block + . + (expression_statement + (string) @string.documentation @spell))) (function_definition - body: - (block - . - (expression_statement - (string) @string.documentation @spell))) + body: (block + . + (expression_statement + (string) @string.documentation @spell))) ; Tokens [ @@ -378,32 +372,27 @@ name: (identifier) @type) (class_definition - body: - (block - (function_definition - name: (identifier) @function.method))) + body: (block + (function_definition + name: (identifier) @function.method))) (class_definition - superclasses: - (argument_list - (identifier) @type)) + superclasses: (argument_list + (identifier) @type)) ((class_definition - body: - (block - (expression_statement - (assignment - left: (identifier) @variable.member)))) + body: (block + (expression_statement + (assignment + left: (identifier) @variable.member)))) (#lua-match? @variable.member "^[%l_].*$")) ((class_definition - body: - (block - (expression_statement - (assignment - left: - (_ - (identifier) @variable.member))))) + body: (block + (expression_statement + (assignment + left: (_ + (identifier) @variable.member))))) (#lua-match? @variable.member "^[%l_].*$")) ((class_definition @@ -434,12 +423,10 @@ ; Regex from the `re` module (call - function: - (attribute - object: (identifier) @_re) - arguments: - (argument_list - . - (string - (string_content) @string.regexp)) + function: (attribute + object: (identifier) @_re) + arguments: (argument_list + . + (string + (string_content) @string.regexp)) (#eq? @_re "re")) diff --git a/runtime/queries/query/highlights.scm b/runtime/queries/query/highlights.scm index cdedb23e29..abc7aa50ad 100644 --- a/runtime/queries/query/highlights.scm +++ b/runtime/queries/query/highlights.scm @@ -68,20 +68,18 @@ ((predicate name: (identifier) @_name - parameters: - (parameters - (string - "\"" @string - "\"" @string) @string.regexp)) + parameters: (parameters + (string + "\"" @string + "\"" @string) @string.regexp)) (#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match")) ((predicate name: (identifier) @_name - parameters: - (parameters - (string - "\"" @string - "\"" @string) @string.regexp - . - (string) .)) + parameters: (parameters + (string + "\"" @string + "\"" @string) @string.regexp + . + (string) .)) (#any-of? @_name "gsub" "not-gsub")) diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm index cc51282a71..2950278f9f 100644 --- a/runtime/queries/vim/highlights.scm +++ b/runtime/queries/vim/highlights.scm @@ -42,9 +42,8 @@ function: (identifier) @function.call) (call_expression - function: - (scoped_identifier - (identifier) @function.call)) + function: (scoped_identifier + (identifier) @function.call)) (parameters (identifier) @variable.parameter) @@ -206,10 +205,9 @@ (command_attribute name: _ @property - val: - (behavior - name: _ @constant - val: (identifier)? @function)?) + val: (behavior + name: _ @constant + val: (identifier)? @function)?) ; Edit command (plus_plus_opt diff --git a/runtime/syntax/java.vim b/runtime/syntax/java.vim index 1f0c158031..22fc934a0c 100644 --- a/runtime/syntax/java.vim +++ b/runtime/syntax/java.vim @@ -2,7 +2,7 @@ " Language: Java " Maintainer: Claudio Fleiner <claudio@fleiner.com> " URL: https://github.com/fleiner/vim/blob/master/runtime/syntax/java.vim -" Last Change: 2024 Mar 25 +" Last Change: 2024 Apr 04 " Please check :help java.vim for comments on some of the options available. @@ -19,6 +19,9 @@ endif let s:cpo_save = &cpo set cpo&vim +" Admit the ASCII dollar sign to keyword characters (JLS-17, §3.8): +execute printf('syntax iskeyword %s,$', &l:iskeyword) + " some characters that cannot be in a java program (outside a string) syn match javaError "[\\@`]" syn match javaError "<<<\|\.\.\|=>\|||=\|&&=\|\*\/" @@ -27,16 +30,17 @@ syn match javaError "<<<\|\.\.\|=>\|||=\|&&=\|\*\/" syn match javaError2 "#\|=<" hi def link javaError2 javaError -" keyword definitions +" Keywords (JLS-17, §3.9): syn keyword javaExternal native package -syn match javaExternal "\<import\>\(\s\+static\>\)\?" +syn match javaExternal "\<import\>\%(\s\+static\>\)\=" syn keyword javaError goto const syn keyword javaConditional if else switch syn keyword javaRepeat while for do syn keyword javaBoolean true false syn keyword javaConstant null syn keyword javaTypedef this super -syn keyword javaOperator var new instanceof +syn keyword javaOperator new instanceof +syn match javaOperator "\<var\>\%(\s*(\)\@!" " Since the yield statement, which could take a parenthesised operand, " and _qualified_ yield methods get along within the switch block " (JLS-17, §3.8), it seems futile to make a region definition for this @@ -48,14 +52,15 @@ syn match javaOperator "\%(\%(::\|\.\)[[:space:]\n]*\)\@80<!\<yield\>" syn keyword javaType boolean char byte short int long float double syn keyword javaType void syn keyword javaStatement return -syn keyword javaStorageClass static synchronized transient volatile final strictfp serializable +syn keyword javaStorageClass static synchronized transient volatile strictfp serializable syn keyword javaExceptions throw try catch finally syn keyword javaAssert assert -syn keyword javaMethodDecl synchronized throws -syn keyword javaClassDecl extends implements interface -" to differentiate the keyword class from MyClass.class we use a match here +syn keyword javaMethodDecl throws +" Differentiate a "MyClass.class" literal from the keyword "class". syn match javaTypedef "\.\s*\<class\>"ms=s+1 -syn keyword javaClassDecl enum +syn keyword javaClassDecl enum extends implements interface +syn match javaClassDecl "\<permits\>\%(\s*(\)\@!" +syn match javaClassDecl "\<record\>\%(\s*(\)\@!" syn match javaClassDecl "^class\>" syn match javaClassDecl "[^.]\s*\<class\>"ms=s+1 syn match javaAnnotation "@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>" contains=javaString @@ -63,19 +68,27 @@ syn match javaClassDecl "@interface\>" syn keyword javaBranch break continue nextgroup=javaUserLabelRef skipwhite syn match javaUserLabelRef "\k\+" contained syn match javaVarArg "\.\.\." -syn keyword javaScopeDecl public protected private abstract +syn keyword javaScopeDecl public protected private +syn keyword javaConceptKind abstract final +syn match javaConceptKind "\<non-sealed\>" +syn match javaConceptKind "\<sealed\>\%(\s*(\)\@!" syn match javaConceptKind "\<default\>\%(\s*\%(:\|->\)\)\@!" -function s:isModuleInfoDeclarationCurrentBuffer() abort - return fnamemodify(bufname("%"), ":t") =~ '^module-info\%(\.class\>\)\@!' -endfunction - -" Java Modules(Since Java 9, for "module-info.java" file) -if s:isModuleInfoDeclarationCurrentBuffer() - syn keyword javaModuleStorageClass module transitive - syn keyword javaModuleStmt open requires exports opens uses provides - syn keyword javaModuleExternal to with - syn cluster javaTop add=javaModuleStorageClass,javaModuleStmt,javaModuleExternal +" Note that a "module-info" file will be recognised with an arbitrary +" file extension (or no extension at all) so that more than one such +" declaration for the same Java module can be maintained for modular +" testing in a project without attendant confusion for IDEs, with the +" ".java\=" extension used for a production version and an arbitrary +" extension used for a testing version. +let s:module_info_cur_buf = fnamemodify(bufname("%"), ":t") =~ '^module-info\%(\.class\>\)\@!' +lockvar s:module_info_cur_buf + +" Java modules (since Java 9, for "module-info.java" file). +if s:module_info_cur_buf + syn keyword javaModuleStorageClass module transitive + syn keyword javaModuleStmt open requires exports opens uses provides + syn keyword javaModuleExternal to with + syn cluster javaTop add=javaModuleStorageClass,javaModuleStmt,javaModuleExternal endif if exists("java_highlight_java_lang_ids") @@ -111,7 +124,7 @@ if exists("java_highlight_all") || exists("java_highlight_java") || exists("ja syn match javaC_JavaLang "\%(\<Enum\.\)\@<=\<EnumDesc\>" syn keyword javaC_JavaLang Boolean Character Class ClassLoader Compiler Double Float Integer Long Math Number Object Process Runtime SecurityManager String StringBuffer Thread ThreadGroup Byte Short Void InheritableThreadLocal Package RuntimePermission ThreadLocal StrictMath StackTraceElement Enum ProcessBuilder StringBuilder ClassValue Module ModuleLayer StackWalker Record syn match javaC_JavaLang "\<System\>" " See javaDebug. - " As of Java 21, java.lang.Compiler is no more (deprecated in Java 9). + " As of JDK 21, java.lang.Compiler is no more (deprecated in JDK 9). syn keyword javaLangDeprecated Compiler syn cluster javaTop add=javaC_JavaLang syn cluster javaClasses add=javaC_JavaLang @@ -275,17 +288,17 @@ syn cluster javaTop add=javaString,javaStrTempl,javaCharacter,javaNumber,javaSpe if exists("java_highlight_functions") if java_highlight_functions == "indent" - syn match javaFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]<>]*([^-+*/]*)" contains=javaScopeDecl,javaType,javaStorageClass,@javaClasses,javaAnnotation - syn region javaFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*,\s*+ end=+)+ contains=javaScopeDecl,javaType,javaStorageClass,@javaClasses,javaAnnotation - syn match javaFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*)" contains=javaScopeDecl,javaType,javaStorageClass,@javaClasses,javaAnnotation - syn region javaFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*,\s*+ end=+)+ contains=javaScopeDecl,javaType,javaStorageClass,@javaClasses,javaAnnotation + syn match javaFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]<>]*([^-+*/]*)" contains=javaScopeDecl,javaConceptKind,javaType,javaStorageClass,@javaClasses,javaAnnotation + syn region javaFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*,\s*+ end=+)+ contains=javaScopeDecl,javaConceptKind,javaType,javaStorageClass,@javaClasses,javaAnnotation + syn match javaFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*)" contains=javaScopeDecl,javaConceptKind,javaType,javaStorageClass,@javaClasses,javaAnnotation + syn region javaFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]<>]*([^-+*/]*,\s*+ end=+)+ contains=javaScopeDecl,javaConceptKind,javaType,javaStorageClass,@javaClasses,javaAnnotation else " This line catches method declarations at any indentation>0, but it assumes " two things: " 1. class names are always capitalized (ie: Button) " 2. method names are never capitalized (except constructors, of course) "syn region javaFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(<[^>]*>\)\=\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*([^0-9]+ end=+)+ contains=javaScopeDecl,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses - syn region javaFuncDef start=+^\s\+\%(\%(public\|protected\|private\|static\|\%(abstract\|default\)\|final\|native\|synchronized\)\s\+\)*\%(<.*>\s\+\)\?\%(\%(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\%([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\%(<[^(){}]*>\)\=\%(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*(+ end=+)+ contains=javaScopeDecl,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses,javaAnnotation + syn region javaFuncDef start=+^\s\+\%(\%(public\|protected\|private\|static\|\%(abstract\|default\)\|final\|native\|synchronized\)\s\+\)*\%(<.*>\s\+\)\?\%(\%(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\%([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\%(<[^(){}]*>\)\=\%(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*(+ end=+)+ contains=javaScopeDecl,javaConceptKind,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses,javaAnnotation endif syn match javaLambdaDef "\<\K\k*\>\%(\<default\>\)\@<!\s*->" syn match javaBraces "[{}]" @@ -440,10 +453,10 @@ hi def link htmlArg Type hi def link htmlString String hi def link javaSpaceError Error -if s:isModuleInfoDeclarationCurrentBuffer() - hi def link javaModuleStorageClass StorageClass - hi def link javaModuleStmt Statement - hi def link javaModuleExternal Include +if s:module_info_cur_buf + hi def link javaModuleStorageClass StorageClass + hi def link javaModuleStmt Statement + hi def link javaModuleExternal Include endif let b:current_syntax = "java" @@ -452,9 +465,8 @@ if main_syntax == 'java' unlet main_syntax endif -delfunction! s:isModuleInfoDeclarationCurrentBuffer -let b:spell_options="contained" +let b:spell_options = "contained" let &cpo = s:cpo_save -unlet s:cpo_save +unlet s:module_info_cur_buf s:cpo_save " vim: ts=8 diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2fb8f3d554..82e9ddff2d 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -277,6 +277,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) bool typed = false; bool execute = false; bool dangerous = false; + bool lowlevel = false; for (size_t i = 0; i < mode.size; i++) { switch (mode.data[i]) { @@ -292,6 +293,8 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) execute = true; break; case '!': dangerous = true; break; + case 'L': + lowlevel = true; break; } } @@ -307,10 +310,14 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) } else { keys_esc = keys.data; } - ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE), - insert ? 0 : typebuf.tb_len, !typed, false); - if (vgetc_busy) { - typebuf_was_filled = true; + if (lowlevel) { + input_enqueue_raw(cstr_as_string(keys_esc)); + } else { + ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE), + insert ? 0 : typebuf.tb_len, !typed, false); + if (vgetc_busy) { + typebuf_was_filled = true; + } } if (escape_ks) { diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 41ef1aceaf..716f3d19b9 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -792,12 +792,11 @@ static const uint32_t signtext_filter[4] = {[kMTMetaSignText] = kMTFilterSelect /// @param clear kFalse, kTrue or kNone for an, added/deleted, cleared, or initialized range. void buf_signcols_count_range(buf_T *buf, int row1, int row2, int add, TriState clear) { - if (!buf->b_signcols.autom || !buf_meta_total(buf, kMTMetaSignText)) { + if (!buf->b_signcols.autom || row2 < row1 || !buf_meta_total(buf, kMTMetaSignText)) { return; } // Allocate an array of integers holding the number of signs in the range. - assert(row2 >= row1); int *count = xcalloc(sizeof(int), (size_t)(row2 + 1 - row1)); MarkTreeIter itr[1]; MTPair pair = { 0 }; diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 6a3eabc467..d2137da48d 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2071,14 +2071,13 @@ M.funcs = { The result is a Number: 1 exists 0 does not exist - -1 not implemented on this system |exepath()| can be used to get the full path of an executable. ]=], fast = true, name = 'executable', params = { { 'expr', 'any' } }, - returns = '0|1|-1', + returns = '0|1', signature = 'executable({expr})', }, execute = { @@ -2481,6 +2480,7 @@ M.funcs = { 't' Handle keys as if typed; otherwise they are handled as if coming from a mapping. This matters for undo, opening folds, etc. + 'L' Lowlevel input. Other flags are not used. 'i' Insert the string instead of appending (see above). 'x' Execute commands until typeahead is empty. This is similar to using ":normal!". You can call feedkeys() diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index 608aeb4c15..f77d686c10 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -90,7 +90,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) int status; if ((status = uv_spawn(&proc->loop->uv, &uvproc->uv, &uvproc->uvopts))) { - DLOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status)); + ILOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status)); if (uvproc->uvopts.env) { os_free_fullenv(uvproc->uvopts.env); } diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d754150089..b7f4f269e1 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -212,10 +212,24 @@ void dialog_changed(buf_T *buf, bool checkall) } if (ret == VIM_YES) { - if (buf->b_fname != NULL - && check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) { + bool empty_bufname = buf->b_fname == NULL; + if (empty_bufname) { + buf_set_name(buf->b_fnum, "Untitled"); + } + + if (check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) { // didn't hit Cancel - buf_write_all(buf, false); + if (buf_write_all(buf, false) == OK) { + return; + } + } + + // restore to empty when write failed + if (empty_bufname) { + XFREE_CLEAR(buf->b_fname); + XFREE_CLEAR(buf->b_ffname); + XFREE_CLEAR(buf->b_sfname); + unchanged(buf, true, false); } } else if (ret == VIM_NO) { unchanged(buf, true, false); diff --git a/src/nvim/math.c b/src/nvim/math.c index 39d166bb53..2fd9cd6ce7 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -56,7 +56,7 @@ int xctz(uint64_t x) // Use compiler builtin if possible. #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4)) return __builtin_ctzll(x); -#elif defined(_MSC_VER) +#elif defined(HAVE_BITSCANFORWARD64) unsigned long index; _BitScanForward64(&index, x); return (int)index; diff --git a/src/nvim/message.c b/src/nvim/message.c index 68a8b8e88b..362dc2c05a 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3395,9 +3395,7 @@ int do_dialog(int type, const char *title, const char *message, const char *butt int retval = 0; int i; - if (silent_mode // No dialogs in silent mode ("ex -s") - || !ui_active() // Without a UI Nvim waits for input forever. - ) { + if (silent_mode) { // No dialogs in silent mode ("ex -s") return dfltbutton; // return default option } @@ -3414,6 +3412,12 @@ int do_dialog(int type, const char *title, const char *message, const char *butt char *hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); while (true) { + // Without a UI Nvim waits for input forever. + if (!ui_active() && !input_available()) { + retval = dfltbutton; + break; + } + // Get a typed character directly from the user. int c = get_keystroke(NULL); switch (c) { diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 5218e50df6..60b5b48745 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -247,6 +247,13 @@ bool os_isatty(int fd) return uv_guess_handle(fd) == UV_TTY; } +void input_enqueue_raw(String keys) +{ + if (keys.size > 0) { + rbuffer_write(input_buffer, keys.data, keys.size); + } +} + size_t input_enqueue(String keys) { const char *ptr = keys.data; diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index c427206764..1722bcc968 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -105,14 +105,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on colnr_T col; bool did_do_comment = false; - // Cursor is currently at the end of line. No need to format - // if line length is less than textwidth (8 * textwidth for - // utf safety) - if (curwin->w_cursor.col < 8 * textwidth) { - colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); - if (virtcol <= (colnr_T)textwidth) { - break; - } + colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); + if (virtcol <= (colnr_T)textwidth) { + break; } if (no_leader) { @@ -160,16 +155,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on coladvance(curwin, (colnr_T)textwidth); wantcol = curwin->w_cursor.col; - // If startcol is large (a long line), formatting takes too much - // time. The algorithm is O(n^2), it walks from the end of the - // line to textwidth border every time for each line break. - // - // Ceil to 8 * textwidth to optimize. - curwin->w_cursor.col = startcol < 8 * textwidth ? startcol : 8 * textwidth; - + curwin->w_cursor.col = startcol; foundcol = 0; int skip_pos = 0; - bool first_pass = true; // Find position to break at. // Stop at first entered white when 'formatoptions' has 'v' @@ -177,9 +165,8 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on || (flags & INSCHAR_FORMAT) || curwin->w_cursor.lnum != Insstart.lnum || curwin->w_cursor.col >= Insstart.col) { - if (first_pass && c != NUL) { + if (curwin->w_cursor.col == startcol && c != NUL) { cc = c; - first_pass = false; } else { cc = gchar_cursor(); } diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 506bb93f5b..98751c8952 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -723,7 +723,7 @@ void ui_call_event(char *name, Array args) handled = true; } if (ERROR_SET(&err)) { - ELOG("Error while executing ui_comp_event callback: %s", err.msg); + ELOG("Error executing UI event callback: %s", err.msg); } api_clear_error(&err); }) diff --git a/src/nvim/version.c b/src/nvim/version.c index 5443371ba7..c392362bf4 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1667,7 +1667,7 @@ static const int included_patches[] = { 818, 817, 816, - // 815, + 815, 814, 813, 812, diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index ea942172ab..25b0405571 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -1374,12 +1374,7 @@ describe('api/buf', function() -- immediate call to nvim_win_get_cursor should have returned the same position eq({ 2, 12 }, cursor) -- coladd should be 0 - eq( - 0, - exec_lua([[ - return vim.fn.winsaveview().coladd - ]]) - ) + eq(0, fn.winsaveview().coladd) end) it('does not change cursor screen column when cursor >EOL and row got shorter', function() @@ -1393,9 +1388,7 @@ describe('api/buf', function() -- turn on virtualedit command('set virtualedit=all') -- move cursor after eol - exec_lua([[ - vim.fn.winrestview({ coladd = 5 }) - ]]) + fn.winrestview({ coladd = 5 }) local cursor = exec_lua([[ vim.api.nvim_buf_set_text(0, 0, 15, 2, 11, { @@ -1414,12 +1407,7 @@ describe('api/buf', function() -- immediate call to nvim_win_get_cursor should have returned the same position eq({ 2, 26 }, cursor) -- coladd should be increased so that cursor stays in the same screen column - eq( - 13, - exec_lua([[ - return vim.fn.winsaveview().coladd - ]]) - ) + eq(13, fn.winsaveview().coladd) end) it( @@ -1435,9 +1423,7 @@ describe('api/buf', function() -- turn on virtualedit command('set virtualedit=all') -- move cursor after eol - exec_lua([[ - vim.fn.winrestview({ coladd = 21 }) - ]]) + fn.winrestview({ coladd = 21 }) local cursor = exec_lua([[ vim.api.nvim_buf_set_text(0, 0, 15, 2, 11, { @@ -1456,12 +1442,7 @@ describe('api/buf', function() -- immediate call to nvim_win_get_cursor should have returned the same position eq({ 1, 38 }, cursor) -- coladd should be increased so that cursor stays in the same screen column - eq( - 2, - exec_lua([[ - return vim.fn.winsaveview().coladd - ]]) - ) + eq(2, fn.winsaveview().coladd) end ) @@ -1478,9 +1459,7 @@ describe('api/buf', function() -- turn on virtualedit command('set virtualedit=all') -- move cursor after eol just a bit - exec_lua([[ - vim.fn.winrestview({ coladd = 3 }) - ]]) + fn.winrestview({ coladd = 3 }) local cursor = exec_lua([[ vim.api.nvim_buf_set_text(0, 0, 15, 2, 11, { @@ -1499,12 +1478,7 @@ describe('api/buf', function() -- immediate call to nvim_win_get_cursor should have returned the same position eq({ 1, 22 }, cursor) -- coladd should become 0 - eq( - 0, - exec_lua([[ - return vim.fn.winsaveview().coladd - ]]) - ) + eq(0, fn.winsaveview().coladd) end ) @@ -1522,9 +1496,7 @@ describe('api/buf', function() -- turn on virtualedit command('set virtualedit=all') -- move cursor after eol - exec_lua([[ - vim.fn.winrestview({ coladd = 28 }) - ]]) + fn.winrestview({ coladd = 28 }) local cursor = exec_lua([[ vim.api.nvim_buf_set_text(0, 0, 15, 3, 11, { @@ -1543,12 +1515,7 @@ describe('api/buf', function() -- immediate call to nvim_win_get_cursor should have returned the same position eq({ 2, 26 }, cursor) -- coladd should be increased so that cursor stays in the same screen column - eq( - 13, - exec_lua([[ - return vim.fn.winsaveview().coladd - ]]) - ) + eq(13, fn.winsaveview().coladd) end ) end) diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 0decd710e9..4380e76486 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -738,7 +738,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end end - it('can set mappings containing literal keycodes', function() + it('can set mappings containing C0 control codes', function() api.nvim_set_keymap('n', '\n\r\n', 'rhs', {}) local expected = generate_mapargs('n', '<NL><CR><NL>', 'rhs') eq(expected, get_mapargs('n', '<NL><CR><NL>')) diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index d1608a951c..9b411c0c3f 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -6,6 +6,7 @@ local api = helpers.api local exec_lua = helpers.exec_lua local retry = helpers.retry local assert_alive = helpers.assert_alive +local check_close = helpers.check_close local testlog = 'Xtest-server-notify-log' @@ -18,6 +19,7 @@ describe('notify', function() end) after_each(function() + check_close() os.remove(testlog) end) diff --git a/test/functional/autocmd/autocmd_oldtest_spec.lua b/test/functional/autocmd/autocmd_oldtest_spec.lua index 279eb495e7..f1d891cddf 100644 --- a/test/functional/autocmd/autocmd_oldtest_spec.lua +++ b/test/functional/autocmd/autocmd_oldtest_spec.lua @@ -8,6 +8,7 @@ local fn = helpers.fn local exec = helpers.exec local feed = helpers.feed local assert_log = helpers.assert_log +local check_close = helpers.check_close local is_os = helpers.is_os local testlog = 'Xtest_autocmd_oldtest_log' @@ -16,6 +17,7 @@ describe('oldtests', function() before_each(clear) after_each(function() + check_close() os.remove(testlog) end) diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 5fffb70095..8fa0ccec5a 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -371,6 +371,31 @@ describe('autocmd', function() assert_alive() screen:expect_unchanged() + -- Also check with win_splitmove(). + exec_lua [[ + vim.api.nvim_buf_call(_G.buf, function() + vim.fn.win_splitmove(vim.fn.winnr(), vim.fn.win_getid(1)) + end) + ]] + screen:expect_unchanged() + + -- Also check with nvim_win_set_config(). + matches( + ': Failed to move window %d+ into split$', + pcall_err( + exec_lua, + [[ + vim.api.nvim_buf_call(_G.buf, function() + vim.api.nvim_win_set_config(0, { + vertical = true, + win = vim.fn.win_getid(1) + }) + end) + ]] + ) + ) + screen:expect_unchanged() + -- Ensure splitting still works from inside the aucmd_win. exec_lua [[vim.api.nvim_buf_call(_G.buf, function() vim.cmd "split" end)]] screen:expect [[ @@ -391,12 +416,12 @@ describe('autocmd', function() eq( 'editor', exec_lua [[ - vim.cmd "only" - vim.api.nvim_buf_call(_G.buf, function() - _G.config = vim.api.nvim_win_get_config(0) - end) - return _G.config.relative - ]] + vim.cmd "only" + vim.api.nvim_buf_call(_G.buf, function() + _G.config = vim.api.nvim_win_get_config(0) + end) + return _G.config.relative + ]] ) end) @@ -437,11 +462,11 @@ describe('autocmd', function() pcall_err( exec_lua, [[ - vim.api.nvim_buf_call(_G.buf, function() - local win = vim.api.nvim_get_current_win() - vim.api.nvim_win_close(win, true) - end) - ]] + vim.api.nvim_buf_call(_G.buf, function() + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_close(win, true) + end) + ]] ) ) matches( @@ -449,12 +474,12 @@ describe('autocmd', function() pcall_err( exec_lua, [[ - vim.api.nvim_buf_call(_G.buf, function() - local win = vim.api.nvim_get_current_win() - vim.cmd('tabnext') - vim.api.nvim_win_close(win, true) - end) - ]] + vim.api.nvim_buf_call(_G.buf, function() + local win = vim.api.nvim_get_current_win() + vim.cmd('tabnext') + vim.api.nvim_win_close(win, true) + end) + ]] ) ) matches( @@ -462,11 +487,11 @@ describe('autocmd', function() pcall_err( exec_lua, [[ - vim.api.nvim_buf_call(_G.buf, function() - local win = vim.api.nvim_get_current_win() - vim.api.nvim_win_hide(win) - end) - ]] + vim.api.nvim_buf_call(_G.buf, function() + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_hide(win) + end) + ]] ) ) matches( @@ -474,12 +499,12 @@ describe('autocmd', function() pcall_err( exec_lua, [[ - vim.api.nvim_buf_call(_G.buf, function() - local win = vim.api.nvim_get_current_win() - vim.cmd('tabnext') - vim.api.nvim_win_hide(win) - end) - ]] + vim.api.nvim_buf_call(_G.buf, function() + local win = vim.api.nvim_get_current_win() + vim.cmd('tabnext') + vim.api.nvim_win_hide(win) + end) + ]] ) ) end) diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index adf29cbe7c..bd3db02874 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -32,6 +32,7 @@ local dedent = helpers.dedent local tbl_map = vim.tbl_map local tbl_filter = vim.tbl_filter local endswith = vim.endswith +local check_close = helpers.check_close local testlog = 'Xtest-startupspec-log' @@ -101,15 +102,7 @@ describe('startup', function() VIMRUNTIME = os.getenv('VIMRUNTIME'), }, }) - screen:expect([[ - ^ | - | - Entering Debug mode. Type "cont" to continue. | - nvim_exec2() | - cmd: aunmenu * | - > | - | - ]]) + screen:expect({ any = pesc('Entering Debug mode. Type "cont" to continue.') }) fn.chansend(id, 'cont\n') screen:expect([[ ^ | @@ -124,6 +117,7 @@ describe('startup', function() before_each(clear) after_each(function() + check_close() os.remove(testlog) end) diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 42a1248464..f806869b40 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -110,7 +110,8 @@ local tests = {} function tests.basic_init() skeleton { - on_init = function(_) + on_init = function(params) + assert_eq(params.workDoneToken, '1') return { capabilities = { textDocumentSync = protocol.TextDocumentSyncKind.None, diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index caa14a480b..e5b0819d12 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -37,9 +37,9 @@ module.nvim_argv = { runtime_set, '--cmd', module.nvim_set, - -- Remove default mappings. + -- Remove default user commands and mappings. '--cmd', - 'mapclear | mapclear!', + 'comclear | mapclear | mapclear!', -- Make screentest work after changing to the new default color scheme -- Source 'vim' color scheme without side effects -- TODO: rewrite tests diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua deleted file mode 100644 index b3964540f0..0000000000 --- a/test/functional/legacy/buffer_spec.lua +++ /dev/null @@ -1,59 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local call, eq, api = helpers.call, helpers.eq, helpers.api - -local function expected_empty() - eq({}, api.nvim_get_vvar('errors')) -end - -describe('buffer', function() - before_each(function() - clear() - api.nvim_ui_attach(80, 24, {}) - api.nvim_set_option_value('hidden', false, {}) - end) - - it('deleting a modified buffer with :confirm', function() - source([[ - func Test_bdel_with_confirm() - new - call setline(1, 'test') - call assert_fails('bdel', 'E89:') - call nvim_input('c') - confirm bdel - call assert_equal(2, winnr('$')) - call assert_equal(1, &modified) - call nvim_input('n') - confirm bdel - call assert_equal(1, winnr('$')) - endfunc - ]]) - call('Test_bdel_with_confirm') - expected_empty() - end) - - it('editing another buffer from a modified buffer with :confirm', function() - source([[ - func Test_goto_buf_with_confirm() - new Xfile - enew - call setline(1, 'test') - call assert_fails('b Xfile', 'E37:') - call nvim_input('c') - call assert_fails('confirm b Xfile', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) - call nvim_input('y') - call assert_fails('confirm b Xfile', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) - call nvim_input('n') - confirm b Xfile - call assert_equal('Xfile', @%) - close! - endfunc - ]]) - call('Test_goto_buf_with_confirm') - expected_empty() - end) -end) diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua deleted file mode 100644 index 46ecfdcd63..0000000000 --- a/test/functional/legacy/filechanged_spec.lua +++ /dev/null @@ -1,142 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source -local call, eq, api = helpers.call, helpers.eq, helpers.api -local is_os = helpers.is_os -local skip = helpers.skip - -local function expected_empty() - eq({}, api.nvim_get_vvar('errors')) -end - -describe('file changed dialog', function() - before_each(function() - clear() - api.nvim_ui_attach(80, 24, {}) - api.nvim_set_option_value('autoread', false, {}) - api.nvim_set_option_value('fsync', true, {}) - end) - - it('works', function() - skip(is_os('win')) - source([[ - func Test_file_changed_dialog() - au! FileChangedShell - - new Xchanged_d - call setline(1, 'reload this') - write - " Need to wait until the timestamp would change by at least a second. - sleep 2 - silent !echo 'extra line' >>Xchanged_d - call nvim_input('L') - checktime - call assert_match('W11:', v:warningmsg) - call assert_equal(2, line('$')) - call assert_equal('reload this', getline(1)) - call assert_equal('extra line', getline(2)) - - " delete buffer, only shows an error, no prompt - silent !rm Xchanged_d - checktime - call assert_match('E211:', v:warningmsg) - call assert_equal(2, line('$')) - call assert_equal('extra line', getline(2)) - let v:warningmsg = 'empty' - - " change buffer, recreate the file and reload - call setline(1, 'buffer is changed') - silent !echo 'new line' >Xchanged_d - call nvim_input('L') - checktime - call assert_match('W12:', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " Only mode changed, reload - silent !chmod +x Xchanged_d - call nvim_input('L') - checktime - call assert_match('W16:', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " Only time changed, no prompt - sleep 2 - silent !touch Xchanged_d - let v:warningmsg = '' - checktime Xchanged_d - call assert_equal('', v:warningmsg) - call assert_equal(1, line('$')) - call assert_equal('new line', getline(1)) - - " File created after starting to edit it - call delete('Xchanged_d') - new Xchanged_d - call writefile(['one'], 'Xchanged_d') - call nvim_input('L') - checktime Xchanged_d - call assert_equal(['one'], getline(1, '$')) - close! - - bwipe! - call delete('Xchanged_d') - endfunc - ]]) - call('Test_file_changed_dialog') - expected_empty() - end) - - it('works with FileChangedShell', function() - source([[ - func Test_FileChangedShell_edit_dialog() - new Xchanged_r - call setline(1, 'reload this') - set fileformat=unix - silent write " Use :silent to prevent a hit-enter prompt - - " File format changed, reload (content only) via prompt - augroup testreload - au! - au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' - augroup END - call assert_equal(&fileformat, 'unix') - sleep 10m " make the test less flaky in Nvim - call writefile(["line1\r", "line2\r"], 'Xchanged_r') - let g:reason = '' - call nvim_input('L') " load file content only - checktime - call assert_equal('changed', g:reason) - call assert_equal(&fileformat, 'unix') - call assert_equal("line1\r", getline(1)) - call assert_equal("line2\r", getline(2)) - %s/\r - silent write " Use :silent to prevent a hit-enter prompt - - " File format changed, reload (file and options) via prompt - augroup testreload - au! - au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' - augroup END - call assert_equal(&fileformat, 'unix') - sleep 10m " make the test less flaky in Nvim - call writefile(["line1\r", "line2\r"], 'Xchanged_r') - let g:reason = '' - call nvim_input('a') " load file content and options - checktime - call assert_equal('changed', g:reason) - call assert_equal(&fileformat, 'dos') - call assert_equal("line1", getline(1)) - call assert_equal("line2", getline(2)) - set fileformat=unix - silent write " Use :silent to prevent a hit-enter prompt - - au! testreload - bwipe! - call delete(undofile('Xchanged_r')) - call delete('Xchanged_r') - endfunc - ]]) - call('Test_FileChangedShell_edit_dialog') - expected_empty() - end) -end) diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua new file mode 100644 index 0000000000..72935c47d5 --- /dev/null +++ b/test/functional/lua/comment_spec.lua @@ -0,0 +1,644 @@ +local helpers = require('test.functional.helpers')(after_each) + +local api = helpers.api +local clear = helpers.clear +local eq = helpers.eq +local exec_capture = helpers.exec_capture +local exec_lua = helpers.exec_lua +local feed = helpers.feed + +-- Reference text +-- aa +-- aa +-- aa +-- +-- aa +-- aa +-- aa +local example_lines = { 'aa', ' aa', ' aa', '', ' aa', ' aa', 'aa' } + +local set_commentstring = function(commentstring) + api.nvim_set_option_value('commentstring', commentstring, { buf = 0 }) +end + +local get_lines = function(from, to) + from, to = from or 0, to or -1 + return api.nvim_buf_get_lines(0, from, to, false) +end + +local set_lines = function(lines, from, to) + from, to = from or 0, to or -1 + api.nvim_buf_set_lines(0, from, to, false, lines) +end + +local set_cursor = function(row, col) + api.nvim_win_set_cursor(0, { row, col }) +end + +local get_cursor = function() + return api.nvim_win_get_cursor(0) +end + +local setup_treesitter = function() + -- NOTE: This leverages bundled Vimscript and Lua tree-sitter parsers + api.nvim_set_option_value('filetype', 'vim', { buf = 0 }) + exec_lua('vim.treesitter.start()') +end + +before_each(function() + clear({ args_rm = { '--cmd' }, args = { '--clean' } }) +end) + +describe('commenting', function() + before_each(function() + set_lines(example_lines) + set_commentstring('# %s') + end) + + describe('toggle_lines()', function() + local toggle_lines = function(...) + exec_lua('require("vim._comment").toggle_lines(...)', ...) + end + + it('works', function() + toggle_lines(3, 5) + eq(get_lines(2, 5), { ' # aa', ' #', ' # aa' }) + + toggle_lines(3, 5) + eq(get_lines(2, 5), { ' aa', '', ' aa' }) + end) + + it("works with different 'commentstring' options", function() + local validate = function(lines_before, lines_after, lines_again) + set_lines(lines_before) + toggle_lines(1, #lines_before) + eq(get_lines(), lines_after) + toggle_lines(1, #lines_before) + eq(get_lines(), lines_again or lines_before) + end + + -- Single whitespace inside comment parts (main case) + set_commentstring('# %s #') + -- - General case + validate( + { 'aa', ' aa', 'aa ', ' aa ' }, + { '# aa #', '# aa #', '# aa #', '# aa #' } + ) + -- - Tabs + validate( + { 'aa', '\taa', 'aa\t', '\taa\t' }, + { '# aa #', '# \taa #', '# aa\t #', '# \taa\t #' } + ) + -- - With indent + validate({ ' aa', ' aa' }, { ' # aa #', ' # aa #' }) + -- - With blank/empty lines + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa #', ' ##', ' ##', ' ##' }, + { ' aa', '', '', '' } + ) + + set_commentstring('# %s') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { '# aa', '# aa', '# aa ', '# aa ' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { '# aa', '# \taa', '# aa\t', '# \taa\t' }) + validate({ ' aa', ' aa' }, { ' # aa', ' # aa' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + set_commentstring('%s #') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { 'aa #', ' aa #', 'aa #', ' aa #' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { 'aa #', '\taa #', 'aa\t #', '\taa\t #' }) + validate({ ' aa', ' aa' }, { ' aa #', ' aa #' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' aa #', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + -- No whitespace in parts + set_commentstring('#%s#') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { '#aa#', '# aa#', '#aa #', '# aa #' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { '#aa#', '#\taa#', '#aa\t#', '#\taa\t#' }) + validate({ ' aa', ' aa' }, { ' #aa#', ' # aa#' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' #aa#', ' ##', ' ##', ' ##' }, + { ' aa', '', '', '' } + ) + + set_commentstring('#%s') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { '#aa', '# aa', '#aa ', '# aa ' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { '#aa', '#\taa', '#aa\t', '#\taa\t' }) + validate({ ' aa', ' aa' }, { ' #aa', ' # aa' }) + validate({ ' aa', '', ' ', '\t' }, { ' #aa', ' #', ' #', ' #' }, { ' aa', '', '', '' }) + + set_commentstring('%s#') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { 'aa#', ' aa#', 'aa #', ' aa #' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { 'aa#', '\taa#', 'aa\t#', '\taa\t#' }) + validate({ ' aa', ' aa' }, { ' aa#', ' aa#' }) + validate({ ' aa', '', ' ', '\t' }, { ' aa#', ' #', ' #', ' #' }, { ' aa', '', '', '' }) + + -- Extra whitespace inside comment parts + set_commentstring('# %s #') + validate( + { 'aa', ' aa', 'aa ', ' aa ' }, + { '# aa #', '# aa #', '# aa #', '# aa #' } + ) + validate( + { 'aa', '\taa', 'aa\t', '\taa\t' }, + { '# aa #', '# \taa #', '# aa\t #', '# \taa\t #' } + ) + validate({ ' aa', ' aa' }, { ' # aa #', ' # aa #' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa #', ' ##', ' ##', ' ##' }, + { ' aa', '', '', '' } + ) + + set_commentstring('# %s') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { '# aa', '# aa', '# aa ', '# aa ' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { '# aa', '# \taa', '# aa\t', '# \taa\t' }) + validate({ ' aa', ' aa' }, { ' # aa', ' # aa' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + set_commentstring('%s #') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { 'aa #', ' aa #', 'aa #', ' aa #' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { 'aa #', '\taa #', 'aa\t #', '\taa\t #' }) + validate({ ' aa', ' aa' }, { ' aa #', ' aa #' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' aa #', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + -- Whitespace outside of comment parts + set_commentstring(' # %s # ') + validate( + { 'aa', ' aa', 'aa ', ' aa ' }, + { ' # aa # ', ' # aa # ', ' # aa # ', ' # aa # ' } + ) + validate( + { 'aa', '\taa', 'aa\t', '\taa\t' }, + { ' # aa # ', ' # \taa # ', ' # aa\t # ', ' # \taa\t # ' } + ) + validate({ ' aa', ' aa' }, { ' # aa # ', ' # aa # ' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa # ', ' ##', ' ##', ' ##' }, + { ' aa', '', '', '' } + ) + + set_commentstring(' # %s ') + validate( + { 'aa', ' aa', 'aa ', ' aa ' }, + { ' # aa ', ' # aa ', ' # aa ', ' # aa ' } + ) + validate( + { 'aa', '\taa', 'aa\t', '\taa\t' }, + { ' # aa ', ' # \taa ', ' # aa\t ', ' # \taa\t ' } + ) + validate({ ' aa', ' aa' }, { ' # aa ', ' # aa ' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' # aa ', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + set_commentstring(' %s # ') + validate( + { 'aa', ' aa', 'aa ', ' aa ' }, + { ' aa # ', ' aa # ', ' aa # ', ' aa # ' } + ) + validate( + { 'aa', '\taa', 'aa\t', '\taa\t' }, + { ' aa # ', ' \taa # ', ' aa\t # ', ' \taa\t # ' } + ) + validate({ ' aa', ' aa' }, { ' aa # ', ' aa # ' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' aa # ', ' #', ' #', ' #' }, + { ' aa', '', '', '' } + ) + + -- LaTeX + set_commentstring('% %s') + validate({ 'aa', ' aa', 'aa ', ' aa ' }, { '% aa', '% aa', '% aa ', '% aa ' }) + validate({ 'aa', '\taa', 'aa\t', '\taa\t' }, { '% aa', '% \taa', '% aa\t', '% \taa\t' }) + validate({ ' aa', ' aa' }, { ' % aa', ' % aa' }) + validate( + { ' aa', '', ' ', '\t' }, + { ' % aa', ' %', ' %', ' %' }, + { ' aa', '', '', '' } + ) + end) + + it('respects tree-sitter injections', function() + setup_treesitter() + + local lines = { + 'set background=dark', + 'lua << EOF', + 'print(1)', + 'vim.api.nvim_exec2([[', + ' set background=light', + ']])', + 'EOF', + } + + -- Single line comments + local validate = function(line, ref_output) + set_lines(lines) + toggle_lines(line, line) + eq(get_lines(line - 1, line)[1], ref_output) + end + + validate(1, '"set background=dark') + validate(2, '"lua << EOF') + validate(3, '-- print(1)') + validate(4, '-- vim.api.nvim_exec2([[') + validate(5, ' "set background=light') + validate(6, '-- ]])') + validate(7, '"EOF') + + -- Multiline comments should be computed based on first line 'commentstring' + set_lines(lines) + toggle_lines(1, 3) + local out_lines = get_lines() + eq(out_lines[1], '"set background=dark') + eq(out_lines[2], '"lua << EOF') + eq(out_lines[3], '"print(1)') + end) + + it('correctly computes indent', function() + toggle_lines(2, 4) + eq(get_lines(1, 4), { ' # aa', ' # aa', ' #' }) + end) + + it('correctly detects comment/uncomment', function() + local validate = function(from, to, ref_lines) + set_lines({ '', 'aa', '# aa', '# aa', 'aa', '' }) + toggle_lines(from, to) + eq(get_lines(), ref_lines) + end + + -- It should uncomment only if all non-blank lines are comments + validate(3, 4, { '', 'aa', 'aa', 'aa', 'aa', '' }) + validate(2, 4, { '', '# aa', '# # aa', '# # aa', 'aa', '' }) + validate(3, 5, { '', 'aa', '# # aa', '# # aa', '# aa', '' }) + validate(1, 6, { '#', '# aa', '# # aa', '# # aa', '# aa', '#' }) + + -- Blank lines should be ignored when making a decision + set_lines({ '# aa', '', ' ', '\t', '# aa' }) + toggle_lines(1, 5) + eq(get_lines(), { 'aa', '', ' ', '\t', 'aa' }) + end) + + it('matches comment parts strictly when detecting comment/uncomment', function() + local validate = function(from, to, ref_lines) + set_lines({ '#aa', '# aa', '# aa' }) + toggle_lines(from, to) + eq(get_lines(), ref_lines) + end + + set_commentstring('#%s') + validate(1, 3, { 'aa', ' aa', ' aa' }) + validate(2, 3, { '#aa', ' aa', ' aa' }) + validate(3, 3, { '#aa', '# aa', ' aa' }) + + set_commentstring('# %s') + validate(1, 3, { '# #aa', '# # aa', '# # aa' }) + validate(2, 3, { '#aa', 'aa', ' aa' }) + validate(3, 3, { '#aa', '# aa', ' aa' }) + + set_commentstring('# %s') + validate(1, 3, { '# #aa', '# # aa', '# # aa' }) + validate(2, 3, { '#aa', '# # aa', '# # aa' }) + validate(3, 3, { '#aa', '# aa', 'aa' }) + end) + + it('uncomments on inconsistent indent levels', function() + set_lines({ '# aa', ' # aa', ' # aa' }) + toggle_lines(1, 3) + eq(get_lines(), { 'aa', ' aa', ' aa' }) + end) + + it('respects tabs', function() + api.nvim_set_option_value('expandtab', false, { buf = 0 }) + set_lines({ '\t\taa', '\t\taa' }) + + toggle_lines(1, 2) + eq(get_lines(), { '\t\t# aa', '\t\t# aa' }) + + toggle_lines(1, 2) + eq(get_lines(), { '\t\taa', '\t\taa' }) + end) + + it('works with trailing whitespace', function() + -- Without right-hand side + set_commentstring('# %s') + set_lines({ ' aa', ' aa ', ' ' }) + toggle_lines(1, 3) + eq(get_lines(), { ' # aa', ' # aa ', ' #' }) + toggle_lines(1, 3) + eq(get_lines(), { ' aa', ' aa ', '' }) + + -- With right-hand side + set_commentstring('%s #') + set_lines({ ' aa', ' aa ', ' ' }) + toggle_lines(1, 3) + eq(get_lines(), { ' aa #', ' aa #', ' #' }) + toggle_lines(1, 3) + eq(get_lines(), { ' aa', ' aa ', '' }) + + -- Trailing whitespace after right side should be preserved for non-blanks + set_commentstring('%s #') + set_lines({ ' aa # ', ' aa #\t', ' # ', ' #\t' }) + toggle_lines(1, 4) + eq(get_lines(), { ' aa ', ' aa\t', '', '' }) + end) + end) + + describe('Operator', function() + it('works in Normal mode', function() + set_cursor(2, 2) + feed('gc', 'ap') + eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }) + -- Cursor moves to start line + eq(get_cursor(), { 1, 0 }) + + -- Supports `v:count` + set_lines(example_lines) + set_cursor(2, 0) + feed('2gc', 'ap') + eq(get_lines(), { '# aa', '# aa', '# aa', '#', '# aa', '# aa', '# aa' }) + end) + + it('allows dot-repeat in Normal mode', function() + local doubly_commented = { '# # aa', '# # aa', '# # aa', '# #', '# aa', '# aa', '# aa' } + + set_lines(example_lines) + set_cursor(2, 2) + feed('gc', 'ap') + feed('.') + eq(get_lines(), doubly_commented) + + -- Not immediate dot-repeat + set_lines(example_lines) + set_cursor(2, 2) + feed('gc', 'ap') + set_cursor(7, 0) + feed('.') + eq(get_lines(), doubly_commented) + end) + + it('works in Visual mode', function() + set_cursor(2, 2) + feed('v', 'ap', 'gc') + eq(get_lines(), { '# aa', '# aa', '# aa', '#', ' aa', ' aa', 'aa' }) + + -- Cursor moves to start line + eq(get_cursor(), { 1, 0 }) + end) + + it('allows dot-repeat after initial Visual mode', function() + -- local example_lines = { 'aa', ' aa', ' aa', '', ' aa', ' aa', 'aa' } + + set_lines(example_lines) + set_cursor(2, 2) + feed('vip', 'gc') + eq(get_lines(), { '# aa', '# aa', '# aa', '', ' aa', ' aa', 'aa' }) + eq(get_cursor(), { 1, 0 }) + + -- Dot-repeat after first application in Visual mode should apply to the same + -- relative region + feed('.') + eq(get_lines(), example_lines) + + set_cursor(3, 0) + feed('.') + eq(get_lines(), { 'aa', ' aa', ' # aa', ' #', ' # aa', ' aa', 'aa' }) + end) + + it("respects 'commentstring'", function() + set_commentstring('/*%s*/') + set_cursor(2, 2) + feed('gc', 'ap') + eq(get_lines(), { '/*aa*/', '/* aa*/', '/* aa*/', '/**/', ' aa', ' aa', 'aa' }) + end) + + it("works with empty 'commentstring'", function() + set_commentstring('') + set_cursor(2, 2) + feed('gc', 'ap') + eq(get_lines(), example_lines) + eq(exec_capture('1messages'), [[Option 'commentstring' is empty.]]) + end) + + it('respects tree-sitter injections', function() + setup_treesitter() + + local lines = { + 'set background=dark', + 'lua << EOF', + 'print(1)', + 'vim.api.nvim_exec2([[', + ' set background=light', + ']])', + 'EOF', + } + + -- Single line comments + local validate = function(line, ref_output) + set_lines(lines) + set_cursor(line, 0) + feed('gc_') + eq(get_lines(line - 1, line)[1], ref_output) + end + + validate(1, '"set background=dark') + validate(2, '"lua << EOF') + validate(3, '-- print(1)') + validate(4, '-- vim.api.nvim_exec2([[') + validate(5, ' "set background=light') + validate(6, '-- ]])') + validate(7, '"EOF') + + -- Has proper dot-repeat which recomputes 'commentstring' + set_lines(lines) + + set_cursor(1, 0) + feed('gc_') + eq(get_lines()[1], '"set background=dark') + + set_cursor(3, 0) + feed('.') + eq(get_lines()[3], '-- print(1)') + + -- Multiline comments should be computed based on cursor position + -- which in case of Visual selection means its left part + set_lines(lines) + set_cursor(1, 0) + feed('v2j', 'gc') + local out_lines = get_lines() + eq(out_lines[1], '"set background=dark') + eq(out_lines[2], '"lua << EOF') + eq(out_lines[3], '"print(1)') + end) + + it("recomputes local 'commentstring' based on cursor position", function() + setup_treesitter() + local lines = { + 'lua << EOF', + ' print(1)', + 'EOF', + } + set_lines(lines) + + -- Vimscript's tree-sitter grammar is (currently) written in a way that Lua's + -- injection really starts at the first non-blank character + set_cursor(2, 1) + feed('gc_') + eq(get_lines()[2], ' "print(1)') + + set_lines(lines) + set_cursor(2, 2) + feed('.') + eq(get_lines()[2], ' -- print(1)') + end) + + it('preserves marks', function() + set_cursor(2, 0) + -- Set '`<' and '`>' marks + feed('VV') + feed('gc', 'ip') + eq(api.nvim_buf_get_mark(0, '<'), { 2, 0 }) + eq(api.nvim_buf_get_mark(0, '>'), { 2, 2147483647 }) + end) + end) + + describe('Current line', function() + it('works', function() + set_lines(example_lines) + set_cursor(1, 1) + feed('gcc') + eq(get_lines(0, 2), { '# aa', ' aa' }) + + -- Does not comment empty line + set_lines(example_lines) + set_cursor(4, 0) + feed('gcc') + eq(get_lines(2, 5), { ' aa', '', ' aa' }) + + -- Supports `v:count` + set_lines(example_lines) + set_cursor(2, 0) + feed('2gcc') + eq(get_lines(0, 3), { 'aa', ' # aa', ' # aa' }) + end) + + it('allows dot-repeat', function() + set_lines(example_lines) + set_cursor(1, 1) + feed('gcc') + feed('.') + eq(get_lines(), example_lines) + + -- Not immediate dot-repeat + set_lines(example_lines) + set_cursor(1, 1) + feed('gcc') + set_cursor(7, 0) + feed('.') + eq(get_lines(6, 7), { '# aa' }) + end) + + it('respects tree-sitter injections', function() + setup_treesitter() + + local lines = { + 'set background=dark', + 'lua << EOF', + 'print(1)', + 'EOF', + } + set_lines(lines) + + set_cursor(1, 0) + feed('gcc') + eq(get_lines(), { '"set background=dark', 'lua << EOF', 'print(1)', 'EOF' }) + + -- Should work with dot-repeat + set_cursor(3, 0) + feed('.') + eq(get_lines(), { '"set background=dark', 'lua << EOF', '-- print(1)', 'EOF' }) + end) + end) + + describe('Textobject', function() + it('works', function() + set_lines({ 'aa', '# aa', '# aa', 'aa' }) + set_cursor(2, 0) + feed('d', 'gc') + eq(get_lines(), { 'aa', 'aa' }) + end) + + it('allows dot-repeat', function() + set_lines({ 'aa', '# aa', '# aa', 'aa', '# aa' }) + set_cursor(2, 0) + feed('d', 'gc') + set_cursor(3, 0) + feed('.') + eq(get_lines(), { 'aa', 'aa' }) + end) + + it('does nothing when not inside textobject', function() + -- Builtin operators + feed('d', 'gc') + eq(get_lines(), example_lines) + + -- Comment operator + local validate_no_action = function(line, col) + set_lines(example_lines) + set_cursor(line, col) + feed('gc', 'gc') + eq(get_lines(), example_lines) + end + + validate_no_action(1, 1) + validate_no_action(2, 2) + + -- Doesn't work (but should) because both `[` and `]` are set to (1, 0) + -- (instead of more reasonable (1, -1) or (0, 2147483647)). + -- validate_no_action(1, 0) + end) + + it('respects tree-sitter injections', function() + setup_treesitter() + local lines = { + '"set background=dark', + '"set termguicolors', + 'lua << EOF', + '-- print(1)', + '-- print(2)', + 'EOF', + } + set_lines(lines) + + set_cursor(1, 0) + feed('dgc') + eq(get_lines(), { 'lua << EOF', '-- print(1)', '-- print(2)', 'EOF' }) + + -- Should work with dot-repeat + set_cursor(2, 0) + feed('.') + eq(get_lines(), { 'lua << EOF', 'EOF' }) + end) + end) +end) diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 716c1e0f30..f648c0b215 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -8,6 +8,7 @@ local eq = helpers.eq local matches = helpers.matches local api = helpers.api local pcall_err = helpers.pcall_err +local fn = helpers.fn describe('vim.diagnostic', function() before_each(function() @@ -109,7 +110,7 @@ describe('vim.diagnostic', function() 'DiagnosticVirtualTextOk', 'DiagnosticVirtualTextWarn', 'DiagnosticWarn', - }, exec_lua([[return vim.fn.getcompletion('Diagnostic', 'highlight')]])) + }, fn.getcompletion('Diagnostic', 'highlight')) end) it('retrieves diagnostics from all buffers and namespaces', function() diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 3e46018682..39c51d242c 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -5,6 +5,10 @@ local exec_lua = helpers.exec_lua local clear = helpers.clear local feed = helpers.feed local fn = helpers.fn +local assert_log = helpers.assert_log +local check_close = helpers.check_close + +local testlog = 'Xtest_lua_ui_event_log' describe('vim.ui_attach', function() local screen @@ -150,3 +154,22 @@ describe('vim.ui_attach', function() }, actual, vim.inspect(actual)) end) end) + +describe('vim.ui_attach', function() + after_each(function() + check_close() + os.remove(testlog) + end) + + it('error in callback is logged', function() + clear({ env = { NVIM_LOG_FILE = testlog } }) + local screen = Screen.new() + screen:attach() + exec_lua([[ + local ns = vim.api.nvim_create_namespace('testspace') + vim.ui_attach(ns, { ext_popupmenu = true }, function() error(42) end) + ]]) + feed('ifoo<CR>foobar<CR>fo<C-X><C-N>') + assert_log('Error executing UI event callback: Error executing lua: .*: 42', testlog, 100) + end) +end) diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index 3bc9e26d41..9f953daa9e 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -5,6 +5,7 @@ local ok = helpers.ok local exec_lua = helpers.exec_lua local matches = helpers.matches local pcall_err = helpers.pcall_err +local fn = helpers.fn local function v(ver) return vim.version._version(ver) @@ -17,7 +18,7 @@ describe('version', function() end) it('version() returns Nvim version', function() - local expected = exec_lua('return vim.fn.api_info().version') + local expected = fn.api_info().version local actual = exec_lua('return vim.version()') eq(expected.major, actual.major) eq(expected.minor, actual.minor) diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 5e98453565..5bf9aa5ac9 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -20,6 +20,7 @@ local rmdir = helpers.rmdir local alter_slashes = helpers.alter_slashes local tbl_contains = vim.tbl_contains local expect_exit = helpers.expect_exit +local check_close = helpers.check_close local is_os = helpers.is_os local testlog = 'Xtest-defaults-log' @@ -274,6 +275,7 @@ describe('XDG defaults', function() -- Do not put before_each() here for the same reasons. after_each(function() + check_close() os.remove(testlog) end) @@ -866,6 +868,7 @@ end) describe('stdpath()', function() after_each(function() + check_close() os.remove(testlog) end) @@ -1227,6 +1230,8 @@ describe('stdpath()', function() end) describe('errors', function() + before_each(clear) + it('on unknown strings', function() eq('Vim(call):E6100: "capybara" is not a valid stdpath', exc_exec('call stdpath("capybara")')) eq('Vim(call):E6100: "" is not a valid stdpath', exc_exec('call stdpath("")')) @@ -1242,6 +1247,7 @@ end) describe('autocommands', function() it('closes terminal with default shell on success', function() + clear() api.nvim_set_option_value('shell', helpers.testprg('shell-test'), {}) command('set shellcmdflag=EXIT shellredir= shellpipe= shellquote= shellxquote=') diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 9306180c40..8416f0e5f7 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -8,7 +8,8 @@ local eq, neq, matches = helpers.eq, helpers.neq, helpers.matches local getcompletion = helpers.fn.getcompletion local insert = helpers.insert local source = helpers.source -local exec_lua = helpers.exec_lua +local fn = helpers.fn +local api = helpers.api describe(':checkhealth', function() it('detects invalid $VIMRUNTIME', function() @@ -381,7 +382,7 @@ describe(':checkhealth window', function() it('opens in tab', function() -- create an empty buffer called "my_buff" - exec_lua 'vim.api.nvim_create_buf(false, true)' + api.nvim_create_buf(false, true) command('file my_buff') command('checkhealth success1') -- define a function that collects all buffers in each tab @@ -400,7 +401,7 @@ describe(':checkhealth window', function() return buffs endfunction ]]) - local buffers_per_tab = exec_lua('return vim.fn.CollectBuffersPerTab()') + local buffers_per_tab = fn.CollectBuffersPerTab() eq(buffers_per_tab, { tab1 = { 'my_buff' }, tab2 = { 'health://' } }) end) end) diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua index 375bff06af..fb93746480 100644 --- a/test/functional/plugin/lsp/helpers.lua +++ b/test/functional/plugin/lsp/helpers.lua @@ -4,6 +4,7 @@ local clear = helpers.clear local exec_lua = helpers.exec_lua local run = helpers.run local stop = helpers.stop +local api = helpers.api local NIL = vim.NIL local M = {} @@ -211,7 +212,7 @@ function M.test_rpc_server(config) end stop() if config.test_name then - exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") + api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) end end diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua index b046a2c509..e9c347bcc5 100644 --- a/test/functional/plugin/lsp/inlay_hint_spec.lua +++ b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -6,6 +6,7 @@ local eq = helpers.eq local dedent = helpers.dedent local exec_lua = helpers.exec_lua local insert = helpers.insert +local api = helpers.api local clear_notrace = lsp_helpers.clear_notrace local create_server_definition = lsp_helpers.create_server_definition @@ -88,7 +89,7 @@ before_each(function() end) after_each(function() - exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") + api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) end) describe('vim.lsp.inlay_hint', function() diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua index ad09ab08b3..12f6e09e7e 100644 --- a/test/functional/plugin/lsp/semantic_tokens_spec.lua +++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua @@ -10,6 +10,7 @@ local feed = helpers.feed local feed_command = helpers.feed_command local insert = helpers.insert local matches = helpers.matches +local api = helpers.api local clear_notrace = lsp_helpers.clear_notrace local create_server_definition = lsp_helpers.create_server_definition @@ -19,7 +20,7 @@ before_each(function() end) after_each(function() - exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") + api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) end) describe('semantic token highlighting', function() diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 788cc8d6f8..c65cca6cb7 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -83,7 +83,7 @@ describe('LSP', function() end) after_each(function() - exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") + api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) -- exec_lua("lsp.stop_all_clients(true)") end) @@ -146,7 +146,7 @@ describe('LSP', function() after_each(function() stop() exec_lua('lsp.stop_client(lsp.get_clients(), true)') - exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") + api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) end) it('should run correctly', function() @@ -1803,7 +1803,7 @@ describe('LSP', function() make_edit(1, 0, 2, 5, 'foobar'), make_edit(4, 0, 5, 0, 'barfoo'), } - eq(true, exec_lua('return vim.api.nvim_buf_set_mark(1, "a", 2, 1, {})')) + eq(true, api.nvim_buf_set_mark(1, 'a', 2, 1, {})) exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16') eq({ 'First line of text', @@ -1811,7 +1811,7 @@ describe('LSP', function() 'Fourth line of text', 'barfoo', }, buf_lines(1)) - local mark = exec_lua('return vim.api.nvim_buf_get_mark(1, "a")') + local mark = api.nvim_buf_get_mark(1, 'a') eq({ 2, 1 }, mark) end) @@ -1820,7 +1820,7 @@ describe('LSP', function() make_edit(1, 0, 2, 15, 'foobar'), make_edit(4, 0, 5, 0, 'barfoo'), } - eq(true, exec_lua('return vim.api.nvim_buf_set_mark(1, "a", 2, 10, {})')) + eq(true, api.nvim_buf_set_mark(1, 'a', 2, 10, {})) exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16') eq({ 'First line of text', @@ -1828,7 +1828,7 @@ describe('LSP', function() 'Fourth line of text', 'barfoo', }, buf_lines(1)) - local mark = exec_lua('return vim.api.nvim_buf_get_mark(1, "a")') + local mark = api.nvim_buf_get_mark(1, 'a') eq({ 2, 9 }, mark) end) @@ -1837,13 +1837,13 @@ describe('LSP', function() make_edit(1, 0, 4, 5, 'foobar'), make_edit(4, 0, 5, 0, 'barfoo'), } - eq(true, exec_lua('return vim.api.nvim_buf_set_mark(1, "a", 4, 1, {})')) + eq(true, api.nvim_buf_set_mark(1, 'a', 4, 1, {})) exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1, 'utf-16') eq({ 'First line of text', 'foobaro', }, buf_lines(1)) - local mark = exec_lua('return vim.api.nvim_buf_get_mark(1, "a")') + local mark = api.nvim_buf_get_mark(1, 'a') eq({ 2, 1 }, mark) end) @@ -1911,7 +1911,7 @@ describe('LSP', function() it('fix the cursor col', function() -- append empty last line. See #22636 - exec_lua('vim.api.nvim_buf_set_lines(...)', 1, -1, -1, true, { '' }) + api.nvim_buf_set_lines(1, -1, -1, true, { '' }) api.nvim_win_set_cursor(0, { 2, 11 }) local edits = { @@ -2263,7 +2263,7 @@ describe('LSP', function() }, } exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16') - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) + eq(true, vim.uv.fs_stat(tmpfile) ~= nil) end) it( 'Supports file creation in folder that needs to be created with CreateFile payload', @@ -2281,7 +2281,7 @@ describe('LSP', function() }, } exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16') - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) + eq(true, vim.uv.fs_stat(tmpfile) ~= nil) end ) it('createFile does not touch file if it exists and ignoreIfExists is set', function() @@ -2300,7 +2300,7 @@ describe('LSP', function() }, } exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16') - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) + eq(true, vim.uv.fs_stat(tmpfile) ~= nil) eq('Dummy content', read_file(tmpfile)) end) it('createFile overrides file if overwrite is set', function() @@ -2320,7 +2320,7 @@ describe('LSP', function() }, } exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16') - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) + eq(true, vim.uv.fs_stat(tmpfile) ~= nil) eq('', read_file(tmpfile)) end) it('DeleteFile delete file and buffer', function() @@ -2344,8 +2344,8 @@ describe('LSP', function() }, } eq(true, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) - eq(false, exec_lua('return vim.api.nvim_buf_is_loaded(vim.fn.bufadd(...))', tmpfile)) + eq(false, vim.uv.fs_stat(tmpfile) ~= nil) + eq(false, api.nvim_buf_is_loaded(fn.bufadd(tmpfile))) end) it('DeleteFile fails if file does not exist and ignoreIfNotExists is false', function() local tmpfile = tmpname() @@ -2363,7 +2363,7 @@ describe('LSP', function() }, } eq(false, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit)) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', tmpfile)) + eq(false, vim.uv.fs_stat(tmpfile) ~= nil) end) end) @@ -2391,9 +2391,9 @@ describe('LSP', function() new ) eq({ 'Test content' }, lines) - local exists = exec_lua('return vim.uv.fs_stat(...) ~= nil', old) + local exists = vim.uv.fs_stat(old) ~= nil eq(false, exists) - exists = exec_lua('return vim.uv.fs_stat(...) ~= nil', new) + exists = vim.uv.fs_stat(new) ~= nil eq(true, exists) os.remove(new) end) @@ -2429,9 +2429,9 @@ describe('LSP', function() file ) eq({ 'Test content' }, lines) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old_dir)) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new_dir)) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new_dir .. pathsep .. file)) + eq(false, vim.uv.fs_stat(old_dir) ~= nil) + eq(true, vim.uv.fs_stat(new_dir) ~= nil) + eq(true, vim.uv.fs_stat(new_dir .. pathsep .. file) ~= nil) os.remove(new_dir) end) @@ -2495,7 +2495,7 @@ describe('LSP', function() new ) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) + eq(true, vim.uv.fs_stat(old) ~= nil) eq('New file', read_file(new)) exec_lua( @@ -2509,7 +2509,7 @@ describe('LSP', function() new ) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) + eq(true, vim.uv.fs_stat(old) ~= nil) eq('New file', read_file(new)) end ) @@ -2539,8 +2539,8 @@ describe('LSP', function() old, new ) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new)) + eq(false, vim.uv.fs_stat(old) ~= nil) + eq(true, vim.uv.fs_stat(new) ~= nil) eq(true, undo_kept) end) it('Maintains undo information for unloaded buffer', function() @@ -2566,8 +2566,8 @@ describe('LSP', function() old, new ) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new)) + eq(false, vim.uv.fs_stat(old) ~= nil) + eq(true, vim.uv.fs_stat(new) ~= nil) eq(true, undo_kept) end) it('Does not rename file when it conflicts with a buffer without file', function() @@ -2611,8 +2611,8 @@ describe('LSP', function() new ) - eq(false, exec_lua('return vim.uv.fs_stat(...) ~= nil', old)) - eq(true, exec_lua('return vim.uv.fs_stat(...) ~= nil', new)) + eq(false, vim.uv.fs_stat(old) ~= nil) + eq(true, vim.uv.fs_stat(new) ~= nil) eq('Old file', read_file(new)) end) end) @@ -2991,10 +2991,10 @@ describe('LSP', function() local jump = function(msg) eq(true, exec_lua('return vim.lsp.util.jump_to_location(...)', msg, 'utf-16')) - eq(target_bufnr, exec_lua [[return vim.fn.bufnr('%')]]) + eq(target_bufnr, fn.bufnr('%')) return { - line = exec_lua [[return vim.fn.line('.')]], - col = exec_lua [[return vim.fn.col('.')]], + line = fn.line('.'), + col = fn.col('.'), } end @@ -3024,7 +3024,7 @@ describe('LSP', function() local pos = jump(location(1, 2, 1, 2)) eq(2, pos.line) eq(4, pos.col) - eq('å', exec_lua [[return vim.fn.expand('<cword>')]]) + eq('å', fn.expand('<cword>')) end) it('adds current position to jumplist before jumping', function() @@ -3081,11 +3081,11 @@ describe('LSP', function() ) ) if focus == true or focus == nil then - eq(target_bufnr, exec_lua([[return vim.fn.bufnr('%')]])) + eq(target_bufnr, fn.bufnr('%')) end return { - line = exec_lua([[return vim.fn.line('.')]]), - col = exec_lua([[return vim.fn.col('.')]]), + line = fn.line('.'), + col = fn.col('.'), } end diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index 3f29a02506..6eb1df38a3 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -163,17 +163,17 @@ describe('ShaDa support code', function() eq({ 2, 0 }, api.nvim_win_get_cursor(0)) end) - it('is able to dump and restore jump list with different times (slow!)', function() + it('is able to dump and restore jump list with different times', function() nvim_command('edit ' .. testfilename_2) - nvim_command('sleep 2') + nvim_command('sleep 10m') nvim_command('normal! G') - nvim_command('sleep 2') + nvim_command('sleep 10m') nvim_command('normal! gg') - nvim_command('sleep 2') + nvim_command('sleep 10m') nvim_command('edit ' .. testfilename) - nvim_command('sleep 2') + nvim_command('sleep 10m') nvim_command('normal! G') - nvim_command('sleep 2') + nvim_command('sleep 10m') nvim_command('normal! gg') expect_exit(nvim_command, 'qall') reset() diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index 77eae3627d..5a8d6e1f62 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -14,6 +14,7 @@ local nvim_prog = helpers.nvim_prog local retry = helpers.retry local write_file = helpers.write_file local assert_log = helpers.assert_log +local check_close = helpers.check_close local is_os = helpers.is_os local testlog = 'Xtest-embed-log' @@ -98,6 +99,7 @@ end) describe('--embed UI', function() after_each(function() + check_close() os.remove(testlog) end) diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 348be7af6a..9c18127875 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -336,8 +336,8 @@ describe('input non-printable chars', function() "Xtest-overwrite" [noeol] 1L, 6B | ]]) - -- The timestamp is in second resolution, wait two seconds to be sure. - screen:sleep(2000) + -- Wait for some time so that the timestamp changes. + vim.uv.sleep(10) write_file('Xtest-overwrite', [[smurf]]) feed_command('w') screen:expect([[ diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index b749d5a7f0..d64ae3b0f1 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -8,7 +8,6 @@ local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err local async_meths = helpers.async_meths local NIL = vim.NIL @@ -407,7 +406,6 @@ describe('inputdialog()', function() end) describe('confirm()', function() - -- oldtest: Test_confirm() it('works', function() api.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt api.nvim_set_option_value('laststatus', 2, {}) @@ -470,20 +468,6 @@ describe('confirm()', function() screen:expect({ any = '%[No Name%]' }) eq(1, api.nvim_get_var('a')) end - - eq('Vim(call):E730: Using a List as a String', pcall_err(command, 'call confirm([])')) - eq( - 'Vim(call):E730: Using a List as a String', - pcall_err(command, 'call confirm("Are you sure?", [])') - ) - eq( - 'Vim(call):E745: Using a List as a Number', - pcall_err(command, 'call confirm("Are you sure?", "&Yes\n&No\n", [])') - ) - eq( - 'Vim(call):E730: Using a List as a String', - pcall_err(command, 'call confirm("Are you sure?", "&Yes\n&No\n", 0, [])') - ) end) it('shows dialog even if :silent #8788', function() diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index c6c9e9c0ab..f7fa4783a3 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -5,7 +5,9 @@ local clear, fn, api = helpers.clear, helpers.fn, helpers.api local ok = helpers.ok local matches = helpers.matches local pcall_err = helpers.pcall_err +local check_close = helpers.check_close local mkdir = helpers.mkdir +local rmdir = helpers.rmdir local is_os = helpers.is_os local testlog = 'Xtest-server-log' @@ -18,12 +20,16 @@ end describe('server', function() after_each(function() + check_close() os.remove(testlog) end) it('serverstart() stores sockets in $XDG_RUNTIME_DIR', function() local dir = 'Xtest_xdg_run' mkdir(dir) + finally(function() + rmdir(dir) + end) clear({ env = { XDG_RUNTIME_DIR = dir } }) matches(dir, fn.stdpath('run')) if not is_os('win') then diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim index 091fb95806..a87903bc0d 100644 --- a/test/old/testdir/setup.vim +++ b/test/old/testdir/setup.vim @@ -44,7 +44,8 @@ if exists('s:did_load') endif let s:did_load = 1 -" Clear Nvim default mappings and menus. +" Clear Nvim default user commands, mappings and menus. +comclear mapclear mapclear! aunmenu * diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index b932837b1f..c1bbc8a129 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -3912,7 +3912,7 @@ func Test_Changed_ChangedI() au TextChangedI <buffer> :call TextChangedAutocmd('I') nnoremap <CR> o<Esc> - call writefile([''], 'XTextChangedI3') + autocmd SafeState * ++once call writefile([''], 'XTextChangedI3') END call writefile(before, 'Xinit', 'D') @@ -3921,38 +3921,40 @@ func Test_Changed_ChangedI() \ {'term_rows': 10}) call assert_equal('running', term_getstatus(buf)) call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))}) + defer delete('XTextChangedI3') + call WaitForAssert({-> assert_equal([''], readfile('XTextChangedI3'))}) " TextChanged should trigger if a mapping enters and leaves Insert mode. call term_sendkeys(buf, "\<CR>") - call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))}) call term_sendkeys(buf, "i") call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))}) " TextChangedI should trigger if change is done in Insert mode. call term_sendkeys(buf, "f") - call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')->join("\n"))}) call term_sendkeys(buf, "o") - call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')->join("\n"))}) call term_sendkeys(buf, "o") - call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))}) " TextChanged shouldn't trigger when leaving Insert mode and TextChangedI " has been triggered. call term_sendkeys(buf, "\<Esc>") call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))}) " TextChanged should trigger if change is done in Normal mode. call term_sendkeys(buf, "yyp") - call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))}) " TextChangedI shouldn't trigger if change isn't done in Insert mode. call term_sendkeys(buf, "i") call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))}) call term_sendkeys(buf, "\<Esc>") call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))}) " TextChangedI should trigger if change is a mix of Normal and Insert modes. func! s:validate_mixed_textchangedi(buf, keys) @@ -3962,13 +3964,13 @@ func Test_Changed_ChangedI() call term_sendkeys(buf, "\<Esc>") call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))}) call term_sendkeys(buf, ":let [g:autocmd_n, g:autocmd_i] = ['', '']\<CR>") - call delete('XTextChangedI3') + call writefile([], 'XTextChangedI3') call term_sendkeys(buf, a:keys) call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))}) call term_sendkeys(buf, "\<Esc>") call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))}) - call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])}) + call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))}) endfunc call s:validate_mixed_textchangedi(buf, "o") @@ -3981,7 +3983,6 @@ func Test_Changed_ChangedI() " clean up bwipe! - call delete('XTextChangedI3') endfunc " Test that filetype detection still works when SwapExists autocommand sets diff --git a/test/old/testdir/test_buffer.vim b/test/old/testdir/test_buffer.vim index bb8394997d..bc8e5eaf7b 100644 --- a/test/old/testdir/test_buffer.vim +++ b/test/old/testdir/test_buffer.vim @@ -232,8 +232,6 @@ endfunc " Test for deleting a modified buffer with :confirm func Test_bdel_with_confirm() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/buffer_spec.lua' CheckUnix CheckNotGui CheckFeature dialog_con @@ -251,26 +249,33 @@ endfunc " Test for editing another buffer from a modified buffer with :confirm func Test_goto_buf_with_confirm() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/buffer_spec.lua' CheckUnix CheckNotGui CheckFeature dialog_con + " When dialog_con_gui is defined, Vim is compiled with GUI support + " and FEAT_BROWSE will be defined, which causes :confirm :b to + " call do_browse(), which will try to use a GUI file browser, + " which aborts if a GUI is not available. + CheckNotFeature dialog_con_gui new XgotoConf enew call setline(1, 'test') call assert_fails('b XgotoConf', 'E37:') call feedkeys('c', 'L') call assert_fails('confirm b XgotoConf', 'E37:') - call assert_equal(1, &modified) - call assert_equal('', @%) + call assert_true(&modified) + call assert_true(empty(bufname('%'))) call feedkeys('y', 'L') - call assert_fails('confirm b XgotoConf', ['', 'E37:']) - call assert_equal(1, &modified) - call assert_equal('', @%) + confirm b XgotoConf + call assert_equal('XgotoConf', bufname('%')) + call assert_equal(['test'], readfile('Untitled')) + e Untitled + call setline(2, 'test2') call feedkeys('n', 'L') confirm b XgotoConf - call assert_equal('XgotoConf', @%) + call assert_equal('XgotoConf', bufname('%')) + call assert_equal(['test'], readfile('Untitled')) + call delete('Untitled') close! endfunc diff --git a/test/old/testdir/test_filechanged.vim b/test/old/testdir/test_filechanged.vim index fef0eb732f..a8fc78ff90 100644 --- a/test/old/testdir/test_filechanged.vim +++ b/test/old/testdir/test_filechanged.vim @@ -11,8 +11,12 @@ func Test_FileChangedShell_reload() new Xchanged_r call setline(1, 'reload this') write - " Need to wait until the timestamp would change by at least a second. - sleep 2 + " Need to wait until the timestamp would change. + if has('nanotime') + sleep 10m + else + sleep 2 + endif silent !echo 'extra line' >>Xchanged_r checktime call assert_equal('changed', g:reason) @@ -50,7 +54,11 @@ func Test_FileChangedShell_reload() call assert_equal('new line', getline(1)) " Only time changed - sleep 2 + if has('nanotime') + sleep 10m + else + sleep 2 + endif silent !touch Xchanged_r let g:reason = '' checktime @@ -65,7 +73,11 @@ func Test_FileChangedShell_reload() call setline(2, 'before write') write call setline(2, 'after write') - sleep 2 + if has('nanotime') + sleep 10m + else + sleep 2 + endif silent !echo 'different line' >>Xchanged_r let g:reason = '' checktime @@ -140,8 +152,6 @@ func Test_FileChangedShell_edit() endfunc func Test_FileChangedShell_edit_dialog() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/filechanged_spec.lua' CheckNotGui CheckUnix " Using low level feedkeys() does not work on MS-Windows. @@ -156,6 +166,7 @@ func Test_FileChangedShell_edit_dialog() au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' augroup END call assert_equal(&fileformat, 'unix') + sleep 10m " make the test less flaky in Nvim call writefile(["line1\r", "line2\r"], 'Xchanged_r') let g:reason = '' call feedkeys('L', 'L') " load file content only @@ -173,6 +184,7 @@ func Test_FileChangedShell_edit_dialog() au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' augroup END call assert_equal(&fileformat, 'unix') + sleep 10m " make the test less flaky in Nvim call writefile(["line1\r", "line2\r"], 'Xchanged_r') let g:reason = '' call feedkeys('a', 'L') " load file content and options @@ -191,8 +203,6 @@ func Test_FileChangedShell_edit_dialog() endfunc func Test_file_changed_dialog() - " requires a UI to be active - throw 'Skipped: use test/functional/legacy/filechanged_spec.lua' CheckUnix CheckNotGui au! FileChangedShell @@ -200,8 +210,12 @@ func Test_file_changed_dialog() new Xchanged_d call setline(1, 'reload this') write - " Need to wait until the timestamp would change by at least a second. - sleep 2 + " Need to wait until the timestamp would change. + if has('nanotime') + sleep 10m + else + sleep 2 + endif silent !echo 'extra line' >>Xchanged_d call feedkeys('L', 'L') checktime @@ -236,7 +250,11 @@ func Test_file_changed_dialog() call assert_equal('new line', getline(1)) " Only time changed, no prompt - sleep 2 + if has('nanotime') + sleep 10m + else + sleep 2 + endif silent !touch Xchanged_d let v:warningmsg = '' checktime Xchanged_d diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 1039f4d5df..b58533c124 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -221,6 +221,7 @@ func s:GetFilenameChecks() abort \ 'dylan': ['file.dylan'], \ 'dylanintr': ['file.intr'], \ 'dylanlid': ['file.lid'], + \ 'earthfile': ['Earthfile'], \ 'ecd': ['file.ecd'], \ 'edif': ['file.edf', 'file.edif', 'file.edo'], \ 'editorconfig': ['.editorconfig'], diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index fdcd93a264..ea0e3790cc 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -2590,8 +2590,6 @@ endfunc " Test confirm({msg} [, {choices} [, {default} [, {type}]]]) func Test_confirm() - " requires a UI to be active - throw 'Skipped: use test/functional/vimscript/input_spec.lua' CheckUnix CheckNotGui diff --git a/test/old/testdir/test_stat.vim b/test/old/testdir/test_stat.vim index d3059664e9..13ade5bee1 100644 --- a/test/old/testdir/test_stat.vim +++ b/test/old/testdir/test_stat.vim @@ -55,7 +55,7 @@ func SleepForTimestamp() if has('win32') sleep 2 else - sleep 2 + sleep 1 endif endfunc |