diff options
64 files changed, 1496 insertions, 650 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f06d060560..43f283d8f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,13 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Prefer our bundled versions of dependencies. set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies") -list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}) -set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig") +if(CMAKE_CROSSCOMPILING AND NOT UNIX) + list(INSERT CMAKE_FIND_ROOT_PATH 0 ${DEPS_PREFIX}) + list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}/../host/bin) +else() + list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig") +endif() # used for check_c_compiler_flag include(CheckCCompilerFlag) @@ -46,27 +51,15 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE) endif() -# Version tokens -# - In a git repo, these tokens are _ignored_. -# - If the current HEAD is tagged, the tag name is used. -# - Otherwise the result of `git describe` is used. -# - If not in a git repo (e.g. a tarball) these tokens set the version string. +# If not in a git repo (e.g., a tarball) these tokens set the version string, +# otherwise the result of `git describe` is used. set(NVIM_VERSION_MAJOR 0) set(NVIM_VERSION_MINOR 1) set(NVIM_VERSION_PATCH 1) file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR) include(GetGitRevisionDescription) -get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT) -if(NVIM_VERSION_COMMIT) # is a git repo - git_get_exact_tag(NVIM_VERSION_MEDIUM) - if(NVIM_VERSION_MEDIUM) # is a tagged release - unset(NVIM_VERSION_COMMIT) - else() # is a dev build - git_describe(NVIM_VERSION_MEDIUM) - get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT) - endif() -endif() +git_describe(NVIM_VERSION_MEDIUM) set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") # NVIM_VERSION_CFLAGS set further below. diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index b780291264..3d7660ed58 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -51,7 +51,10 @@ if(JEMALLOC_FOUND) set(HAVE_JEMALLOC 1) endif() -check_function_exists(putenv HAVE_PUTENV) +check_function_exists(_putenv_s HAVE_PUTENV_S) +if(WIN32 AND NOT HAVE_PUTENV_S) + message(SEND_ERROR "_putenv_s() function not found on your system.") +endif() check_function_exists(opendir HAVE_OPENDIR) check_function_exists(readlink HAVE_READLINK) check_function_exists(setenv HAVE_SETENV) diff --git a/config/config.h.in b/config/config.h.in index 7d901180b4..017cb80f2f 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -29,7 +29,7 @@ #cmakedefine HAVE_LOCALE_H #cmakedefine HAVE_NL_LANGINFO_CODESET #cmakedefine HAVE_NL_MSG_CAT_CNTR -#cmakedefine HAVE_PUTENV +#cmakedefine HAVE_PUTENV_S #cmakedefine HAVE_PWD_H #cmakedefine HAVE_READLINK // TODO: add proper cmake check diff --git a/config/versiondef.h.in b/config/versiondef.h.in index 7f37ef72fb..c91bb29c90 100644 --- a/config/versiondef.h.in +++ b/config/versiondef.h.in @@ -5,7 +5,6 @@ #define NVIM_VERSION_MINOR @NVIM_VERSION_MINOR@ #define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@ #define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@" -#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@" #cmakedefine NVIM_VERSION_MEDIUM "@NVIM_VERSION_MEDIUM@" #define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@" diff --git a/uncrustify.cfg b/contrib/uncrustify.cfg index 11da34d59a..11da34d59a 100644 --- a/uncrustify.cfg +++ b/contrib/uncrustify.cfg diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 075e581bf2..e23fc49d89 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1063,11 +1063,12 @@ There are nine types of registers: *registers* *E354* 2. 10 numbered registers "0 to "9 3. The small delete register "- 4. 26 named registers "a to "z or "A to "Z -5. four read-only registers ":, "., "% and "# -6. the expression register "= -7. The selection and drop registers "*, "+ and "~ -8. The black hole register "_ -9. Last search pattern register "/ +5. three read-only registers ":, "., "% +6. alternate buffer register "# +7. the expression register "= +8. The selection and drop registers "*, "+ and "~ +9. The black hole register "_ +10. Last search pattern register "/ 1. Unnamed register "" *quote_quote* *quotequote* Vim fills this register with text deleted with the "d", "c", "s", "x" commands diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index 54d47eb28a..8c9cdc3800 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -1,4 +1,4 @@ -*diff.txt* For Vim version 7.4. Last change: 2015 Jan 19 +*diff.txt* For Vim version 7.4. Last change: 2015 Feb 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -306,6 +306,19 @@ name or a part of a buffer name. Examples: Also see |'diffopt'| and the "diff" item of |'fillchars'|. + *diff-slow* *diff_translations* +For very long lines, the diff syntax highlighting might be slow, especially +since it tries to match all different kind of localisations. To disable +localisations and speed up the syntax highlighting, set the global variable +g:diff_translations to zero: > + + let g:diff_translations = 0 +< +After setting this variable, Reload the syntax script: > + + set syntax=diff +< + FINDING THE DIFFERENCES *diff-diffexpr* diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4ff0636b61..8e40186a15 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2014 Nov 27 +*eval.txt* For Vim version 7.4. Last change: 2015 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -953,7 +953,7 @@ Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0). Floating point numbers can be written in two forms: [-+]{N}.{M} - [-+]{N}.{M}e[-+]{exp} + [-+]{N}.{M}[eE][-+]{exp} {N} and {M} are numbers. Both {N} and {M} must be present and can only contain digits. @@ -4972,6 +4972,7 @@ printf({fmt}, {expr1} ...) *printf()* s The text of the String argument is used. If a precision is specified, no more bytes than the number specified are used. + *printf-S* S The text of the String argument is used. If a precision is specified, no more display cells than the number specified are used. Without the |+multi_byte| @@ -7596,7 +7597,7 @@ This does NOT work: > :unlet v < *E741* If you try to change a locked variable you get an - error message: "E741: Value of {name} is locked" + error message: "E741: Value is locked: {name}" [depth] is relevant when locking a |List| or |Dictionary|. It specifies how deep the locking goes: diff --git a/runtime/doc/farsi.txt b/runtime/doc/farsi.txt index d5b371ab40..5aa77d8a22 100644 --- a/runtime/doc/farsi.txt +++ b/runtime/doc/farsi.txt @@ -215,7 +215,7 @@ o Keyboard Note: ¡ stands for Farsi PSP (break without space) - ¢ stands for Farsi PCN (for HAMZE attribute ) + ¢ stands for Farsi PCN (for HAMZE attribute) Restrictions ------------ diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index 0825ca8848..431b6e1ad7 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -1,4 +1,4 @@ -*intro.txt* For Vim version 7.4. Last change: 2014 May 24 +*intro.txt* For Vim version 7.4. Last change: 2015 Jan 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -131,7 +131,7 @@ http://www.vim.org/maillist.php Bug reports: *bugs* *bug-reports* *bugreport.vim* -Send bug reports to: Vim Developers <vim_dev@vim.org> +Send bug reports to: Vim Developers <vim-dev@vim.org> This is a maillist, you need to become a member first and many people will see the message. If you don't want that, e.g. because it is a security issue, send it to <bugs@vim.org>, this only goes to the Vim maintainer (that's Bram). diff --git a/runtime/doc/nvim_python.txt b/runtime/doc/nvim_python.txt index 1c345b4532..a2fc968db4 100644 --- a/runtime/doc/nvim_python.txt +++ b/runtime/doc/nvim_python.txt @@ -49,6 +49,9 @@ To use Vim Python 2/3 plugins with Nvim, do the following: > $ pip3 install --user neovim < +Note: If you previously installed the package, get the latest version by + appending the `--upgrade` flag to the commands above. + ============================================================================== *g:python_host_prog* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 70a585654e..229e020daf 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2014 Dec 17 +*options.txt* For Vim version 7.4. Last change: 2015 Oct 15 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1194,6 +1194,8 @@ A jump table for the options with a short description can be found at |Q_op|. nofile only: The buffer name is fixed, it is not handled like a file name. It is not modified in response to a |:cd| command. + nofile only: When using ":e bufname" and already editing "bufname" + nothing changes, since there is no file to edit. *E676* "acwrite" implies that the buffer name is not related to a file, like "nofile", but it will be written. Thus, in contrast to "nofile" and @@ -2178,15 +2180,16 @@ A jump table for the options with a short description can be found at |Q_op|. 'endofline' 'eol' boolean (default on) local to buffer When writing a file and this option is off and the 'binary' option - is on, no <EOL> will be written for the last line in the file. This - option is automatically set when starting to edit a new file, unless - the file does not have an <EOL> for the last line in the file, in - which case it is reset. Normally you don't have to set or reset this - option. When 'binary' is off the value is not used when writing the - file. When 'binary' is on it is used to remember the presence of a - <EOL> for the last line in the file, so that when you write the file - the situation from the original file can be kept. But you can change - it if you want to. + is on, or 'fixeol' option is off, no <EOL> will be written for the + last line in the file. This option is automatically set or reset when + starting to edit a new file, depending on whether file has an <EOL> + for the last line in the file. Normally you don't have to set or + reset this option. + When 'binary' is off and 'fixeol' is on the value is not used when + writing the file. When 'binary' is on or 'fixeol' is off it is used + to remember the presence of a <EOL> for the last line in the file, so + that when you write the file the situation from the original file can + be kept. But you can change it if you want to. *'equalalways'* *'ea'* *'noequalalways'* *'noea'* 'equalalways' 'ea' boolean (default on) @@ -2541,6 +2544,17 @@ A jump table for the options with a short description can be found at |Q_op|. fold:c Folded |hl-Folded| diff:c DiffDelete |hl-DiffDelete| + *'fixendofline'* *'fixeol'* *'nofixendofline'* *'nofixeol'* +'fixendofline' 'fixeol' boolean (default on) + local to buffer + {not in Vi} + When writing a file and this option is on, <EOL> at the end of file + will be restored if missing. Turn this option off if you want to + preserve the situation from the original file. + When the 'binary' option is set the value of this option doesn't + matter. + See the 'endofline' option. + *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* 'fkmap' 'fk' boolean (default off) *E198* global diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index 086d05613d..7565d1e976 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -677,7 +677,7 @@ It is possible to achieve a poor man's version of duplex printing using the PS utility psselect. This utility has options -e and -o for printing just the even or odd pages of a PS file respectively. -First generate a PS file with the 'hardcopy' command, then generate a new +First generate a PS file with the 'hardcopy' command, then generate new files with all the odd and even numbered pages with: > psselect -o test.ps odd.ps diff --git a/runtime/doc/quotes.txt b/runtime/doc/quotes.txt index 28b0e1c623..c35fb2f139 100644 --- a/runtime/doc/quotes.txt +++ b/runtime/doc/quotes.txt @@ -178,14 +178,14 @@ Hurrah for VIM!! It is "at your fingertips" like vi, and has the extensions that vi sorely needs: highlighting for executing commands on blocks, an easily navigable and digestible help screen, and more. (Paul Pax) -The reason WHY I don't have this amazingly useful macro any more, is that I +The reason WHY I don't have this amazingly useful macro anymore, is that I now use VIM - and this is built in!! (Stephen Riehm, Germany) I am a user of VIM and I love it. I use it to do all my programming, C, C++, HTML what ever. (Tim Allwine) I discovered VIM after years of struggling with the original vi, and I just -can't live without it any more. (Emmanuel Mogenet, USA) +can't live without it anymore. (Emmanuel Mogenet, USA) Emacs has not a bit of chance to survive so long as VIM is around. Besides, it also has the most detailed software documentation I have ever seen---much diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 67550365a3..33547b2012 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2015 Jan 07 +*syntax.txt* For Vim version 7.4. Last change: 2015 Feb 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1130,6 +1130,8 @@ there are very long lines in the file. To disable translations: > :let diff_translations = 0 +Also see |diff-slow|. + DIRCOLORS *dircolors.vim* *ft-dircolors-syntax* diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 618d4e5df9..9610555dce 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -357,7 +357,7 @@ adjust the various t_ codes. This avoids the problem that the xterm can produce different codes, depending on the mode it is in (8-bit, VT102, VT220, etc.). The result is that codes like <xF1> are no longer needed. Note: This is only done on startup. If the xterm options are changed after -Vim has started, the escape sequences may not be recognized any more. +Vim has started, the escape sequences may not be recognized anymore. *xterm-resize* Window resizing with xterm only works if the allowWindowOps resource is diff --git a/runtime/doc/uganda.txt b/runtime/doc/uganda.txt index ee1c36d676..c228c65542 100644 --- a/runtime/doc/uganda.txt +++ b/runtime/doc/uganda.txt @@ -190,7 +190,7 @@ child, you should have the intention to do this for at least one year. How do you know that the money will be spent right? First of all you have my personal guarantee as the author of Vim. I trust the people that are working -at the centre, I know them personally. Further more, the centre has been +at the centre, I know them personally. Furthermore, the centre has been co-sponsored and inspected by World Vision, Save the Children Fund and is now under the supervision of Pacific Academy Outreach Society. The centre is visited about once a year to check the progress (at our own cost). I have diff --git a/runtime/doc/usr_03.txt b/runtime/doc/usr_03.txt index a8139d60ca..5b6eaa295b 100644 --- a/runtime/doc/usr_03.txt +++ b/runtime/doc/usr_03.txt @@ -528,7 +528,7 @@ MATCHING ANY SINGLE CHARACTER The . (dot) character matches any existing character. For example, the pattern "c.m" matches a string whose first character is a c, whose second -character is anything, and whose the third character is m. Example: +character is anything, and whose third character is m. Example: We use a computer that became the cummin winter. ~ xxx xxx xxx diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index c009bec66e..1b902c908c 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -1,4 +1,4 @@ -*windows.txt* For Vim version 7.4. Last change: 2014 Dec 05 +*windows.txt* For Vim version 7.4. Last change: 2015 Jan 31 VIM REFERENCE MANUAL by Bram Moolenaar @@ -984,8 +984,8 @@ list of buffers. |unlisted-buffer| (the term "unlisted" is a bit confusing then...). Each buffer has a unique number. That number will not change, - so you can always go to a specific buffer with ":buffer N" or - "N CTRL-^", where N is the buffer number. + thus you can always go to a specific buffer with ":buffer N" + or "N CTRL-^", where N is the buffer number. Indicators (chars in the same column are mutually exclusive): u an unlisted buffer (only displayed when [!] is used) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index b06e702637..c9686b8502 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2015 Jan 07 +" Last Change: 2015 Jan 14 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -2032,6 +2032,10 @@ func! s:FTRules() setf conf " Better than hog return endif + if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' + setf javascript + return + endif try let config_lines = readfile('/etc/udev/udev.conf') catch /^Vim\%((\a\+)\)\=:E484/ diff --git a/runtime/ftplugin/j.vim b/runtime/ftplugin/j.vim index bcd606ffa0..71ac4c5418 100644 --- a/runtime/ftplugin/j.vim +++ b/runtime/ftplugin/j.vim @@ -2,7 +2,7 @@ " Language: J " Maintainer: David Bürgin <676c7473@gmail.com> " URL: https://github.com/glts/vim-j -" Last Change: 2014-04-05 +" Last Change: 2015-01-11 if exists('b:did_ftplugin') finish @@ -16,39 +16,41 @@ setlocal iskeyword=48-57,A-Z,_,a-z setlocal comments=:NB. setlocal commentstring=NB.\ %s setlocal formatoptions-=t -setlocal shiftwidth=2 softtabstop=2 expandtab +setlocal shiftwidth=2 +setlocal softtabstop=2 +setlocal expandtab setlocal matchpairs=(:) let b:undo_ftplugin = 'setlocal matchpairs< expandtab< softtabstop< shiftwidth< formatoptions< commentstring< comments< iskeyword<' " Section movement with ]] ][ [[ []. The start/end patterns below are amended " inside the function in order to avoid matching on the current cursor line. -let s:sectionstart = '.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>.*' +let s:sectionstart = '\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\)\>.*' let s:sectionend = '\s*)\s*' function! s:SearchSection(end, backwards, visualmode) abort if a:visualmode !=# '' normal! gv endif - let flags = a:backwards ? 'bsW' : 'sW' + let l:flags = a:backwards ? 'bsW' : 'sW' if a:end - call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags) + call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags) else - call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags) + call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags) endif endfunction -noremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR> -xnoremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR> +noremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR> +xnoremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR> sunmap <buffer> ]] -noremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR> -xnoremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR> +noremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR> +xnoremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR> sunmap <buffer> ][ -noremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR> -xnoremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR> +noremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR> +xnoremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR> sunmap <buffer> [[ -noremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR> -xnoremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR> +noremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR> +xnoremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR> sunmap <buffer> [] let b:undo_ftplugin .= ' | silent! execute "unmap <buffer> ]]"' @@ -66,7 +68,7 @@ endif " Enhanced "%" matching (see ":help matchit") if exists('loaded_matchit') && !exists('b:match_words') let b:match_ignorecase = 0 - let b:match_words = '^.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(\:\s*0\|def\s\+0\|define\)\>:^\s*\:\s*$:^\s*)\s*$' + let b:match_words = '^\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(\:\s*0\|def\s\+0\|define\)\)\>:^\s*\:\s*$:^\s*)\s*$' \ . ',\<\%(for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.:\<\%(case\|catch[dt]\=\|else\%(if\)\=\|fcase\)\.:\<end\.' let b:undo_ftplugin .= ' | unlet! b:match_ignorecase b:match_words' endif diff --git a/runtime/indent/fortran.vim b/runtime/indent/fortran.vim index e76c64b671..2c83f26b58 100644 --- a/runtime/indent/fortran.vim +++ b/runtime/indent/fortran.vim @@ -1,9 +1,11 @@ " Vim indent file -" Language: Fortran95 (and Fortran90, Fortran77, F and elf90) -" Version: 0.40 -" Last Change: 2011 Dec. 28 -" Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/> +" Language: Fortran 2008 (and earlier versions: 2003, 95, 90, and 77) +" Version: 0.41 +" Last Change: 2015 Jan. 15 +" Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www2.unb.ca/~ajit/> " Usage: Do :help fortran-indent from Vim +" Credits: +" Useful suggestions were made by: Albert Oliver Serra. " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -36,8 +38,8 @@ if !exists("b:fortran_fixed_source") else " f90 and f95 allow both fixed and free source form " assume fixed source form unless signs of free source form - " are detected in the first five columns of the first 250 lines - " Detection becomes more accurate and time-consuming if more lines + " are detected in the first five columns of the first s:lmax lines. + " Detection becomes more accurate and more time-consuming if more lines " are checked. Increase the limit below if you keep lots of comments at " the very top of each file and you have a fast computer let s:lmax = 500 @@ -129,7 +131,7 @@ function FortranGetIndent(lnum) if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*' \. '\(else\|else\s*if\|else\s*where\|case\|' \. 'end\s*\(if\|where\|select\|interface\|' - \. 'type\|forall\|associate\|enum\)\)\>' + \. 'type\|forall\|associate\|enum\|block\)\)\>' let ind = ind - &sw " Fix indent for case statement immediately after select if prevstat =~? '\<select\s\+\(case\|type\)\>' @@ -141,8 +143,11 @@ function FortranGetIndent(lnum) if prevstat =~ '&\s*$' && prev2stat !~ '&\s*$' let ind = ind + &sw endif + if prevstat =~ '&\s*$' && prevstat =~ '\<else\s*if\>' + let ind = ind - &sw + endif "Line after last continuation line - if prevstat !~ '&\s*$' && prev2stat =~ '&\s*$' + if prevstat !~ '&\s*$' && prev2stat =~ '&\s*$' && prevstat !~? '\<then\>' let ind = ind - &sw endif diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim index d64a0e5cd3..b97a905988 100644 --- a/runtime/indent/html.vim +++ b/runtime/indent/html.vim @@ -2,7 +2,7 @@ " Header: "{{{ " Maintainer: Bram Moolenaar " Original Author: Andy Wokula <anwoku@yahoo.de> -" Last Change: 2014 Aug 23 +" Last Change: 2015 Jan 11 " Version: 1.0 " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -883,7 +883,7 @@ endfunc "}}} " THE MAIN INDENT FUNCTION. Return the amount of indent for v:lnum. func! HtmlIndent() "{{{ - if prevnonblank(v:lnum - 1) <= 1 + if prevnonblank(v:lnum - 1) < 1 " First non-blank line has no indent. return 0 endif diff --git a/runtime/indent/j.vim b/runtime/indent/j.vim index e268e1fcd3..ea3d50936b 100644 --- a/runtime/indent/j.vim +++ b/runtime/indent/j.vim @@ -2,7 +2,7 @@ " Language: J " Maintainer: David Bürgin <676c7473@gmail.com> " URL: https://github.com/glts/vim-j -" Last Change: 2014-04-05 +" Last Change: 2015-01-11 if exists('b:did_indent') finish @@ -26,25 +26,25 @@ if !exists('g:j_indent_definitions') endif function GetJIndent() abort - let prevlnum = prevnonblank(v:lnum-1) - if prevlnum == 0 + let l:prevlnum = prevnonblank(v:lnum - 1) + if l:prevlnum == 0 return 0 endif - let indent = indent(prevlnum) - let prevline = getline(prevlnum) - if prevline =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.\%(\%(\<end\.\)\@!.\)*$' + let l:indent = indent(l:prevlnum) + let l:prevline = getline(l:prevlnum) + if l:prevline =~# '^\s*\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|fcase\|for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.\%(\%(\<end\.\)\@!.\)*$' " Increase indentation after an initial control word that starts or " continues a block and is not terminated by "end." - let indent += shiftwidth() - elseif g:j_indent_definitions && (prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || prevline =~# '^\s*:\s*$') + let l:indent += shiftwidth() + elseif g:j_indent_definitions && (l:prevline =~# '\<\%([1-4]\|13\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>' || l:prevline =~# '^\s*:\s*$') " Increase indentation in explicit definitions of adverbs, conjunctions, " and verbs - let indent += shiftwidth() + let l:indent += shiftwidth() endif " Decrease indentation in lines that start with either control words that " continue or end a block, or the special items ")" and ":" if getline(v:lnum) =~# '^\s*\%()\|:\|\%(case\|catch[dt]\=\|do\|else\%(if\)\=\|end\|fcase\)\.\)' - let indent -= shiftwidth() + let l:indent -= shiftwidth() endif - return indent + return l:indent endfunction diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 09406f260b..dde5dd0c61 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -926,6 +926,9 @@ call <SID>BinOptionL("bin") call append("$", "endofline\tlast line in the file has an end-of-line") call append("$", "\t(local to buffer)") call <SID>BinOptionL("eol") +call append("$", "fixeol\tfixes missing end-of-line at end of text file") +call append("$", "\t(local to buffer)") +call <SID>BinOptionL("fixeol") if has("multi_byte") call append("$", "bomb\tprepend a Byte Order Mark to the file") call append("$", "\t(local to buffer)") diff --git a/runtime/syntax/awk.vim b/runtime/syntax/awk.vim index f80a582226..40491eea1a 100644 --- a/runtime/syntax/awk.vim +++ b/runtime/syntax/awk.vim @@ -1,13 +1,15 @@ " Vim syntax file " Language: awk, nawk, gawk, mawk " Maintainer: Antonio Colombo <azc100@gmail.com> -" Last Change: 2012 May 18 +" Last Change: 2014 Oct 21 " AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger " The AWK Programming Language, Addison-Wesley, 1988 " GAWK ref. is: Arnold D. Robbins " Effective AWK Programming, Third Edition, O'Reilly, 2001 +" Effective AWK Programming, Fourth Edition, O'Reilly, 2015 +" (also available with the gawk source distribution) " MAWK is a "new awk" meaning it implements AWK ref. " mawk conforms to the Posix 1003.2 (draft 11.3) @@ -33,17 +35,27 @@ set cpo&vim syn keyword awkStatement break continue delete exit syn keyword awkStatement function getline next syn keyword awkStatement print printf return -" GAWK ref. p. 117 +" GAWK ref. Chapter 7 syn keyword awkStatement nextfile -" AWK ref. p. 42, GAWK ref. p. 142-166 -syn keyword awkFunction atan2 close cos exp fflush int log rand sin sqrt srand -syn keyword awkFunction gsub index length match split sprintf sub -syn keyword awkFunction substr system -" GAWK ref. p. 142-166 -syn keyword awkFunction asort gensub mktime strftime strtonum systime +" +" GAWK ref. Chapter 9, Functions +" +" Numeric Functions +syn keyword awkFunction atan2 cos div exp int log rand sin sqrt srand +" String Manipulation Functions +syn keyword awkFunction asort asort1 gensub gsub index length match +syn keyword awkFunction patsplit split sprintf strtonum sub substr syn keyword awkFunction tolower toupper -syn keyword awkFunction and or xor compl lshift rshift -syn keyword awkFunction dcgettext bindtextdomain +" Input Output Functions +syn keyword awkFunction close fflush system +" Time Functions +syn keyword awkFunction mktime strftime systime +" Bit Manipulation Functions +syn keyword awkFunction and compl lshift or rshift xor +" Getting Type Function +syn keyword awkFunction isarray +" String-Translation Functions +syn keyword awkFunction bindtextdomain dcgettext dcngetext syn keyword awkConditional if else syn keyword awkRepeat while for @@ -51,13 +63,16 @@ syn keyword awkRepeat while for syn keyword awkTodo contained TODO syn keyword awkPatterns BEGIN END -" AWK ref. p. 36 -syn keyword awkVariables ARGC ARGV FILENAME FNR FS NF NR -syn keyword awkVariables OFMT OFS ORS RLENGTH RS RSTART SUBSEP -" GAWK ref. p. 120-126 -syn keyword awkVariables ARGIND BINMODE CONVFMT ENVIRON ERRNO -syn keyword awkVariables FIELDWIDTHS IGNORECASE LINT PROCINFO -syn keyword awkVariables RT RLENGTH TEXTDOMAIN + +" GAWK ref. Chapter 7 +" Built-in Variables That Control awk +syn keyword awkVariables BINMODE CONVFMT FIELDWIDTHS FPAT FS +syn keyword awkVariables IGNORECASE LINT OFMT OFS ORS PREC +syn keyword awkVariables ROUNDMODE RS SUBSEP TEXTDOMAIN +" Built-in Variables That Convey Information +syn keyword awkVariables ARGC ARGV ARGIND ENVIRON ERRNO FILENAME +syn keyword awkVariables FNR NF FUNCTAB NR PROCINFO RLENGTH RSTART +syn keyword awkVariables RT SYMTAB syn keyword awkRepeat do @@ -115,15 +130,15 @@ syn case match "syn match awkIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" " Arithmetic operators: +, and - take care of ++, and -- -"syn match awkOperator "+\|-\|\*\|/\|%\|=" -"syn match awkOperator "+=\|-=\|\*=\|/=\|%=" -"syn match awkOperator "^\|^=" +syn match awkOperator "+\|-\|\*\|/\|%\|=" +syn match awkOperator "+=\|-=\|\*=\|/=\|%=" +syn match awkOperator "^\|^=" " Comparison expressions. -"syn match awkExpression "==\|>=\|=>\|<=\|=<\|\!=" -"syn match awkExpression "\~\|\!\~" -"syn match awkExpression "?\|:" -"syn keyword awkExpression in +syn match awkExpression "==\|>=\|=>\|<=\|=<\|\!=" +syn match awkExpression "\~\|\!\~" +syn match awkExpression "?\|:" +syn keyword awkExpression in " Boolean Logic (OR, AND, NOT) "syn match awkBoolLogic "||\|&&\|\!" @@ -187,8 +202,8 @@ if version >= 508 || !exists("did_awk_syn_inits") HiLink awkFloat Float HiLink awkFileIO Special - "HiLink awkOperator Special - "HiLink awkExpression Special + HiLink awkOperator Special + HiLink awkExpression Special HiLink awkBoolLogic Special HiLink awkPatterns Special diff --git a/runtime/syntax/config.vim b/runtime/syntax/config.vim index 20ca19ced0..cd83b24352 100644 --- a/runtime/syntax/config.vim +++ b/runtime/syntax/config.vim @@ -1,11 +1,13 @@ " Vim syntax file " Language: configure.in script: M4 with sh " Maintainer: Christian Hammesr <ch@lathspell.westend.com> -" Last Change: 2008 Sep 03 +" Last Change: 2015 Jan 14 +" (patch from Yngve Inntjore Levinsen to detect AC_MSG) +" (patch from Khym Chanur to add @Spell) " Well, I actually even do not know much about m4. This explains why there " is probably very much missing here, yet ! -" But I missed a good hilighting when editing my GNU autoconf/automake +" But I missed good highlighting when editing my GNU autoconf/automake " script, so I wrote this quick and dirty patch. @@ -20,14 +22,19 @@ endif " define the config syntax syn match configdelimiter "[()\[\];,]" syn match configoperator "[=|&\*\+\<\>]" -syn match configcomment "\(dnl.*\)\|\(#.*\)" +syn match configcomment "\(dnl.*\)\|\(#.*\)" contains=configDnl,@Spell syn match configfunction "\<[A-Z_][A-Z0-9_]*\>" syn match confignumber "[-+]\=\<\d\+\(\.\d*\)\=\>" +syn keyword configDnl dnl contained syn keyword configkeyword if then else fi test for in do done syn keyword configspecial cat rm eval -syn region configstring start=+"+ skip=+\\"+ end=+"+ -syn region configstring start=+'+ skip=+\\'+ end=+'+ -syn region configstring start=+`+ skip=+\\'+ end=+`+ + +" This shortens the script, see syn-ext-match.. +syn region configstring start=+\z(["'`]\)+ skip=+\\\z1+ end=+\z1+ contains=@Spell + +" Anything inside AC_MSG_TYPE([...]) and AC_MSG_TYPE(...) is a string. +syn region configstring matchgroup=configfunction start="AC_MSG_[A-Z]*\ze(\[" matchgroup=configdelimiter end="\])" contains=configdelimiter,@Spell +syn region configstring matchgroup=configfunction start="AC_MSG_[A-Z]*\ze([^[]" matchgroup=configdelimiter end=")" contains=configdelimiter,@Spell " Define the default highlighting. " For version 5.7 and earlier: only when not done already @@ -43,6 +50,7 @@ if version >= 508 || !exists("did_config_syntax_inits") HiLink configdelimiter Delimiter HiLink configoperator Operator HiLink configcomment Comment + HiLink configDnl Comment HiLink configfunction Function HiLink confignumber Number HiLink configkeyword Keyword diff --git a/runtime/syntax/crontab.vim b/runtime/syntax/crontab.vim index 36d75c4d13..fd1c30023f 100644 --- a/runtime/syntax/crontab.vim +++ b/runtime/syntax/crontab.vim @@ -5,7 +5,7 @@ " License: This file can be redistribued and/or modified under the same terms " as Vim itself. " Filenames: /tmp/crontab.* used by "crontab -e" -" Last Change: 2012-05-16 +" Last Change: 2015-01-20 " " crontab line format: " Minutes Hours Days Months Days_of_Week Commands # comments @@ -13,11 +13,17 @@ " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 - syntax clear + syntax clear elseif exists("b:current_syntax") - finish + finish endif +syntax match crontabNick "^\s*@\(reboot\|yearly\|annually\|monthly\|weekly\|daily\|midnight\|hourly\)\>" nextgroup=crontabCmd skipwhite + +syntax match crontabVar "^\s*\k\w*\s*="me=e-1 + +syntax case ignore + syntax match crontabMin "^\s*[-0-9/,.*]\+" nextgroup=crontabHr skipwhite syntax match crontabHr "\s[-0-9/,.*]\+" nextgroup=crontabDay skipwhite contained syntax match crontabDay "\s[-0-9/,.*]\+" nextgroup=crontabMnth skipwhite contained @@ -32,45 +38,41 @@ syntax region crontabCmd start="\S" end="$" skipwhite contained keepend contains syntax match crontabCmnt "^\s*#.*" contains=@Spell syntax match crontabPercent "[^\\]%.*"lc=1 contained -syntax match crontabNick "^\s*@\(reboot\|yearly\|annually\|monthly\|weekly\|daily\|midnight\|hourly\)\>" nextgroup=crontabCmd skipwhite - -syntax match crontabVar "^\s*\k\w*\s*="me=e-1 - " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_crontab_syn_inits") - if version < 508 - let did_crontab_syn_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - - HiLink crontabMin Number - HiLink crontabHr PreProc - HiLink crontabDay Type - - HiLink crontabMnth Number - HiLink crontabMnth12 Number - HiLink crontabMnthS Number - HiLink crontabMnthN Number - - HiLink crontabDow PreProc - HiLink crontabDow7 PreProc - HiLink crontabDowS PreProc - HiLink crontabDowN PreProc - - HiLink crontabNick Special - HiLink crontabVar Identifier - HiLink crontabPercent Special + if version < 508 + let did_crontab_syn_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink crontabMin Number + HiLink crontabHr PreProc + HiLink crontabDay Type + + HiLink crontabMnth Number + HiLink crontabMnth12 Number + HiLink crontabMnthS Number + HiLink crontabMnthN Number + + HiLink crontabDow PreProc + HiLink crontabDow7 PreProc + HiLink crontabDowS PreProc + HiLink crontabDowN PreProc + + HiLink crontabNick Special + HiLink crontabVar Identifier + HiLink crontabPercent Special " comment out next line for to suppress unix commands coloring. - HiLink crontabCmd Statement + HiLink crontabCmd Statement - HiLink crontabCmnt Comment + HiLink crontabCmnt Comment - delcommand HiLink + delcommand HiLink endif let b:current_syntax = "crontab" diff --git a/runtime/syntax/diff.vim b/runtime/syntax/diff.vim index ff69c5860b..885feaebdd 100644 --- a/runtime/syntax/diff.vim +++ b/runtime/syntax/diff.vim @@ -2,7 +2,7 @@ " Language: Diff (context or unified) " Maintainer: Bram Moolenaar <Bram@vim.org> " Translations by Jakson Alves de Aquino. -" Last Change: 2015 Jan 07 +" Last Change: 2015 Feb 03 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -123,13 +123,17 @@ syn match diffNoEOL "^\\ Non hai un salto de liña na fin da liña" syn match diffCommon "^Subdirectorios comúns: .* e .*" " he -syn match diffOnly "^.*-ב קר ××¦×ž× .*" -syn match diffIdentical "^××™×”×– ×× ×™×” .*-ו .* ×יצבקה$" -syn match diffDiffer "^הזמ ×”×– ××™× ×•×© `.*'-ו `.*' ×יצבקה$" -syn match diffBDiffer "^הזמ ×”×– ××™× ×•×© `.*'-ו `.*' ××™×™×¨× ×™×‘ ×יצבק$" -syn match diffIsA "^.* .*-ל .* .* תוושהל ×Ÿ×ª×™× ×ל$" -syn match diffNoEOL "^\\ ץבוקה ףוסב השד.-הרוש ות רס." -syn match diffCommon "^.*-ו .* :תוהז תויקית-תת$" +" ^.* are expansive patterns for long lines, so disabled unless we can match +" some specific hebrew chars +if search('\%u05d5\|\%u05d1', 'nw', '', 100) + syn match diffOnly "^.*-ב קר ××¦×ž× .*" + syn match diffIdentical "^××™×”×– ×× ×™×” .*-ו .* ×יצבקה$" + syn match diffDiffer "^הזמ ×”×– ××™× ×•×© `.*'-ו `.*' ×יצבקה$" + syn match diffBDiffer "^הזמ ×”×– ××™× ×•×© `.*'-ו `.*' ××™×™×¨× ×™×‘ ×יצבק$" + syn match diffIsA "^.* .*-ל .* .* תוושהל ×Ÿ×ª×™× ×ל$" + syn match diffNoEOL "^\\ ץבוקה ףוסב השד.-הרוש ות רס." + syn match diffCommon "^.*-ו .* :תוהז תויקית-תת$" +endif " hr syn match diffOnly "^Samo u .*" diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim index df33793bb2..120a999404 100644 --- a/runtime/syntax/fortran.vim +++ b/runtime/syntax/fortran.vim @@ -1,15 +1,15 @@ " Vim syntax file " Language: Fortran 2008 (and earlier versions: 2003, 95, 90, and 77) -" Version: 0.94 -" Last Change: 2012 June 18 -" Maintainer: Ajit J. Thakkar (ajit AT unb.ca); <http://www.unb.ca/chem/ajit/> +" Version: 0.95 +" Last Change: 2015 Jan. 15 +" Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www2.unb.ca/~ajit/> " Usage: For instructions, do :help fortran-syntax from Vim " Credits: " Version 0.1 was based on the fortran 77 syntax file by Mario Eusebio and " Preben Guldberg. Useful suggestions were made by: Andrej Panjkov, " Bram Moolenaar, Thomas Olsen, Michael Sternberg, Christian Reile, " Walter Dieudonné, Alexander Wagner, Roman Bertle, Charles Rendleman, -" Andrew Griffiths, Joe Krahn, and Hendrik Merx. +" Andrew Griffiths, Joe Krahn, Hendrik Merx, and Matt Thompson. if exists("b:current_syntax") finish @@ -298,6 +298,41 @@ if b:fortran_dialect == "f08" syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image syn keyword fortranIO newunit syn keyword fortranType contiguous + +" CUDA fortran + syn match fortranTypeCUDA "\<attributes\>" + syn keyword fortranTypeCUDA host global device value + syn keyword fortranTypeCUDA shared constant pinned texture + syn keyword fortranTypeCUDA dim1 dim2 dim3 dim4 + syn keyword fortranTypeCUDA cudadeviceprop cuda_count_kind cuda_stream_kind + syn keyword fortranTypeCUDA cudaEvent cudaFuncAttributes cudaArrayPtr + syn keyword fortranTypeCUDA cudaSymbol cudaChannelFormatDesc cudaPitchedPtr + syn keyword fortranTypeCUDA cudaExtent cudaMemcpy3DParms + syn keyword fortranTypeCUDA cudaFuncCachePreferNone cudaFuncCachePreferShared + syn keyword fortranTypeCUDA cudaFuncCachePreferL1 cudaLimitStackSize + syn keyword fortranTypeCUDA cudaLimitPrintfSize cudaLimitMallocHeapSize + syn keyword fortranTypeCUDA cudaSharedMemBankSizeDefault cudaSharedMemBankSizeFourByte cudaSharedMemBankSizeEightByte + syn keyword fortranTypeCUDA cudaEventDefault cudaEventBlockingSync cudaEventDisableTiming + syn keyword fortranTypeCUDA cudaMemcpyHostToDevice cudaMemcpyDeviceToHost + syn keyword fortranTypeCUDA cudaMemcpyDeviceToDevice + syn keyword fortranTypeCUDA cudaErrorNotReady cudaSuccess cudaErrorInvalidValue + syn keyword fortranTypeCUDA c_devptr + + syn match fortranStringCUDA "blockidx%[xyz]" + syn match fortranStringCUDA "blockdim%[xyz]" + syn match fortranStringCUDA "griddim%[xyz]" + syn match fortranStringCUDA "threadidx%[xyz]" + + syn keyword fortranIntrinsicCUDA warpsize syncthreads syncthreads_and syncthreads_count syncthreads_or threadfence threadfence_block threadfence_system gpu_time allthreads anythread ballot + syn keyword fortranIntrinsicCUDA atomicadd atomicsub atomicmax atomicmin atomicand atomicor atomicxor atomicexch atomicinc atomicdec atomiccas sizeof __shfl __shfl_up __shfl_down __shfl_xor + syn keyword fortranIntrinsicCUDA cudaChooseDevice cudaDeviceGetCacheConfig cudaDeviceGetLimit cudaDeviceGetSharedMemConfig cudaDeviceReset cudaDeviceSetCacheConfig cudaDeviceSetLimit cudaDeviceSetSharedMemConfig cudaDeviceSynchronize cudaGetDevice cudaGetDeviceCount cudaGetDeviceProperties cudaSetDevice cudaSetDeviceFlags cudaSetValidDevices + syn keyword fortranIntrinsicCUDA cudaThreadExit cudaThreadSynchronize cudaGetLastError cudaGetErrorString cudaPeekAtLastError cudaStreamCreate cudaStreamDestroy cudaStreamQuery cudaStreamSynchronize cudaStreamWaitEvent cudaEventCreate cudaEventCreateWithFlags cudaEventDestroy cudaEventElapsedTime cudaEventQuery cudaEventRecord cudaEventSynchronize + syn keyword fortranIntrinsicCUDA cudaFuncGetAttributes cudaFuncSetCacheConfig cudaFuncSetSharedMemConfig cudaSetDoubleForDevice cudaSetDoubleForHost cudaFree cudaFreeArray cudaFreeHost cudaGetSymbolAddress cudaGetSymbolSize + syn keyword fortranIntrinsicCUDA cudaHostAlloc cudaHostGetDevicePointer cudaHostGetFlags cudaHostRegister cudaHostUnregister cudaMalloc cudaMallocArray cudaMallocHost cudaMallocPitch cudaMalloc3D cudaMalloc3DArray + syn keyword fortranIntrinsicCUDA cudaMemcpy cudaMemcpyArraytoArray cudaMemcpyAsync cudaMemcpyFromArray cudaMemcpyFromSymbol cudaMemcpyFromSymbolAsync cudaMemcpyPeer cudaMemcpyPeerAsync cudaMemcpyToArray cudaMemcpyToSymbol cudaMemcpyToSymbolAsync cudaMemcpy2D cudaMemcpy2DArrayToArray cudaMemcpy2DAsync cudaMemcpy2DFromArray cudaMemcpy2DToArray cudaMemcpy3D cudaMemcpy3DAsync + syn keyword fortranIntrinsicCUDA cudaMemGetInfo cudaMemset cudaMemset2D cudaMemset3D cudaDeviceCanAccessPeer cudaDeviceDisablePeerAccess cudaDeviceEnablePeerAccess cudaPointerGetAttributes cudaDriverGetVersion cudaRuntimeGetVersion + + syn region none matchgroup=fortranType start="<<<" end=">>>" contains=ALLBUT,none endif syn cluster fortranCommentGroup contains=fortranTodo @@ -453,6 +488,11 @@ else hi! def link fortranConditionalR fortranConditional endif +" CUDA +hi def link fortranIntrinsicCUDA fortranIntrinsic +hi def link fortranTypeCUDA fortranType +hi def link fortranStringCUDA fortranString + hi def link fortranFormatSpec Identifier hi def link fortranFloat Float hi def link fortranPreCondit PreCondit diff --git a/runtime/syntax/j.vim b/runtime/syntax/j.vim index 0cdd59b887..4912942e8b 100644 --- a/runtime/syntax/j.vim +++ b/runtime/syntax/j.vim @@ -2,7 +2,7 @@ " Language: J " Maintainer: David Bürgin <676c7473@gmail.com> " URL: https://github.com/glts/vim-j -" Last Change: 2014-10-05 +" Last Change: 2015-01-11 if exists('b:current_syntax') finish @@ -23,12 +23,12 @@ syntax match jControl /\<\%(for\|goto\|label\)_\a\k*\./ " Standard library names. A few names need to be defined with ":syntax match" " because they would otherwise take precedence over the corresponding jControl " and jDefineExpression items. -syntax keyword jStdlibNoun ARGV BINPATH CR CRLF DEL Debug EAV EMPTY FF FHS IF64 IFIOS IFJCDROID IFJHS IFQT IFRASPI IFUNIX IFWIN IFWINCE IFWINE IFWOW64 JB01 JBOXED JCHAR JCMPX JFL JINT JPTR JSIZES JSTR JTYPES JVERSION LF LF2 TAB UNAME UNXLIB andurl dbhelp libjqt -syntax keyword jStdlibAdverb define each every fapplylines inv inverse items leaf rows table +syntax keyword jStdlibNoun ARGV BINPATH CR CRLF DEL Debug EAV EMPTY FF FHS IF64 IFIOS IFJCDROID IFJHS IFQT IFRASPI IFUNIX IFWIN IFWINCE IFWINE IFWOW64 JB01 JBOXED JCHAR JCMPX JFL JINT JPTR JSIZES JSTR JTYPES JVERSION LF LF2 TAB UNAME UNXLIB dbhelp libjqt +syntax keyword jStdlibAdverb define each every fapplylines inv inverse items leaf rows rxapply rxmerge table syntax keyword jStdlibConjunction bind cuts def on -syntax keyword jStdlibVerb AND Endian IFDEF Note OR XOR alpha17 alpha27 anddf android_exec_host andunzip apply boxopen boxxopen bx calendar cd cdcb cder cderx cdf charsub chopstring clear coclass cocreate cocurrent codestroy coerase cofind cofindv cofullname coinfo coinsert coname conames conew conl conouns conounsx copath copathnl copathnlx coreset costate cut cutLF cutopen cutpara datatype dbctx dberm dberr dbg dbjmp dblocals dblxq dblxs dbnxt dbq dbr dbret dbrr dbrrx dbrun dbs dbsig dbsq dbss dbst dbstack dbstk dbstop dbstopme dbstopnext dbstops dbtrace dbview deb debc delstring detab dfh dir dircompare dircompares dirfind dirpath dirss dirssrplc dirtree dirused dlb dltb dltbs dquote drop dropafter dropto dtb dtbs echo empty endian erase evtloop exit expand f2utf8 fappend fappends fboxname fc fcopynew fdir ferase fetch fexist fexists fgets file2url fixdotdot fliprgb fmakex foldpara foldtext fpathcreate fpathname fputs fread freadblock freadr freads frename freplace fsize fss fssrplc fstamp fstringreplace ftype fview fwrite fwritenew fwrites getargs getdate getenv getqtbin hfd hostpathsep ic install iospath isatty isotimestamp isutf8 jcwdpath joinstring jpathsep jsystemdefs list ljust load loadd mema memf memr memw nameclass namelist names nc nl pick quote require rjust rplc script scriptd setbreak show sign sminfo smoutput sort split splitnostring splitstring ss startupandroid startupconsole startupide stderr stdin stdout stringreplace symdat symget symset take takeafter taketo timespacex timestamp timex tmoutput toCRLF toHOST toJ todate todayno tolower topara toupper tsdiff tsrep tstamp type ucp ucpcount unxlib usleep utf8 uucp valdate wcsize weekday weeknumber weeksinyear winpathsep +syntax keyword jStdlibVerb AND Endian IFDEF OR XOR anddf android_exec_am android_exec_host andunzip apply boxopen boxxopen bx calendar cd cdcb cder cderx cdf charsub chopstring cleartags clear coclass cocreate cocurrent codestroy coerase cofind cofindv cofullname coinfo coinsert compare coname conames conew conl conouns conounsx copath copathnl copathnlx coreset costate cut cutLF cutopen cutpara datatype dbctx dberm dberr dbg dbjmp dblocals dblxq dblxs dbnxt dbq dbr dbret dbrr dbrrx dbrun dbs dbsig dbsq dbss dbst dbstack dbstk dbstop dbstopme dbstopnext dbstops dbtrace dbview deb debc delstring detab dfh dir dircompare dircompares dirfind dirpath dirss dirssrplc dirtree dirused dlb dltb dltbs dquote drop dropafter dropto dtb dtbs echo empty endian erase evtloop exit expand f2utf8 fappend fappends fboxname fc fcompare fcompares fcopynew fdir ferase fetch fexist fexists fgets file2url fixdotdot fliprgb fmakex foldpara foldtext fpathcreate fpathname fputs fread freadblock freadr freads frename freplace fsize fss fssrplc fstamp fstringreplace ftype fview fwrite fwritenew fwrites getalpha getargs getdate getenv getqtbin hfd hostpathsep ic install iospath isatty isotimestamp isutf8 jcwdpath joinstring jpath jpathsep jsystemdefs launch list ljust load loadd loadtags mema memf memr memw nameclass namelist names nc nl pick quote require rjust rplc rxE rxall rxcomp rxcut rxeq rxerror rxfirst rxfree rxfrom rxhandles rxin rxindex rxinfo rxmatch rxmatches rxrplc rxutf8 script scriptd scripts setalpha setbreak shell show sign sminfo smoutput sort split splitnostring splitstring ss startupandroid startupconsole startupide stderr stdin stdout stringreplace symdat symget symset ta tagcp tagopen tagselect take takeafter taketo timespacex timestamp timex tmoutput toCRLF toHOST toJ todate todayno tolower topara toupper tsdiff tsrep tstamp type ucp ucpcount unxlib usleep utf8 uucp valdate wcsize weekday weeknumber weeksinyear winpathsep xedit syntax match jStdlibNoun /\<\%(adverb\|conjunction\|dyad\|monad\|noun\|verb\)\>/ -syntax match jStdlibVerb /\<\%(assert\|break\|do\)\>\.\@!/ +syntax match jStdlibVerb /\<\%(Note\|\%(assert\|break\|do\)\.\@!\)\>/ " Numbers. Matching J numbers is difficult. In fact, the job cannot be done " with regular expressions alone. Below is a sketch of the pattern used. It @@ -75,12 +75,12 @@ syntax match jConjunction /;\.\|\^:\|![.:]/ " the next line. The trick is to split the problem into two regions and link " them with "nextgroup=". The fold wrapper provides syntax folding. syntax region jNounDefineFold - \ matchgroup=NONE start=/\<\%(\%(0\|noun\)\s\+\%(\:\s*0\|def\s\+0\|define\)\>\)\@=/ + \ matchgroup=NONE start=/\%(\%(\%(^\s*Note\)\|\<\%(0\|noun\)\s\+\%(\:\s*0\|def\s\+0\|define\)\)\>\)\@=/ \ keepend matchgroup=NONE end=/^\s*)\s*$/ \ contains=jNounDefineStart \ fold syntax region jNounDefineStart - \ matchgroup=jDefineExpression start=/\<\%(0\|noun\)\s\+\%(\:\s*0\|def\s\+0\|define\)\>/ + \ matchgroup=jDefineExpression start=/\%(\%(^\s*Note\)\|\<\%(0\|noun\)\s\+\%(\:\s*0\|def\s\+0\|define\)\)\>/ \ keepend matchgroup=NONE end=/$/ \ contains=@jStdlibItems,@jPrimitiveItems,jNumber,jString,jParenGroup,jParen,jComment \ contained oneline skipempty nextgroup=jDefineEnd,jNounDefine @@ -112,7 +112,7 @@ syntax region jParenGroup \ oneline transparent syntax keyword jTodo contained TODO FIXME XXX -syntax match jComment /NB\..*$/ contains=jTodo,@Spell +syntax match jComment /\<NB\..*$/ contains=jTodo,@Spell syntax match jSharpBang /\%^#!.*$/ diff --git a/runtime/syntax/mplayerconf.vim b/runtime/syntax/mplayerconf.vim index b348327f90..84ad2daf13 100644 --- a/runtime/syntax/mplayerconf.vim +++ b/runtime/syntax/mplayerconf.vim @@ -1,7 +1,8 @@ " Vim syntax file -" Language: mplayer(1) configuration file -" Maintainer: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2007-06-17 +" Language: mplayer(1) configuration file +" Maintainer: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com> +" Previous Maintainer: Nikolai Weibull <now@bitwi.se> +" Latest Revision: 2015-01-24 if exists("b:current_syntax") finish @@ -19,7 +20,7 @@ syn region mplayerconfComment display oneline start='#' end='$' syn keyword mplayerconfPreProc include -syn keyword mplayerconfBoolean yes no +syn keyword mplayerconfBoolean yes no true false syn match mplayerconfNumber '\<\d\+\>' @@ -68,7 +69,49 @@ syn keyword mplayerconfOption hardframedrop nomouseinput bandwidth dumpstream \ audio-delay audio-preload endpos ffourcc \ include info noautoexpand noskip o oac of \ ofps ovc skiplimit v vobsubout vobsuboutid - \ lameopts lavcopts nuvopts xvidencopts + \ lameopts lavcopts nuvopts xvidencopts a52drc + \ adapter af-add af-clr af-del af-pre + \ allow-dangerous-playlist-parsing ass + \ ass-border-color ass-bottom-margin ass-color + \ ass-font-scale ass-force-style ass-hinting + \ ass-line-spacing ass-styles ass-top-margin + \ ass-use-margins ausid bluray-angle + \ bluray-device border border-pos-x border-pos-y + \ cache-min cache-seek-min capture codecpath + \ codecs-file correct-pts crash-debug + \ doubleclick-time dvd-speed edl-backward-delay + \ edl-start-pts embeddedfonts fafmttag + \ field-dominance fontconfig force-avi-aspect + \ force-key-frames frameno-file fullscreen gamma + \ gui gui-include gui-wid heartbeat-cmd + \ heartbeat-interval hr-edl-seek + \ http-header-fields idle ignore-start + \ key-fifo-size list-properties menu-chroot + \ menu-keepdir menu-startup mixer-channel + \ monitor-orientation monitorpixelaspect + \ mouse-movements msgcharset msgcolor msglevel + \ msgmodule name noar nocache noconfig + \ noconsolecontrols nocorrect-pts nodouble + \ noedl-start-pts noencodedups + \ noflip-hebrew-commas nogui noidx noodml + \ nostop-xscreensaver nosub noterm-osd + \ osd-duration osd-fractions panscanrange + \ pausing playing-msg priority profile + \ progbar-align psprobe pvr radio referrer + \ refreshrate reuse-socket rtc rtc-device + \ rtsp-destination rtsp-port + \ rtsp-stream-over-http screenh show-profile + \ softvol softvol-max sub-paths subfont + \ term-osd-esc title tvscan udp-ip udp-master + \ udp-port udp-seek-threshold udp-slave + \ unrarexec use-filedir-conf use-filename-title + \ vf-add vf-clr vf-del vf-pre volstep volume + \ zrhdec zrydoff + +syn region mplayerconfString display oneline start=+"+ end=+"+ +syn region mplayerconfString display oneline start=+'+ end=+'+ + +syn region mplayerconfProfile display oneline start='^\s*\[' end='\]' hi def link mplayerconfTodo Todo hi def link mplayerconfComment Comment @@ -76,6 +119,8 @@ hi def link mplayerconfPreProc PreProc hi def link mplayerconfBoolean Boolean hi def link mplayerconfNumber Number hi def link mplayerconfOption Keyword +hi def link mplayerconfString String +hi def link mplayerconfProfile Special let b:current_syntax = "mplayerconf" diff --git a/runtime/syntax/rpcgen.vim b/runtime/syntax/rpcgen.vim index 548f8c807f..85036dc049 100644 --- a/runtime/syntax/rpcgen.vim +++ b/runtime/syntax/rpcgen.vim @@ -1,15 +1,11 @@ " Vim syntax file " Language: rpcgen -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 06, 2005 -" Version: 8 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Jan 13, 2015 +" Version: 10 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_RPCGEN -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") +if exists("b:current_syntax") finish endif diff --git a/runtime/syntax/sm.vim b/runtime/syntax/sm.vim index 2f9e6d7d01..ad96cdb3b5 100644 --- a/runtime/syntax/sm.vim +++ b/runtime/syntax/sm.vim @@ -1,15 +1,11 @@ " Vim syntax file " Language: sendmail -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 06, 2005 -" Version: 4 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Jan 13, 2015 +" Version: 6 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SM + +if exists("b:current_syntax") finish endif diff --git a/runtime/syntax/strace.vim b/runtime/syntax/strace.vim index 80cd262efc..0f686fd808 100644 --- a/runtime/syntax/strace.vim +++ b/runtime/syntax/strace.vim @@ -1,9 +1,8 @@ " Vim syntax file " This is a GENERATED FILE. Please always refer to source file at the URI below. " Language: strace output -" Maintainer: David Ne\v{c}as (Yeti) <yeti@physics.muni.cz> -" Last Change: 2002-10-10 -" URL: http://trific.ath.cx/Ftp/vim/syntax/strace.vim +" Maintainer: David Necas (Yeti) <yeti@physics.muni.cz> +" Last Change: 2015-01-16 " Setup if version >= 600 @@ -17,7 +16,7 @@ endif syn case match " Parse the line -syn match straceSpecialChar "\\\d\d\d\|\\." contained +syn match straceSpecialChar "\\\o\{1,3}\|\\." contained syn region straceString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=straceSpecialChar oneline syn match straceNumber "\W[+-]\=\(\d\+\)\=\.\=\d\+\([eE][+-]\=\d\+\)\="lc=1 syn match straceNumber "\W0x\x\+"lc=1 diff --git a/runtime/syntax/valgrind.vim b/runtime/syntax/valgrind.vim index c247927c2f..d099971826 100644 --- a/runtime/syntax/valgrind.vim +++ b/runtime/syntax/valgrind.vim @@ -2,7 +2,8 @@ " Language: Valgrind Memory Debugger Output " Maintainer: Roger Luethi <rl@hellgate.ch> " Program URL: http://devel-home.kde.org/~sewardj/ -" Last Change: 2014 Oct 02 +" Last Change: 2015 Jan 27 +" Included improvement by Dominique Pelle " " Notes: mostly based on strace.vim and xml.vim " @@ -15,6 +16,9 @@ endif let s:keepcpo= &cpo set cpo&vim +" Lines can be long with demangled c++ functions. +setlocal synmaxcol=8000 + syn case match syn sync minlines=50 @@ -29,8 +33,8 @@ syn region valgrindRegion \ contains=valgrindPidChunk,valgrindLine syn region valgrindPidChunk - \ start=+\(^==\)\@<=+ - \ end=+\(==\)\@=+ + \ start=+^==\zs+ + \ end=+\ze==+ \ contained \ contains=valgrindPid0,valgrindPid1,valgrindPid2,valgrindPid3,valgrindPid4,valgrindPid5,valgrindPid6,valgrindPid7,valgrindPid8,valgrindPid9 \ keepend @@ -64,10 +68,11 @@ syn match valgrindSummary ".*SUMMARY:" contained syn match valgrindLoc "\s\+\(by\|at\|Address\).*$" contained \ contains=valgrindAt,valgrindAddr,valgrindFunc,valgrindBin,valgrindSrc syn match valgrindAt "at\s\@=" contained -syn match valgrindAddr "\(\W\)\@<=0x\x\+" contained -syn match valgrindFunc "\(: \)\@<=\w\+" contained -syn match valgrindBin "\((\(with\|\)in \)\@<=\S\+\()\)\@=" contained -syn match valgrindSrc "\((\)\@<=[^)]*:\d\+\()\)\@=" contained +syn match valgrindAddr "\W\zs0x\x\+" contained + +syn match valgrindFunc ": \zs\h[a-zA-Z0-9_:\[\]()<>&*+\-,=%!|^ ]*\ze([^)]*)$" contained +syn match valgrindBin "(\(with\)\=in \zs\S\+)\@=" contained +syn match valgrindSrc "(\zs[^)]*:\d\+)\@=" contained " Define the default highlighting diff --git a/runtime/syntax/yacc.vim b/runtime/syntax/yacc.vim index 17a1cab6b7..714432be9d 100644 --- a/runtime/syntax/yacc.vim +++ b/runtime/syntax/yacc.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Yacc " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Mar 20, 2014 -" Version: 11 +" Last Change: Jan 14, 2015 +" Version: 12 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax " " Options: {{{1 diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 4a567727d8..1f6c787b24 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -38,11 +38,10 @@ check_executable() { get_vim_sources() { check_executable git - echo "Retrieving Vim sources." + cd "${VIM_SOURCE_DIR}" if [[ ! -d ${VIM_SOURCE_DIR} ]]; then echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'." git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" - cd "${VIM_SOURCE_DIR}" else if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then echo "✘ ${VIM_SOURCE_DIR} does not appear to be a git repository." @@ -50,7 +49,6 @@ get_vim_sources() { exit 1 fi echo "Updating Vim sources in '${VIM_SOURCE_DIR}'." - cd "${VIM_SOURCE_DIR}" git pull && echo "✔ Updated Vim sources." || echo "✘ Could not update Vim sources; ignoring error." @@ -58,11 +56,8 @@ get_vim_sources() { } commit_message() { - echo "vim-patch:${vim_version} - -${vim_message} - -${vim_commit_url}" + printf 'vim-patch:%s\n\n%s\n\n%s' "${vim_version}" \ + "${vim_message}" "${vim_commit_url}" } assign_commit_details() { @@ -102,8 +97,10 @@ get_vim_patch() { # Collect patch details and store into variables. vim_full="$(git show -1 --pretty=medium "${vim_commit}")" + # Patch surgery: preprocess the patch. + # - transform src/ paths to src/nvim/ vim_diff="$(git show -1 "${vim_commit}" \ - | sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim. + | LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" neovim_message="$(commit_message)" neovim_pr=" \`\`\` @@ -161,22 +158,20 @@ ${vim_diff} list_vim_patches() { get_vim_sources - echo - echo "Vim patches missing from Neovim:" + printf "\nVim patches missing from Neovim:\n" # Get tags since 7.4.442. - local vim_tags=$(cd "${VIM_SOURCE_DIR}" && \ - git tag --contains v7.4.442) + local vim_tags=$(cd "${VIM_SOURCE_DIR}" && git tag --contains v7.4.442) # Get non-versioned commits since e2719096. if git log -1 --grep='.' --invert-grep > /dev/null 2>&1 ; then local vim_runtime_commits=$(cd "${VIM_SOURCE_DIR}" && \ - git log --format='%H' --grep='^patch' --grep='^updated for version' --invert-grep e2719096250a19ecdd9a35d13702879f163d2a50..HEAD) - else - # --invert-grep requires git 2.4+ + git log --reverse --format='%H' --grep='^patch' --grep='^updated for version' \ + --invert-grep e2719096250a19ecdd9a35d13702879f163d2a50..HEAD) + else # --invert-grep requires git 2.4+ echo "Warning: some runtime updates may not be listed (requires git 2.4+)." local vim_runtime_commits=$(cd "${VIM_SOURCE_DIR}" && \ - git log --format='%H' --grep='Updated' e2719096250a19ecdd9a35d13702879f163d2a50..HEAD) + git log --reverse --format='%H' --grep='Updated' e2719096250a19ecdd9a35d13702879f163d2a50..HEAD) fi local vim_commit @@ -191,7 +186,7 @@ list_vim_patches() { else # Untagged Vim patch (e.g. runtime updates), check the Neovim git log: is_missing="$(cd "${NEOVIM_SOURCE_DIR}" && - git log -1 --no-merges --grep="vim\-patch:${vim_commit:0:7}" --pretty=format:"false")" + git log -1 --no-merges --grep="vim\-patch:${vim_commit:0:7}" --pretty=format:false)" fi if [[ ${is_missing} != "false" ]]; then @@ -258,8 +253,6 @@ review_pr() { echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'." git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff" echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'." - git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.patch" - echo "✔ Saved full Vim commit details to '${NEOVIM_SOURCE_DIR}/${base_name}.patch'." echo "You can use 'git clean' to remove these files when you're done." echo diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fae8e9ecd0..762cd3efd3 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1414,7 +1414,6 @@ buflist_new ( return NULL; if (aborting()) /* autocmds may abort script processing */ return NULL; - /* buf->b_nwindows = 0; why was this here? */ free_buffer_stuff(buf, FALSE); /* delete local variables et al. */ /* Init the options. */ @@ -1475,6 +1474,9 @@ buflist_new ( fmarks_check_names(buf); /* check file marks for this file */ buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */ if (!(flags & BLN_DUMMY)) { + // Tricky: these autocommands may change the buffer list. They could also + // split the window with re-using the one empty buffer. This may result in + // unexpectedly losing the empty buffer. apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf); if (!buf_valid(buf)) { return NULL; diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 3eabb7ee43..6b5bbe3b00 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -612,6 +612,7 @@ struct file_buffer { char_u *b_p_cfu; /* 'completefunc' */ char_u *b_p_ofu; /* 'omnifunc' */ int b_p_eol; /* 'endofline' */ + int b_p_fixeol; /* 'fixendofline' */ int b_p_et; /* 'expandtab' */ int b_p_et_nobin; /* b_p_et saved for binary mode */ char_u *b_p_fenc; /* 'fileencoding' */ diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 8dc2844d8e..b3222b0781 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -5017,8 +5017,9 @@ insertchar ( int textwidth; char_u *p; int fo_ins_blank; + int force_format = flags & INSCHAR_FORMAT; - textwidth = comp_textwidth(flags & INSCHAR_FORMAT); + textwidth = comp_textwidth(force_format); fo_ins_blank = has_format_option(FO_INS_BLANK); /* @@ -5037,7 +5038,7 @@ insertchar ( * before 'textwidth' */ if (textwidth > 0 - && ((flags & INSCHAR_FORMAT) + && (force_format || (!ascii_iswhite(c) && !((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG) @@ -5051,8 +5052,11 @@ insertchar ( /* Format with 'formatexpr' when it's set. Use internal formatting * when 'formatexpr' isn't set or it returns non-zero. */ int do_internal = TRUE; + colnr_T virtcol = get_nolist_virtcol() + + char2cells(c != NUL ? c : gchar_cursor()); - if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0) { + if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0 + && (force_format || virtcol > (colnr_T)textwidth)) { do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0); /* It may be required to save for undo again, e.g. when setline() * was called. */ @@ -6580,9 +6584,14 @@ static int cindent_on(void) { */ void fixthisline(IndentGetter get_the_indent) { - change_indent(INDENT_SET, get_the_indent(), FALSE, 0, TRUE); - if (linewhite(curwin->w_cursor.lnum)) - did_ai = TRUE; /* delete the indent if the line stays empty */ + int amount = get_the_indent(); + + if (amount >= 0) { + change_indent(INDENT_SET, amount, false, 0, true); + if (linewhite(curwin->w_cursor.lnum)) { + did_ai = true; // delete the indent if the line stays empty + } + } } void fix_indent(void) { @@ -7427,15 +7436,14 @@ static int ins_bs(int c, int mode, int *inserted_space_p) * delete newline! */ if (curwin->w_cursor.col == 0) { - lnum = Insstart_orig.lnum; + lnum = Insstart.lnum; if (curwin->w_cursor.lnum == lnum || revins_on) { if (u_save((linenr_T)(curwin->w_cursor.lnum - 2), (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) { return FALSE; } - --Insstart_orig.lnum; - Insstart_orig.col = MAXCOL; - Insstart = Insstart_orig; + --Insstart.lnum; + Insstart.col = MAXCOL; } /* * In replace mode: diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4a2bf2ac7a..b60886704e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5651,6 +5651,14 @@ bool garbage_collect(void) ABORTING(set_ref_in_ht)(&fc->l_avars.dv_hashtab, copyID, NULL); } + // Jobs + { + TerminalJobData *data; + map_foreach_value(jobs, data, { + ABORTING(set_ref_dict)(data->self, copyID); + }) + } + // v: vars ABORTING(set_ref_in_ht)(&vimvarht, copyID, NULL); @@ -5728,8 +5736,7 @@ static int free_unref_items(int copyID) // Go through the list of dicts and free items without the copyID. // Don't free dicts that are referenced internally. for (dict_T *dd = first_dict; dd != NULL; ) { - if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) - && !dd->internal_refcount) { + if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) { // Free the Dictionary and ordinary items it contains, but don't // recurse into Lists and Dictionaries, they will be in the list // of dicts or list of lists. */ @@ -5970,7 +5977,6 @@ dict_T *dict_alloc(void) FUNC_ATTR_NONNULL_RET d->dv_scope = 0; d->dv_refcount = 0; d->dv_copyID = 0; - d->internal_refcount = 0; QUEUE_INIT(&d->watchers); return d; @@ -21620,7 +21626,6 @@ static inline bool common_job_callbacks(dict_T *vopts, ufunc_T **on_stdout, if (get_dict_callback(vopts, "on_stdout", on_stdout) && get_dict_callback(vopts, "on_stderr", on_stderr) && get_dict_callback(vopts, "on_exit", on_exit)) { - vopts->internal_refcount++; vopts->dv_refcount++; return true; } @@ -21682,7 +21687,6 @@ static inline void free_term_job_data_event(void **argv) } if (data->self) { - data->self->internal_refcount--; dict_unref(data->self); } queue_free(data->events); @@ -21933,7 +21937,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments) true, NULL); - arguments->lv_refcount--; + list_unref(arguments); // Restore caller scope information restore_funccal(provider_caller_scope.funccalp); provider_caller_scope = saved_provider_caller_scope; diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index bd50d6b829..ed419268d2 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -118,8 +118,6 @@ struct dictvar_S { dict_T *dv_copydict; /* copied dict used by deepcopy() */ dict_T *dv_used_next; /* next dict in used dicts list */ dict_T *dv_used_prev; /* previous dict in used dicts list */ - int internal_refcount; // number of internal references to - // prevent garbage collection QUEUE watchers; // dictionary key watchers set by user code }; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3f19421a75..d902234ef7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2112,7 +2112,6 @@ do_ecmd ( goto theend; if (buf->b_ml.ml_mfp == NULL) { /* no memfile yet */ oldbuf = FALSE; - buf->b_nwindows = 0; } else { /* existing memfile */ oldbuf = TRUE; (void)buf_check_timestamp(buf, FALSE); @@ -2138,7 +2137,7 @@ do_ecmd ( * Make the (new) buffer the one used by the current window. * If the old buffer becomes unused, free it if ECMD_HIDE is FALSE. * If the current buffer was empty and has no file name, curbuf - * is returned by buflist_new(). + * is returned by buflist_new(), nothing to do here. */ if (buf != curbuf) { /* @@ -2225,8 +2224,7 @@ do_ecmd ( } xfree(new_name); au_new_curbuf = NULL; - } else - ++curbuf->b_nwindows; + } curwin->w_pcmark.lnum = 1; curwin->w_pcmark.col = 0; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index bc5b08ef24..1a6c85abaa 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1544,6 +1544,11 @@ rewind_retry: /* First try finding a NL, for Dos and Unix */ if (try_dos || try_unix) { for (p = ptr; p < ptr + size; ++p) { + // Reset the carriage return counter. + if (try_mac) { + try_mac = 1; + } + if (*p == NL) { if (!try_unix || (try_dos && p > ptr && p[-1] == CAR)) @@ -1551,6 +1556,8 @@ rewind_retry: else fileformat = EOL_UNIX; break; + } else if (*p == CAR && try_mac) { + try_mac++; } } @@ -1571,6 +1578,10 @@ rewind_retry: if (try_mac > try_unix) fileformat = EOL_MAC; } + } else if (fileformat == EOL_UNKNOWN && try_mac == 1) { + // Looking for CR but found no end-of-line markers at all: + // use the default format. + fileformat = default_fileformat(); } } @@ -1922,10 +1933,10 @@ failed: check_marks_read(); /* - * Trick: We remember if the last line of the read didn't have - * an eol even when 'binary' is off, for when writing it again with - * 'binary' on. This is required for - * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. + * We remember if the last line of the read didn't have + * an eol even when 'binary' is off, to support turning 'fixeol' off, + * or writing the read again with 'binary' on. The latter is required + * for ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. */ curbuf->b_no_eol_lnum = read_no_eol_lnum; @@ -3310,7 +3321,7 @@ restore_backup: /* write failed or last line has no EOL: stop here */ if (end == 0 || (lnum == end - && write_bin + && (write_bin || !buf->b_p_fixeol) && (lnum == buf->b_no_eol_lnum || (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol)))) { ++lnum; /* written the line, count it */ diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index d62e7aad03..340287499e 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -17,7 +17,11 @@ #include "nvim/search.h" #include "nvim/strings.h" - +// Find result cache for cpp_baseclass +typedef struct { + int found; + lpos_T lpos; +} cpp_baseclass_cache_T; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent_c.c.generated.h" @@ -25,6 +29,7 @@ /* * Find the start of a comment, not knowing if we are in a comment right now. * Search starts at w_cursor.lnum and goes backwards. + * Return NULL when not inside a comment. */ static pos_T *ind_find_start_comment(void) { /* XXX */ @@ -65,6 +70,62 @@ find_start_comment ( /* XXX */ } /* + * Find the start of a comment or raw string, not knowing if we are in a + * comment or raw string right now. + * Search starts at w_cursor.lnum and goes backwards. + * Return NULL when not inside a comment or raw string. + * "CORS" -> Comment Or Raw String + */ +static pos_T *ind_find_start_CORS(void) +{ /* XXX */ + pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment); + pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment); + + /* If comment_pos is before rs_pos the raw string is inside the comment. + * If rs_pos is before comment_pos the comment is inside the raw string. */ + if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos))) + return rs_pos; + return comment_pos; +} + +/* + * Find the start of a raw string, not knowing if we are in one right now. + * Search starts at w_cursor.lnum and goes backwards. + * Return NULL when not inside a raw string. + */ +static pos_T *find_start_rawstring(int ind_maxcomment) +{ /* XXX */ + pos_T *pos; + char_u *line; + char_u *p; + long cur_maxcomment = ind_maxcomment; + + for (;;) + { + pos = findmatchlimit(NULL, 'R', FM_BACKWARD, cur_maxcomment); + if (pos == NULL) + break; + + /* + * Check if the raw string start we found is inside a string. + * If it is then restrict the search to below this line and try again. + */ + line = ml_get(pos->lnum); + for (p = line; *p && (colnr_T)(p - line) < pos->col; ++p) + p = skip_string(p); + if ((colnr_T)(p - line) <= pos->col) + break; + cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1; + if (cur_maxcomment <= 0) + { + pos = NULL; + break; + } + } + return pos; +} + +/* * Skip to the end of a "string" and a 'c' character. * If there is no string or character, return argument unmodified. */ @@ -97,7 +158,26 @@ static char_u *skip_string(char_u *p) break; } if (p[0] == '"') - continue; + continue; /* continue for another string */ + } else if (p[0] == 'R' && p[1] == '"') { + /* Raw string: R"[delim](...)[delim]" */ + char_u *delim = p + 2; + char_u *paren = vim_strchr(delim, '('); + + if (paren != NULL) + { + long delim_len = paren - delim; + + for (p += 3; *p; ++p) + if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0 + && p[delim_len + 1] == '"') + { + p += delim_len + 1; + break; + } + if (p[0] == '"') + continue; /* continue for another string */ + } } break; /* no string found */ } @@ -288,10 +368,11 @@ int cin_islabel(void) --curwin->w_cursor.lnum; /* - * If we're in a comment now, skip to the start of the comment. + * If we're in a comment or raw string now, skip to the start of + * it. */ curwin->w_cursor.col = 0; - if ((trypos = ind_find_start_comment()) != NULL) /* XXX */ + if ((trypos = ind_find_start_CORS()) != NULL) /* XXX */ curwin->w_cursor = *trypos; line = get_cursor_line_ptr(); @@ -986,17 +1067,18 @@ static int cin_isbreak(char_u *p) * * This is a lot of guessing. Watch out for "cond ? func() : foo". */ -static int -cin_is_cpp_baseclass ( - colnr_T *col /* return: column to align with */ -) -{ +static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) { + lpos_T *pos = &cached->lpos; // find position char_u *s; int class_or_struct, lookfor_ctor_init, cpp_base_class; linenr_T lnum = curwin->w_cursor.lnum; char_u *line = get_cursor_line_ptr(); - *col = 0; + if (pos->lnum <= lnum) { + return cached->found; // Use the cached result + } + + pos->col = 0; s = skipwhite(line); if (*s == '#') /* skip #define FOO x ? (x) : x */ @@ -1038,6 +1120,7 @@ cin_is_cpp_baseclass ( --lnum; } + pos->lnum = lnum; line = ml_get(lnum); s = cin_skipcomment(line); for (;; ) { @@ -1051,7 +1134,7 @@ cin_is_cpp_baseclass ( continue; } - if (s[0] == '"') + if (s[0] == '"' || (s[0] == 'R' && s[1] == '"')) s = skip_string(s) + 1; else if (s[0] == ':') { if (s[1] == ':') { @@ -1062,9 +1145,9 @@ cin_is_cpp_baseclass ( } else if (lookfor_ctor_init || class_or_struct) { /* we have something found, that looks like the start of * cpp-base-class-declaration or constructor-initialization */ - cpp_base_class = TRUE; - lookfor_ctor_init = class_or_struct = FALSE; - *col = 0; + cpp_base_class = true; + lookfor_ctor_init = class_or_struct = false; + pos->col = 0; s = cin_skipcomment(s + 1); } else s = cin_skipcomment(s + 1); @@ -1090,25 +1173,31 @@ cin_is_cpp_baseclass ( return FALSE; } else if (!vim_isIDc(s[0])) { /* if it is not an identifier, we are wrong */ - class_or_struct = FALSE; - lookfor_ctor_init = FALSE; - } else if (*col == 0) { + class_or_struct = false; + lookfor_ctor_init = false; + } else if (pos->col == 0) { /* it can't be a constructor-initialization any more */ lookfor_ctor_init = FALSE; /* the first statement starts here: lineup with this one... */ - if (cpp_base_class) - *col = (colnr_T)(s - line); + if (cpp_base_class) { + pos->col = (colnr_T)(s - line); + } } /* When the line ends in a comma don't align with it. */ - if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) - *col = 0; + if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) { + pos->col = 0; + } s = cin_skipcomment(s + 1); } } + cached->found = cpp_base_class; + if (cpp_base_class) { + pos->lnum = lnum; + } return cpp_base_class; } @@ -1216,7 +1305,7 @@ static pos_T *find_start_brace(void) pos = NULL; /* ignore the { if it's in a // or / * * / comment */ if ((colnr_T)cin_skip2pos(trypos) == trypos->col - && (pos = ind_find_start_comment()) == NULL) /* XXX */ + && (pos = ind_find_start_CORS()) == NULL) /* XXX */ break; if (pos != NULL) curwin->w_cursor.lnum = pos->lnum; @@ -1237,18 +1326,36 @@ static pos_T * find_match_char(char_u c, int ind_maxparen) pos_T cursor_save; pos_T *trypos; static pos_T pos_copy; + int ind_maxp_wk; cursor_save = curwin->w_cursor; - if ((trypos = findmatchlimit(NULL, c, 0, ind_maxparen)) != NULL) { - /* check if the ( is in a // comment */ - if ((colnr_T)cin_skip2pos(trypos) > trypos->col) + ind_maxp_wk = ind_maxparen; +retry: + if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) { + // check if the ( is in a // comment + if ((colnr_T)cin_skip2pos(trypos) > trypos->col) { + ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos->lnum); + if (ind_maxp_wk > 0) { + curwin->w_cursor = *trypos; + curwin->w_cursor.col = 0; // XXX + goto retry; + } trypos = NULL; - else { + } else { + pos_T *trypos_wk; + pos_copy = *trypos; /* copy trypos, findmatch will change it */ trypos = &pos_copy; curwin->w_cursor = *trypos; - if (ind_find_start_comment() != NULL) + if ((trypos_wk = ind_find_start_CORS()) != NULL) { /* XXX */ + ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum + - trypos_wk->lnum); + if (ind_maxp_wk > 0) { + curwin->w_cursor = *trypos_wk; + goto retry; + } trypos = NULL; + } } } curwin->w_cursor = cursor_save; @@ -1532,6 +1639,10 @@ void parse_cino(buf_T *buf) } } +/* + * Return the desired indent for C code. + * Return -1 if the indent should be left alone (inside a raw string). + */ int get_c_indent(void) { pos_T cur_curpos; @@ -1542,8 +1653,9 @@ int get_c_indent(void) char_u *theline; char_u *linecopy; pos_T *trypos; + pos_T *comment_pos; pos_T *tryposBrace = NULL; - pos_T tryposBraceCopy; + pos_T tryposCopy; pos_T our_paren_pos; char_u *start; int start_brace; @@ -1567,7 +1679,7 @@ int get_c_indent(void) #define LOOKFOR_CPP_BASECLASS 9 #define LOOKFOR_ENUM_OR_INIT 10 #define LOOKFOR_JS_KEY 11 -#define LOOKFOR_NO_COMMA 12 +#define LOOKFOR_COMMA 12 int whilelevel; linenr_T lnum; @@ -1578,6 +1690,7 @@ int get_c_indent(void) int cont_amount = 0; /* amount for continuation line */ int original_line_islabel; int added_to_amount = 0; + cpp_baseclass_cache_T cache_cpp_baseclass = { false, { MAXLNUM, 0 } }; /* make a copy, value is changed below */ int ind_continuation = curbuf->b_ind_continuation; @@ -1585,7 +1698,7 @@ int get_c_indent(void) /* remember where the cursor was when we started */ cur_curpos = curwin->w_cursor; - /* if we are at line 1 0 is fine, right? */ + /* if we are at line 1 zero indent is fine, right? */ if (cur_curpos.lnum == 1) return 0; @@ -1615,37 +1728,55 @@ int get_c_indent(void) original_line_islabel = cin_islabel(); /* XXX */ /* + * If we are inside a raw string don't change the indent. + * Ignore a raw string inside a comment. + */ + comment_pos = ind_find_start_comment(); + if (comment_pos != NULL) { + /* findmatchlimit() static pos is overwritten, make a copy */ + tryposCopy = *comment_pos; + comment_pos = &tryposCopy; + } + trypos = find_start_rawstring(curbuf->b_ind_maxcomment); + if (trypos != NULL && (comment_pos == NULL || lt(*trypos, *comment_pos))) { + amount = -1; + goto laterend; + } + + /* * #defines and so on always go at the left when included in 'cinkeys'. */ - if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE))) + if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', true))) { amount = curbuf->b_ind_hash_comment; + goto theend; + } /* * Is it a non-case label? Then that goes at the left margin too unless: * - JS flag is set. * - 'L' item has a positive value. */ - else if (original_line_islabel && !curbuf->b_ind_js + if (original_line_islabel && !curbuf->b_ind_js && curbuf->b_ind_jump_label < 0) { amount = 0; + goto theend; } /* * If we're inside a "//" comment and there is a "//" comment in a * previous line, lineup with that one. */ - else if (cin_islinecomment(theline) + if (cin_islinecomment(theline) && (trypos = find_line_comment()) != NULL) { /* XXX */ /* find how indented the line beginning the comment is */ getvcol(curwin, trypos, &col, NULL, NULL); amount = col; + goto theend; } /* * If we're inside a comment and not looking at the start of the * comment, try using the 'comments' option. */ - else if (!cin_iscomment(theline) - && (trypos = ind_find_start_comment()) != NULL) { - /* XXX */ + if (!cin_iscomment(theline) && comment_pos != NULL) { /* XXX */ int lead_start_len = 2; int lead_middle_len = 1; char_u lead_start[COM_MAX_LEN]; /* start-comment string */ @@ -1657,7 +1788,7 @@ int get_c_indent(void) int done = FALSE; /* find how indented the line beginning the comment is */ - getvcol(curwin, trypos, &col, NULL, NULL); + getvcol(curwin, comment_pos, &col, NULL, NULL); amount = col; *lead_start = NUL; *lead_middle = NUL; @@ -1709,12 +1840,12 @@ int get_c_indent(void) lead_middle_len) == 0) { amount = get_indent_lnum(curwin->w_cursor.lnum - 1); break; - } - /* If the start comment string doesn't match with the - * start of the comment, skip this entry. XXX */ - else if (STRNCMP(ml_get(trypos->lnum) + trypos->col, - lead_start, lead_start_len) != 0) + } else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col, + lead_start, lead_start_len) != 0) { + /* If the start comment string doesn't match with the + * start of the comment, skip this entry. XXX */ continue; + } } if (start_off != 0) amount += start_off; @@ -1758,7 +1889,7 @@ int get_c_indent(void) * otherwise, add the amount specified by "c" in 'cino' */ amount = -1; - for (lnum = cur_curpos.lnum - 1; lnum > trypos->lnum; --lnum) { + for (lnum = cur_curpos.lnum - 1; lnum > comment_pos->lnum; --lnum) { if (linewhite(lnum)) /* skip blank lines */ continue; amount = get_indent_lnum(lnum); /* XXX */ @@ -1766,28 +1897,30 @@ int get_c_indent(void) } if (amount == -1) { /* use the comment opener */ if (!curbuf->b_ind_in_comment2) { - start = ml_get(trypos->lnum); - look = start + trypos->col + 2; /* skip / and * */ + start = ml_get(comment_pos->lnum); + look = start + comment_pos->col + 2; /* skip / and * */ if (*look != NUL) /* if something after it */ - trypos->col = (colnr_T)(skipwhite(look) - start); + comment_pos->col = (colnr_T)(skipwhite(look) - start); } - getvcol(curwin, trypos, &col, NULL, NULL); + getvcol(curwin, comment_pos, &col, NULL, NULL); amount = col; if (curbuf->b_ind_in_comment2 || *look == NUL) amount += curbuf->b_ind_in_comment; } } + goto theend; } // Are we looking at a ']' that has a match? - else if (*skipwhite(theline) == ']' + if (*skipwhite(theline) == ']' && (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL) { // align with the line containing the '['. amount = get_indent_lnum(trypos->lnum); + goto theend; } /* * Are we inside parentheses or braces? */ /* XXX */ - else if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL + if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL && curbuf->b_ind_java == 0) || (tryposBrace = find_start_brace()) != NULL || trypos != NULL) { @@ -1821,8 +1954,8 @@ int get_c_indent(void) continue; /* ignore #define, #if, etc. */ curwin->w_cursor.lnum = lnum; - /* Skip a comment. XXX */ - if ((trypos = ind_find_start_comment()) != NULL) { + /* Skip a comment or raw string. XXX */ + if ((trypos = ind_find_start_CORS()) != NULL) { lnum = trypos->lnum + 1; continue; } @@ -2023,8 +2156,8 @@ int get_c_indent(void) // stored in tryposBrace. // Make a copy of tryposBrace, it may point to pos_copy inside // find_start_brace(), which may be changed somewhere. - tryposBraceCopy = *tryposBrace; - tryposBrace = &tryposBraceCopy; + tryposCopy = *tryposBrace; + tryposBrace = &tryposCopy; trypos = tryposBrace; ourscope = trypos->lnum; start = ml_get(ourscope); @@ -2201,10 +2334,10 @@ int get_c_indent(void) l = get_cursor_line_ptr(); /* - * If we're in a comment now, skip to the start of the - * comment. + * If we're in a comment or raw string now, skip to + * the start of it. */ - trypos = ind_find_start_comment(); + trypos = ind_find_start_CORS(); if (trypos != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; @@ -2286,7 +2419,8 @@ int get_c_indent(void) amount += ind_continuation; } else { if (lookfor != LOOKFOR_TERM - && lookfor != LOOKFOR_CPP_BASECLASS) { + && lookfor != LOOKFOR_CPP_BASECLASS + && lookfor != LOOKFOR_COMMA) { amount = scope_amount; if (theline[0] == '{') { amount += curbuf->b_ind_open_extra; @@ -2309,9 +2443,9 @@ int get_c_indent(void) l = get_cursor_line_ptr(); - /* If we're in a comment now, skip to the start of - * the comment. */ - trypos = ind_find_start_comment(); + /* If we're in a comment or raw string now, skip + * to the start of it. */ + trypos = ind_find_start_CORS(); if (trypos != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; @@ -2337,9 +2471,10 @@ int get_c_indent(void) } /* - * If we're in a comment now, skip to the start of the comment. + * If we're in a comment or raw string now, skip to the start + * of it. */ /* XXX */ - if ((trypos = ind_find_start_comment()) != NULL) { + if ((trypos = ind_find_start_CORS()) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; @@ -2492,7 +2627,7 @@ int get_c_indent(void) */ /* XXX */ n = FALSE; if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) { - n = cin_is_cpp_baseclass(&col); + n = cin_is_cpp_baseclass(&cache_cpp_baseclass); l = get_cursor_line_ptr(); } if (n) { @@ -2508,7 +2643,7 @@ int get_c_indent(void) continue; } else /* XXX */ - amount = get_baseclass_amount(col); + amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col); break; } else if (lookfor == LOOKFOR_CPP_BASECLASS) { /* only look, whether there is a cpp base class @@ -2550,23 +2685,31 @@ int get_c_indent(void) amount = get_indent(); break; } - if (lookfor == LOOKFOR_NO_COMMA) { - if (terminated != ',') { - // Line below current line is the one that starts a - // (possibly broken) line ending in a comma. + if (lookfor == LOOKFOR_COMMA) { + if (tryposBrace != NULL && tryposBrace->lnum + >= curwin->w_cursor.lnum) { break; } - amount = get_indent(); - if (curwin->w_cursor.lnum - 1 == ourscope) { - // line above is start of the scope, thus current line - // is the one that stars a (possibly broken) line - // ending in a comma. + if (terminated == ',') { + // Line below current line is the one that starts a + // (possibly broken) line ending in a comma. break; + } else { + amount = get_indent(); + if (curwin->w_cursor.lnum - 1 == ourscope) { + // line above is start of the scope, thus current + // line is the one that stars a (possibly broken) + // line ending in a comma. + break; + } } } if (terminated == 0 || (lookfor != LOOKFOR_UNTERM && terminated == ',')) { + if (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[') { + amount += ind_continuation; + } // If we're in the middle of a paren thing, Go back to the line // that starts it so we can get the right prevailing indent // if ( foo && @@ -2783,7 +2926,11 @@ int get_c_indent(void) * 100 + * -> here; */ + l = get_cursor_line_ptr(); amount = cur_amount; + if (*skipwhite(l) == ']' || l[STRLEN(l) - 1] == ']') { + break; + } /* * If previous line ends in ',', check whether we @@ -2809,8 +2956,10 @@ int get_c_indent(void) // 4 * // 5, // 6, - lookfor = LOOKFOR_NO_COMMA; - amount = get_indent(); // XXX + if (cin_iscomment(skipwhite(l))) { + break; + } + lookfor = LOOKFOR_COMMA; trypos = find_match_char('[', curbuf->b_ind_maxparen); if (trypos != NULL) { if (trypos->lnum == curwin->w_cursor.lnum - 1) { @@ -2831,7 +2980,9 @@ int get_c_indent(void) // XXX cont_amount = cin_get_equal_amount( curwin->w_cursor.lnum); } - if (lookfor != LOOKFOR_TERM && lookfor != LOOKFOR_JS_KEY) { + if (lookfor != LOOKFOR_TERM + && lookfor != LOOKFOR_JS_KEY + && lookfor != LOOKFOR_COMMA) { lookfor = LOOKFOR_UNTERM; } } @@ -3038,252 +3189,257 @@ term_again: /* subtract extra left-shift for jump labels */ if (curbuf->b_ind_jump_label > 0 && original_line_islabel) amount -= curbuf->b_ind_jump_label; + + goto theend; } - else { - // Ok -- we're not inside any sort of structure at all! - // - // this means we're at the top level, and everything should - // basically just match where the previous line is, except - // for the lines immediately following a function declaration, - // which are K&R-style parameters and need to be indented. - - // if our line starts with an open brace, forget about any - // prevailing indent and make sure it looks like the start - // of a function - if (theline[0] == '{') { - amount = curbuf->b_ind_first_open; - } - /* - * If the NEXT line is a function declaration, the current - * line needs to be indented as a function type spec. - * Don't do this if the current line looks like a comment or if the - * current line is terminated, ie. ends in ';', or if the current line - * contains { or }: "void f() {\n if (1)" - */ - else if (cur_curpos.lnum < curbuf->b_ml.ml_line_count - && !cin_nocode(theline) - && vim_strchr(theline, '{') == NULL - && vim_strchr(theline, '}') == NULL - && !cin_ends_in(theline, (char_u *)":", NULL) - && !cin_ends_in(theline, (char_u *)",", NULL) - && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, - cur_curpos.lnum + 1) - && !cin_isterminated(theline, FALSE, TRUE)) { - amount = curbuf->b_ind_func_type; - } else { - amount = 0; - curwin->w_cursor = cur_curpos; - /* search backwards until we find something we recognize */ + // Ok -- we're not inside any sort of structure at all! + // + // this means we're at the top level, and everything should + // basically just match where the previous line is, except + // for the lines immediately following a function declaration, + // which are K&R-style parameters and need to be indented. - while (curwin->w_cursor.lnum > 1) { - curwin->w_cursor.lnum--; - curwin->w_cursor.col = 0; + // if our line starts with an open brace, forget about any + // prevailing indent and make sure it looks like the start + // of a function - l = get_cursor_line_ptr(); + if (theline[0] == '{') { + amount = curbuf->b_ind_first_open; + goto theend; + } + /* + * If the NEXT line is a function declaration, the current + * line needs to be indented as a function type spec. + * Don't do this if the current line looks like a comment or if the + * current line is terminated, ie. ends in ';', or if the current line + * contains { or }: "void f() {\n if (1)" + */ + if (cur_curpos.lnum < curbuf->b_ml.ml_line_count + && !cin_nocode(theline) + && vim_strchr(theline, '{') == NULL + && vim_strchr(theline, '}') == NULL + && !cin_ends_in(theline, (char_u *)":", NULL) + && !cin_ends_in(theline, (char_u *)",", NULL) + && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, + cur_curpos.lnum + 1) + && !cin_isterminated(theline, false, true)) { + amount = curbuf->b_ind_func_type; + goto theend; + } - /* - * If we're in a comment now, skip to the start of the comment. - */ /* XXX */ - if ((trypos = ind_find_start_comment()) != NULL) { - curwin->w_cursor.lnum = trypos->lnum + 1; - curwin->w_cursor.col = 0; - continue; - } + /* search backwards until we find something we recognize */ + amount = 0; + curwin->w_cursor = cur_curpos; + while (curwin->w_cursor.lnum > 1) { + curwin->w_cursor.lnum--; + curwin->w_cursor.col = 0; - /* - * Are we at the start of a cpp base class declaration or - * constructor initialization? - */ /* XXX */ - n = FALSE; - if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { - n = cin_is_cpp_baseclass(&col); - l = get_cursor_line_ptr(); - } - if (n) { - /* XXX */ - amount = get_baseclass_amount(col); - break; - } + l = get_cursor_line_ptr(); - /* - * Skip preprocessor directives and blank lines. - */ - if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) - continue; + /* + * If we're in a comment or raw string now, skip to the start + * of it. + */ /* XXX */ + if ((trypos = ind_find_start_CORS()) != NULL) { + curwin->w_cursor.lnum = trypos->lnum + 1; + curwin->w_cursor.col = 0; + continue; + } - if (cin_nocode(l)) - continue; + /* + * Are we at the start of a cpp base class declaration or + * constructor initialization? + */ /* XXX */ + n = false; + if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { + n = cin_is_cpp_baseclass(&cache_cpp_baseclass); + l = get_cursor_line_ptr(); + } + if (n) { + /* XXX */ + amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col); + break; + } - /* - * If the previous line ends in ',', use one level of - * indentation: - * int foo, - * bar; - * do this before checking for '}' in case of eg. - * enum foobar - * { - * ... - * } foo, - * bar; - */ - n = 0; - if (cin_ends_in(l, (char_u *)",", NULL) - || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) { - /* take us back to opening paren */ - if (find_last_paren(l, '(', ')') - && (trypos = find_match_paren( - curbuf->b_ind_maxparen)) != NULL) - curwin->w_cursor = *trypos; - - /* For a line ending in ',' that is a continuation line go - * back to the first line with a backslash: - * char *foo = "bla\ - * bla", - * here; - */ - while (n == 0 && curwin->w_cursor.lnum > 1) { - l = ml_get(curwin->w_cursor.lnum - 1); - if (*l == NUL || l[STRLEN(l) - 1] != '\\') - break; - --curwin->w_cursor.lnum; - curwin->w_cursor.col = 0; - } + /* + * Skip preprocessor directives and blank lines. + */ + if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) + continue; - amount = get_indent(); /* XXX */ + if (cin_nocode(l)) + continue; - if (amount == 0) - amount = cin_first_id_amount(); - if (amount == 0) - amount = ind_continuation; + /* + * If the previous line ends in ',', use one level of + * indentation: + * int foo, + * bar; + * do this before checking for '}' in case of eg. + * enum foobar + * { + * ... + * } foo, + * bar; + */ + n = 0; + if (cin_ends_in(l, (char_u *)",", NULL) + || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) { + /* take us back to opening paren */ + if (find_last_paren(l, '(', ')') + && (trypos = find_match_paren( + curbuf->b_ind_maxparen)) != NULL) + curwin->w_cursor = *trypos; + + /* For a line ending in ',' that is a continuation line go + * back to the first line with a backslash: + * char *foo = "bla\ + * bla", + * here; + */ + while (n == 0 && curwin->w_cursor.lnum > 1) { + l = ml_get(curwin->w_cursor.lnum - 1); + if (*l == NUL || l[STRLEN(l) - 1] != '\\') break; - } + --curwin->w_cursor.lnum; + curwin->w_cursor.col = 0; + } - /* - * If the line looks like a function declaration, and we're - * not in a comment, put it the left margin. - */ - if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */ - break; - l = get_cursor_line_ptr(); + amount = get_indent(); /* XXX */ - /* - * Finding the closing '}' of a previous function. Put - * current line at the left margin. For when 'cino' has "fs". - */ - if (*skipwhite(l) == '}') - break; + if (amount == 0) + amount = cin_first_id_amount(); + if (amount == 0) + amount = ind_continuation; + break; + } - /* (matching {) - * If the previous line ends on '};' (maybe followed by - * comments) align at column 0. For example: - * char *string_array[] = { "foo", - * / * x * / "b};ar" }; / * foobar * / - */ - if (cin_ends_in(l, (char_u *)"};", NULL)) - break; + /* + * If the line looks like a function declaration, and we're + * not in a comment, put it the left margin. + */ + if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */ + break; + l = get_cursor_line_ptr(); - // If the previous line ends on '[' we are probably in an - // array constant: - // something = [ - // 234, <- extra indent - if (cin_ends_in(l, (char_u *)"[", NULL)) { - amount = get_indent() + ind_continuation; - break; - } + /* + * Finding the closing '}' of a previous function. Put + * current line at the left margin. For when 'cino' has "fs". + */ + if (*skipwhite(l) == '}') + break; - /* - * Find a line only has a semicolon that belongs to a previous - * line ending in '}', e.g. before an #endif. Don't increase - * indent then. - */ - if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) { - pos_T curpos_save = curwin->w_cursor; + /* (matching {) + * If the previous line ends on '};' (maybe followed by + * comments) align at column 0. For example: + * char *string_array[] = { "foo", + * / * x * / "b};ar" }; / * foobar * / + */ + if (cin_ends_in(l, (char_u *)"};", NULL)) + break; - while (curwin->w_cursor.lnum > 1) { - look = ml_get(--curwin->w_cursor.lnum); - if (!(cin_nocode(look) || cin_ispreproc_cont( - &look, &curwin->w_cursor.lnum))) - break; - } - if (curwin->w_cursor.lnum > 0 - && cin_ends_in(look, (char_u *)"}", NULL)) - break; + // If the previous line ends on '[' we are probably in an + // array constant: + // something = [ + // 234, <- extra indent + if (cin_ends_in(l, (char_u *)"[", NULL)) { + amount = get_indent() + ind_continuation; + break; + } - curwin->w_cursor = curpos_save; - } + /* + * Find a line only has a semicolon that belongs to a previous + * line ending in '}', e.g. before an #endif. Don't increase + * indent then. + */ + if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) { + pos_T curpos_save = curwin->w_cursor; - /* - * If the PREVIOUS line is a function declaration, the current - * line (and the ones that follow) needs to be indented as - * parameters. - */ - if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { - amount = curbuf->b_ind_param; + while (curwin->w_cursor.lnum > 1) { + look = ml_get(--curwin->w_cursor.lnum); + if (!(cin_nocode(look) || cin_ispreproc_cont( + &look, &curwin->w_cursor.lnum))) break; - } + } + if (curwin->w_cursor.lnum > 0 + && cin_ends_in(look, (char_u *)"}", NULL)) + break; - /* - * If the previous line ends in ';' and the line before the - * previous line ends in ',' or '\', ident to column zero: - * int foo, - * bar; - * indent_to_0 here; - */ - if (cin_ends_in(l, (char_u *)";", NULL)) { - l = ml_get(curwin->w_cursor.lnum - 1); - if (cin_ends_in(l, (char_u *)",", NULL) - || (*l != NUL && l[STRLEN(l) - 1] == '\\')) - break; - l = get_cursor_line_ptr(); - } + curwin->w_cursor = curpos_save; + } - /* - * Doesn't look like anything interesting -- so just - * use the indent of this line. - * - * Position the cursor over the rightmost paren, so that - * matching it will take us back to the start of the line. - */ - find_last_paren(l, '(', ')'); + /* + * If the PREVIOUS line is a function declaration, the current + * line (and the ones that follow) needs to be indented as + * parameters. + */ + if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { + amount = curbuf->b_ind_param; + break; + } - if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) - curwin->w_cursor = *trypos; - amount = get_indent(); /* XXX */ + /* + * If the previous line ends in ';' and the line before the + * previous line ends in ',' or '\', ident to column zero: + * int foo, + * bar; + * indent_to_0 here; + */ + if (cin_ends_in(l, (char_u *)";", NULL)) { + l = ml_get(curwin->w_cursor.lnum - 1); + if (cin_ends_in(l, (char_u *)",", NULL) + || (*l != NUL && l[STRLEN(l) - 1] == '\\')) break; - } + l = get_cursor_line_ptr(); + } - /* add extra indent for a comment */ - if (cin_iscomment(theline)) - amount += curbuf->b_ind_comment; + /* + * Doesn't look like anything interesting -- so just + * use the indent of this line. + * + * Position the cursor over the rightmost paren, so that + * matching it will take us back to the start of the line. + */ + find_last_paren(l, '(', ')'); - /* add extra indent if the previous line ended in a backslash: - * "asdfasdf\ - * here"; - * char *foo = "asdf\ - * here"; - */ - if (cur_curpos.lnum > 1) { - l = ml_get(cur_curpos.lnum - 1); - if (*l != NUL && l[STRLEN(l) - 1] == '\\') { - cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1); - if (cur_amount > 0) - amount = cur_amount; - else if (cur_amount == 0) - amount += ind_continuation; - } - } + if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) + curwin->w_cursor = *trypos; + amount = get_indent(); /* XXX */ + break; + } + + /* add extra indent for a comment */ + if (cin_iscomment(theline)) + amount += curbuf->b_ind_comment; + + /* add extra indent if the previous line ended in a backslash: + * "asdfasdf\ + * here"; + * char *foo = "asdf\ + * here"; + */ + if (cur_curpos.lnum > 1) { + l = ml_get(cur_curpos.lnum - 1); + if (*l != NUL && l[STRLEN(l) - 1] == '\\') { + cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1); + if (cur_amount > 0) + amount = cur_amount; + else if (cur_amount == 0) + amount += ind_continuation; } } theend: + if (amount < 0) + amount = 0; + +laterend: /* put the cursor back where it belongs */ curwin->w_cursor = cur_curpos; xfree(linecopy); - if (amount < 0) - return 0; return amount; } diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 0ba8dd98d0..c91a25df6e 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3954,8 +3954,10 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp) if (ffdos) size += lnum - 1; - /* Don't count the last line break if 'bin' and 'noeol'. */ - if (buf->b_p_bin && !buf->b_p_eol && buf->b_ml.ml_line_count == lnum) { + /* Don't count the last line break if 'noeol' and ('bin' or + * 'nofixeol'). */ + if ((!buf->b_p_fixeol || buf->b_p_bin) && !buf->b_p_eol + && buf->b_ml.ml_line_count == lnum) { size -= ffdos + 1; } } diff --git a/src/nvim/memline_defs.h b/src/nvim/memline_defs.h index bcc1c673d2..34a002af5d 100644 --- a/src/nvim/memline_defs.h +++ b/src/nvim/memline_defs.h @@ -41,7 +41,7 @@ typedef struct memline { int ml_flags; infoptr_T *ml_stack; /* stack of pointer blocks (array of IPTRs) */ - int ml_stack_top; /* current top if ml_stack */ + int ml_stack_top; /* current top of ml_stack */ int ml_stack_size; /* total number of entries in ml_stack */ linenr_T ml_line_lnum; /* line number of cached line, 0 if not valid */ diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ad53e9bf24..a2e473fcb8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7466,6 +7466,13 @@ static void nv_object(cmdarg_T *cap) flag = current_block(cap->oap, cap->count1, include, '<', '>'); break; case 't': /* "at" = a tag block (xml and html) */ + // Do not adjust oap->end in do_pending_operator() + // otherwise there are different results for 'dit' + // (note leading whitespace in last line): + // 1) <b> 2) <b> + // foobar foobar + // </b> </b> + cap->retval |= CA_NO_ADJ_OP_END; flag = current_tagblock(cap->oap, cap->count1, include); break; case 'p': /* "ap" = a paragraph */ diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 956b9c7758..52b4fed9d7 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -554,7 +554,7 @@ void op_reindent(oparg_T *oap, Indenter how) { long i; char_u *l; - int count; + int amount; linenr_T first_changed = 0; linenr_T last_changed = 0; linenr_T start_lnum = curwin->w_cursor.lnum; @@ -582,11 +582,11 @@ void op_reindent(oparg_T *oap, Indenter how) || how != get_lisp_indent) { l = skipwhite(get_cursor_line_ptr()); if (*l == NUL) /* empty or blank line */ - count = 0; + amount = 0; else - count = how(); /* get the indent for this line */ + amount = how(); /* get the indent for this line */ - if (set_indent(count, SIN_UNDO)) { + if (amount >= 0 && set_indent(amount, SIN_UNDO)) { /* did change the indent, call changed_lines() later */ if (first_changed == 0) first_changed = curwin->w_cursor.lnum; @@ -4964,7 +4964,7 @@ void cursor_pos_info(void) &char_count_cursor, len, eol_size); if (lnum == curbuf->b_ml.ml_line_count && !curbuf->b_p_eol - && curbuf->b_p_bin + && (curbuf->b_p_bin || !curbuf->b_p_fixeol) && (long)STRLEN(s) < len) byte_count_cursor -= eol_size; } @@ -4985,7 +4985,7 @@ void cursor_pos_info(void) } /* Correction for when last line doesn't have an EOL. */ - if (!curbuf->b_p_eol && curbuf->b_p_bin) + if (!curbuf->b_p_eol && (curbuf->b_p_bin || !curbuf->b_p_fixeol)) byte_count -= eol_size; if (l_VIsual_active) { diff --git a/src/nvim/option.c b/src/nvim/option.c index dbcd230186..486f2083a6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -122,6 +122,7 @@ static char_u *p_cpt; static char_u *p_cfu; static char_u *p_ofu; static int p_eol; +static int p_fixeol; static int p_et; static char_u *p_fenc; static char_u *p_ff; @@ -1018,12 +1019,9 @@ void set_init_2(void) */ void set_init_3(void) { -#if defined(UNIX) || defined(WIN3264) - /* - * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. - * This is done after other initializations, where 'shell' might have been - * set, but only if they have not been set before. - */ + // Set 'shellpipe' and 'shellredir', depending on the 'shell' option. + // This is done after other initializations, where 'shell' might have been + // set, but only if they have not been set before. int idx_srr; int do_srr; int idx_sp; @@ -1080,8 +1078,6 @@ void set_init_3(void) } xfree(p); } -#endif - set_title_defaults(); } @@ -3592,6 +3588,9 @@ set_bool_option ( /* when 'endofline' is changed, redraw the window title */ else if ((int *)varp == &curbuf->b_p_eol) { redraw_titles(); + } else if ((int *)varp == &curbuf->b_p_fixeol) { + // when 'fixeol' is changed, redraw the window title + redraw_titles(); } /* when 'bomb' is changed, redraw the window title and tab page text */ else if ((int *)varp == &curbuf->b_p_bomb) { @@ -5304,6 +5303,7 @@ static char_u *get_varp(vimoption_T *p) case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); case PV_EOL: return (char_u *)&(curbuf->b_p_eol); + case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); case PV_ET: return (char_u *)&(curbuf->b_p_et); case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); case PV_FF: return (char_u *)&(curbuf->b_p_ff); @@ -5548,6 +5548,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_bin = p_bin; buf->b_p_bomb = p_bomb; buf->b_p_et = p_et; + buf->b_p_fixeol = p_fixeol; buf->b_p_et_nobin = p_et_nobin; buf->b_p_ml = p_ml; buf->b_p_ml_nobin = p_ml_nobin; @@ -6483,6 +6484,7 @@ void save_file_ff(buf_T *buf) * from when editing started (save_file_ff() called). * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was * changed and 'binary' is not set. + * Also when 'endofline' was changed and 'fixeol' is not set. * When "ignore_empty" is true don't consider a new, empty buffer to be * changed. */ @@ -6497,9 +6499,9 @@ bool file_ff_differs(buf_T *buf, bool ignore_empty) && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) return FALSE; if (buf->b_start_ffc != *buf->b_p_ff) - return TRUE; - if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol) - return TRUE; + return true; + if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol) + return true; if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) return TRUE; if (buf->b_start_fenc == NULL) diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index d4d3410d5c..c72e1cf0bb 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -665,6 +665,7 @@ enum { , BV_DEF , BV_INC , BV_EOL + , BV_FIXEOL , BV_EP , BV_ET , BV_FENC diff --git a/src/nvim/options.lua b/src/nvim/options.lua index b22e994efe..5187340629 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -799,6 +799,14 @@ return { defaults={if_true={vi="vert:|,fold:-"}} }, { + full_name='fixendofline', abbreviation='fixeol', + type='bool', scope={'buffer'}, + vi_def=true, + redraw={'statuslines'}, + varname='p_fixeol', + defaults={if_true={vi=true}} + }, + { full_name='fkmap', abbreviation='fk', type='bool', scope={'global'}, vi_def=true, diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 0e052ced55..a791dca39c 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -46,7 +46,19 @@ bool os_env_exists(const char *name) int os_setenv(const char *name, const char *value, int overwrite) FUNC_ATTR_NONNULL_ALL { +#ifdef HAVE_SETENV return setenv(name, value, overwrite); +#elif defined(HAVE_PUTENV_S) + if (!overwrite && os_getenv(name) != NULL) { + return 0; + } + if (_putenv_s(name, value) == 0) { + return 0; + } + return -1; +#else +# error "This system has no implementation available for os_setenv()" +#endif } /// Unset environment variable diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 57e25560de..3813c45726 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -418,7 +418,8 @@ static void read_input(DynamicBuffer *buf) // Finished a line, add a NL, unless this line should not have one. // FIXME need to make this more readable if (lnum != curbuf->b_op_end.lnum - || !curbuf->b_p_bin + || (!curbuf->b_p_bin + && curbuf->b_p_fixeol) || (lnum != curbuf->b_no_eol_lnum && (lnum != curbuf->b_ml.ml_line_count diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 32960dfbe9..aad9672ba7 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -2,10 +2,13 @@ #define NVIM_OS_WIN_DEFS_H #include <windows.h> +#include <sys/stat.h> #define TEMP_DIR_NAMES {"$TMP", "$TEMP", "$USERPROFILE", ""} #define TEMP_FILE_PATH_MAXLEN _MAX_PATH +#define FNAME_ILLEGAL "\"*?><|" + #define USE_CRNL #ifdef _MSC_VER @@ -15,6 +18,9 @@ # ifndef restrict # define restrict __restrict # endif +# ifndef S_IXUSR +# define S_IXUSR S_IEXEC +# endif #endif #ifdef _MSC_VER diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 7fe61c45bc..729697eee3 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -25,9 +25,8 @@ msgstr "" "Content-Transfer-Encoding: 8-bit\n" #: ../api/private/helpers.c:201 -#, fuzzy msgid "Unable to get option value" -msgstr "impossibile ottenere il valore di opzione" +msgstr "Impossibile ottenere il valore di opzione" #: ../api/private/helpers.c:204 msgid "internal error: unknown option type" @@ -827,18 +826,16 @@ msgid "sort() argument" msgstr "argomento di sort()" #: ../eval.c:13721 -#, fuzzy msgid "uniq() argument" -msgstr "argomento di add()" +msgstr "argomento di uniq()" #: ../eval.c:13776 msgid "E702: Sort compare function failed" msgstr "E702: Funzione confronto nel sort non riuscita" #: ../eval.c:13806 -#, fuzzy msgid "E882: Uniq compare function failed" -msgstr "E702: Funzione confronto nel sort non riuscita" +msgstr "E882: Funzione di comparazione 'uniq' fallita" #: ../eval.c:14085 msgid "(Invalid)" @@ -963,16 +960,12 @@ msgid "E129: Function name required" msgstr "E129: Nome funzione necessario" #: ../eval.c:17824 -#, fuzzy, c-format msgid "E128: Function name must start with a capital or \"s:\": %s" -msgstr "" -"E128: Il nome funzione deve iniziare con una maiuscola o contenere ':': %s" +msgstr "E128: Il nome funzione deve iniziare con una maiuscola o \"s:\": %s" #: ../eval.c:17833 -#, fuzzy, c-format msgid "E884: Function name cannot contain a colon: %s" -msgstr "" -"E128: Il nome funzione deve iniziare con una maiuscola o contenere ':': %s" +msgstr "E884: Il nome funzione non può contenere una virgola: %s" #: ../eval.c:18336 #, c-format @@ -2667,18 +2660,17 @@ msgid "E17: \"%s\" is a directory" msgstr "E17: \"%s\" è una directory" #: ../globals.h:1020 -#, fuzzy msgid "E900: Invalid job id" -msgstr "E49: Quantità di 'scroll' non valida" +msgstr "E900: 'Job id' non valido" #: ../globals.h:1021 msgid "E901: Job table is full" -msgstr "" +msgstr "E901: Job table piena" #: ../globals.h:1022 #, c-format msgid "E902: \"%s\" is not an executable" -msgstr "" +msgstr "E902: \"%s\" non è un esegubile" #: ../globals.h:1024 #, c-format @@ -2703,7 +2695,7 @@ msgstr "E22: Script troppo nidificati" #: ../globals.h:1031 msgid "E23: No alternate file" -msgstr "E23: Nessun file alternato" +msgstr "E23: Nessun file alternativo" #: ../globals.h:1032 msgid "E24: No such abbreviation" @@ -2791,9 +2783,8 @@ msgid "E37: No write since last change (add ! to override)" msgstr "E37: Non salvato dopo modifica (aggiungi ! per eseguire comunque)" #: ../globals.h:1055 -#, fuzzy msgid "E37: No write since last change" -msgstr "[Non salvato dopo l'ultima modifica]\n" +msgstr "E37: Non salvato dall'ultima modifica" #: ../globals.h:1056 msgid "E38: Null argument" @@ -2857,8 +2848,7 @@ msgstr "E46: Non posso cambiare la variabile read-only \"%s\"" #: ../globals.h:1075 #, c-format msgid "E794: Cannot set variable in the sandbox: \"%s\"" -msgstr "" -"E794: Non posso impostare la variabile read-only in ambiente protetto: \"%s\"" +msgstr "E794: Non posso impostare la variabile read-only in ambiente protetto: \"%s\"" #: ../globals.h:1076 msgid "E47: Error while reading errorfile" @@ -4869,9 +4859,8 @@ msgid "E777: String or List expected" msgstr "E777: aspettavo Stringa o Lista" #: ../regexp.c:359 -#, fuzzy, c-format msgid "E369: invalid item in %s%%[]" -msgstr "E239: Testo 'sign' non valido: %s" +msgstr "E369: elemento non valido in %s%%[]" #: ../regexp.c:374 #, c-format @@ -5004,7 +4993,7 @@ msgstr "E866: (NFA regexp) %c fuori posto" #: ../regexp_nfa.c:242 #, c-format msgid "E877: (NFA regexp) Invalid character class: %<PRId64>" -msgstr "" +msgstr "E877: (NFA regexp) Classe di caratteri non valida: %<PRId64>" #: ../regexp_nfa.c:1261 #, c-format @@ -5611,14 +5600,12 @@ msgid "E765: 'spellfile' does not have %<PRId64> entries" msgstr "E765: 'spellfile' non ha %<PRId64> elementi" #: ../spell.c:8074 -#, fuzzy, c-format msgid "Word '%.*s' removed from %s" -msgstr "Parola rimossa da %s" +msgstr "Parola '%.*s' rimossa da %s" #: ../spell.c:8117 -#, fuzzy, c-format msgid "Word '%.*s' added to %s" -msgstr "Parola aggiunta a %s" +msgstr "Parola '%.*s' aggiunta a %s" #: ../spell.c:8381 msgid "E763: Word characters differ between spell files" @@ -6100,9 +6087,8 @@ msgstr "Vim: Errore leggendo l'input, esco...\n" #. This happens when the FileChangedRO autocommand changes the #. * file in a way it becomes shorter. #: ../undo.c:379 -#, fuzzy msgid "E881: Line count changed unexpectedly" -msgstr "E834: Il conteggio delle righe è inaspettatamente cambiato" +msgstr "E881: Il conteggio delle righe è inaspettatamente cambiato" #: ../undo.c:627 #, c-format diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 9fdb476748..c4264cbcee 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2934,14 +2934,16 @@ win_line ( } } - /* Decide which of the highlight attributes to use. */ - attr_pri = TRUE; - if (area_attr != 0) - char_attr = area_attr; - else if (search_attr != 0) - char_attr = search_attr; - /* Use line_attr when not in the Visual or 'incsearch' area - * (area_attr may be 0 when "noinvcur" is set). */ + // Decide which of the highlight attributes to use. + attr_pri = true; + + if (area_attr != 0) { + char_attr = hl_combine_attr(line_attr, area_attr); + } else if (search_attr != 0) { + char_attr = hl_combine_attr(line_attr, search_attr); + } + // Use line_attr when not in the Visual or 'incsearch' area + // (area_attr may be 0 when "noinvcur" is set). else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL) || vcol < fromcol || vcol_prev < fromcol_prev || vcol >= tocol)) @@ -3323,16 +3325,15 @@ win_line ( * Found last space before word: check for line break. */ if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)) { - char_u *p = ptr - ( - has_mbyte ? mb_l : - 1); + int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0; + char_u *p = ptr - (mb_off + 1); // TODO: is passing p for start of the line OK? n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1; if (c == TAB && n_extra + col > wp->w_width) { n_extra = (int)wp->w_buffer->b_p_ts - vcol % (int)wp->w_buffer->b_p_ts - 1; } - c_extra = ' '; + c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' '; if (ascii_iswhite(c)) { if (c == TAB) /* See "Tab alignment" below. */ diff --git a/src/nvim/search.c b/src/nvim/search.c index cb461c9ef2..18a72524cb 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -918,7 +918,7 @@ static int first_submatch(regmmatch_T *rp) * Careful: If spats[0].off.line == TRUE and spats[0].off.off == 0 this * makes the movement linewise without moving the match position. * - * return 0 for failure, 1 for found, 2 for found and line offset added + * Return 0 for failure, 1 for found, 2 for found and line offset added. */ int do_search( oparg_T *oap, /* can be NULL */ @@ -1443,19 +1443,64 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) } /* + * Raw string start is found at linep[startpos.col - 1]. + * Return true if the matching end can be found between startpos and endpos. + */ +static int find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos) +{ + char_u *p; + char_u *delim_copy; + size_t delim_len; + linenr_T lnum; + int found = false; + + for (p = linep + startpos->col + 1; *p && *p != '('; ++p) {} + + delim_len = (p - linep) - startpos->col - 1; + delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len); + if (delim_copy == NULL) + return false; + for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum) + { + char_u *line = ml_get(lnum); + + for (p = line + (lnum == startpos->lnum + ? startpos->col + 1 : 0); *p; ++p) + { + if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) + break; + if (*p == ')' && p[delim_len + 1] == '"' + && STRNCMP(delim_copy, p + 1, delim_len) == 0) + { + found = true; + break; + } + } + if (found) + break; + } + xfree(delim_copy); + return found; +} + +/* * findmatchlimit -- find the matching paren or brace, if it exists within - * maxtravel lines of here. A maxtravel of 0 means search until falling off - * the edge of the file. + * maxtravel lines of the cursor. A maxtravel of 0 means search until falling + * off the edge of the file. * * "initc" is the character to find a match for. NUL means to find the - * character at or after the cursor. + * character at or after the cursor. Special values: + * '*' look for C-style comment / * + * '/' look for C-style comment / *, ignoring comment-end + * '#' look for preprocessor directives + * 'R' look for raw string start: R"delim(text)delim" (only backwards) * * flags: FM_BACKWARD search backwards (when initc is '/', '*' or '#') * FM_FORWARD search forwards (when initc is '/', '*' or '#') * FM_BLOCKSTOP stop at start/end of block ({ or } in column 0) * FM_SKIPCOMM skip comments (not implemented yet!) * - * "oap" is only used to set oap->motion_type for a linewise motion, it be + * "oap" is only used to set oap->motion_type for a linewise motion, it can be * NULL */ @@ -1465,8 +1510,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) int findc = 0; /* matching brace */ int c; int count = 0; /* cumulative number of braces */ - int backwards = FALSE; /* init for gcc */ - int inquote = FALSE; /* TRUE when inside quotes */ + int backwards = false; /* init for gcc */ + int raw_string = false; /* search for raw string */ + int inquote = false; /* true when inside quotes */ char_u *linep; /* pointer to current line */ char_u *ptr; int do_quotes; /* check for quotes in current line */ @@ -1506,22 +1552,22 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) * When '/' is used, we ignore running backwards into a star-slash, for * "[*" command, we just want to find any comment. */ - if (initc == '/' || initc == '*') { + if (initc == '/' || initc == '*' || initc == 'R') { comment_dir = dir; if (initc == '/') - ignore_cend = TRUE; - backwards = (dir == FORWARD) ? FALSE : TRUE; + ignore_cend = true; + backwards = (dir == FORWARD) ? false : true; + raw_string = (initc == 'R'); initc = NUL; } else if (initc != '#' && initc != NUL) { find_mps_values(&initc, &findc, &backwards, TRUE); if (findc == NUL) return NULL; - } - /* - * Either initc is '#', or no initc was given and we need to look under the - * cursor. - */ - else { + } else { + /* + * Either initc is '#', or no initc was given and we need to look + * under the cursor. + */ if (initc == '#') { hash_dir = dir; } else { @@ -1766,7 +1812,26 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) */ if (pos.col == 0) continue; - else if ( linep[pos.col - 1] == '/' + else if (raw_string) + { + if (linep[pos.col - 1] == 'R' + && linep[pos.col] == '"' + && vim_strchr(linep + pos.col + 1, '(') != NULL) + { + /* Possible start of raw string. Now that we have the + * delimiter we can check if it ends before where we + * started searching, or before the previously found + * raw string start. */ + if (!find_rawstring_end(linep, &pos, + count > 0 ? &match_pos : &curwin->w_cursor)) + { + count++; + match_pos = pos; + match_pos.col--; + } + linep = ml_get(pos.lnum); /* may have been released */ + } + } else if ( linep[pos.col - 1] == '/' && linep[pos.col] == '*' && (int)pos.col < comment_col) { count++; @@ -3193,6 +3258,7 @@ current_tagblock ( int do_include = include; bool save_p_ws = p_ws; int retval = FAIL; + int is_inclusive = true; p_ws = false; @@ -3287,9 +3353,16 @@ again: if (inc_cursor() < 0) break; } else { - /* Exclude the '<' of the end tag. */ - if (*get_cursor_pos_ptr() == '<') + char_u *c = get_cursor_pos_ptr(); + // Exclude the '<' of the end tag. + // If the closing tag is on new line, do not decrement cursor, but make + // operation exclusive, so that the linefeed will be selected + if (*c == '<' && !VIsual_active && curwin->w_cursor.col == 0) { + // do not decrement cursor + is_inclusive = false; + } else if (*c == '<') { dec_cursor(); + } } end_pos = curwin->w_cursor; @@ -3334,8 +3407,9 @@ again: * on an empty area. */ curwin->w_cursor = start_pos; oap->inclusive = false; - } else - oap->inclusive = true; + } else { + oap->inclusive = is_inclusive; + } } retval = OK; diff --git a/src/nvim/testdir/test53.in b/src/nvim/testdir/test53.in index 8ca9c9ed29..7c35b2e853 100644 --- a/src/nvim/testdir/test53.in +++ b/src/nvim/testdir/test53.in @@ -23,6 +23,7 @@ jfXdit 0fXdit fXdat 0fXdat +dit :" :put =matchstr(\"abcd\", \".\", 0, 2) " b :put =matchstr(\"abcd\", \"..\", 0, 2) " bc @@ -97,6 +98,9 @@ voo "nah" sdf " asdf" sdf " sdf" sd -<b>asdX<i>a<i />sdf</i>asdf</b>- -<b>asdf<i>Xasdf</i>asdf</b>- -<b>asdX<i>as<b />df</i>asdf</b>- +-<b> +innertext object +</b> </begin> SEARCH: foobar diff --git a/src/nvim/testdir/test53.ok b/src/nvim/testdir/test53.ok index 0c0b9ded16..05206972a4 100644 --- a/src/nvim/testdir/test53.ok +++ b/src/nvim/testdir/test53.ok @@ -11,6 +11,7 @@ voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd -<b></b>- -<b>asdfasdf</b>- -- +-<b></b> </begin> b bc diff --git a/src/nvim/version.c b/src/nvim/version.c index 2b0d6f22f2..33c310a8b2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -37,9 +37,6 @@ char *Version = VIM_VERSION_SHORT; char *longVersion = NVIM_VERSION_LONG; char *longVersionWithDate = NVIM_VERSION_LONG \ " (compiled " __DATE__ " " __TIME__ ")"; -#ifdef NVIM_VERSION_COMMIT -char *version_commit = "Commit: " NVIM_VERSION_COMMIT; -#endif char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE; char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS; @@ -98,7 +95,7 @@ static int included_patches[] = { // 901, // 900 NA // 899 NA - // 898, + 898, // 897, // 896, // 895, @@ -193,7 +190,7 @@ static int included_patches[] = { // 806, // 805, // 804, - // 803, + 803, 802, // 801, // 800, @@ -201,7 +198,7 @@ static int included_patches[] = { // 798, // 797, // 796 NA - // 795, + 795, // 794 NA 793, // 792, @@ -211,7 +208,7 @@ static int included_patches[] = { // 788 NA 787, 786, - // 785, + 785, 784, // 783 NA // 782, @@ -273,7 +270,7 @@ static int included_patches[] = { // 726 NA // 725, // 724 NA - // 723, + 723, // 722, // 721, // 720 NA @@ -314,7 +311,7 @@ static int included_patches[] = { // 685, // 684, // 683 NA - // 682, + 682, // 681 NA // 680, // 679 NA @@ -325,23 +322,23 @@ static int included_patches[] = { // 674 NA 673, // 672, - // 671, - // 670, + 671, + 670, // 669 NA 668, 667, // 666 NA - // 665, + 665, // 664 NA // 663 NA // 662, // 661, 660, 659, - // 658, + 658, // 657 NA // 656, - // 655, + 655, // 654, 653, // 652 NA @@ -351,17 +348,17 @@ static int included_patches[] = { // 648 NA // 647 NA 646, - // 645, + 645, // 644 NA // 643, // 642, // 641, - // 640, + 640, // 639, // 638 NA 637, 636, - // 635, + 635, // 634, 633, // 632 NA @@ -1099,9 +1096,6 @@ void list_version(void) // When adding features here, don't forget to update the list of // internal variables in eval.c! MSG(longVersionWithDate); -#ifdef NVIM_VERSION_COMMIT - MSG(version_commit); -#endif MSG(version_buildtype); MSG(version_cflags); diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua index 39de3e8280..19694550f4 100644 --- a/test/functional/legacy/003_cindent_spec.lua +++ b/test/functional/legacy/003_cindent_spec.lua @@ -901,6 +901,23 @@ describe('cindent', function() { 111111111111111111; } + void getstring() { + /* Raw strings */ + const char* s = R"( + test { + # comment + field: 123 + } + )"; + } + void getstring() { + const char* s = R"foo( + test { + # comment + field: 123 + } + )foo"; + } /* end of AUTO */ ]=]) @@ -1790,6 +1807,23 @@ describe('cindent', function() { 111111111111111111; } + void getstring() { + /* Raw strings */ + const char* s = R"( + test { + # comment + field: 123 + } + )"; + } + void getstring() { + const char* s = R"foo( + test { + # comment + field: 123 + } + )foo"; + } /* end of AUTO */ ]=]) @@ -4213,4 +4247,321 @@ describe('cindent', function() JSEND ]=]) end) + + it('javascript indent / vim-patch 7.4.670', function() + insert_([=[ + + JSSTART + // Results of JavaScript indent + // 1 + (function(){ + var a = [ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 2 + (function(){ + var a = [ + 0 + + 5 * + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 3 + (function(){ + var a = [ + 0 + + // comment 1 + 5 * + /* comment 2 */ + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 4 + { + var a = [ + 0, + 1 + ]; + var b; + var c; + } + + // 5 + { + var a = [ + [ + 0 + ], + 2, + 3 + ]; + } + + // 6 + { + var a = [ + [ + 0, + 1 + ], + 2, + 3 + ]; + } + + // 7 + { + var a = [ + // [ + 0, + // 1 + // ], + 2, + 3 + ]; + } + + // 8 + var x = [ + (function(){ + var a, + b, + c, + d, + e, + f, + g, + h, + i; + }) + ]; + + // 9 + var a = [ + 0 + + 5 * + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + + // 10 + var a, + b, + c, + d, + e, + f, + g, + h, + i; + JSEND + ]=]) + + -- :set cino=j1,J1,+2 + execute('set cino=j1,J1,+2') + execute('/^JSSTART') + feed('=/^JSEND<cr>') + + expect([=[ + + JSSTART + // Results of JavaScript indent + // 1 + (function(){ + var a = [ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 2 + (function(){ + var a = [ + 0 + + 5 * + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 3 + (function(){ + var a = [ + 0 + + // comment 1 + 5 * + /* comment 2 */ + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + }()) + + // 4 + { + var a = [ + 0, + 1 + ]; + var b; + var c; + } + + // 5 + { + var a = [ + [ + 0 + ], + 2, + 3 + ]; + } + + // 6 + { + var a = [ + [ + 0, + 1 + ], + 2, + 3 + ]; + } + + // 7 + { + var a = [ + // [ + 0, + // 1 + // ], + 2, + 3 + ]; + } + + // 8 + var x = [ + (function(){ + var a, + b, + c, + d, + e, + f, + g, + h, + i; + }) + ]; + + // 9 + var a = [ + 0 + + 5 * + 9 * + 'a', + 'b', + 0 + + 5 * + 9 * + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i' + ]; + + // 10 + var a, + b, + c, + d, + e, + f, + g, + h, + i; + JSEND + ]=]) + end) end) diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua new file mode 100644 index 0000000000..578178d707 --- /dev/null +++ b/test/functional/legacy/fixeol_spec.lua @@ -0,0 +1,72 @@ +-- Tests for 'fixeol' + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('fixeol', function() + local function rmtestfiles() + os.remove('test.out') + os.remove('XXEol') + os.remove('XXNoEol') + os.remove('XXTestEol') + os.remove('XXTestNoEol') + end + setup(function() + clear() + rmtestfiles() + end) + teardown(function() + rmtestfiles() + end) + + it('is working', function() + -- First write two test files – with and without trailing EOL. + -- Use Unix fileformat for consistency. + execute('set ff=unix') + execute('enew!') + feed('awith eol<esc>:w! XXEol<cr>') + execute('enew!') + execute('set noeol nofixeol') + feed('awithout eol<esc>:w! XXNoEol<cr>') + execute('set eol fixeol') + execute('bwipe XXEol XXNoEol') + + -- Try editing files with 'fixeol' disabled. + execute('e! XXEol') + feed('ostays eol<esc>:set nofixeol<cr>') + execute('w! XXTestEol') + execute('e! XXNoEol') + feed('ostays without<esc>:set nofixeol<cr>') + execute('w! XXTestNoEol') + execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol') + execute('set fixeol') + + -- Append "END" to each file so that we can see what the last written char was. + feed('ggdGaEND<esc>:w >>XXEol<cr>') + execute('w >>XXNoEol') + execute('w >>XXTestEol') + execute('w >>XXTestNoEol') + + -- Concatenate the results. + execute('e! test.out') + feed('a0<esc>:$r XXEol<cr>') + execute('$r XXNoEol') + feed('Go1<esc>:$r XXTestEol<cr>') + execute('$r XXTestNoEol') + execute('w') + + -- Assert buffer contents. + expect([=[ + 0 + with eol + END + without eolEND + 1 + with eol + stays eol + END + without eol + stays withoutEND]=]) + end) +end) |