diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-12-27 22:49:44 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-12-27 22:49:44 +0100 |
commit | c1015121ec626cab6cb384f544bc0be1a1760c0e (patch) | |
tree | 6cc9a5d1899a4486a24c491e07d17a7dd01f9503 /runtime | |
parent | 4f030ec24e0e148bbb83aedaef7dd629e5fef130 (diff) | |
parent | e1876c7ad1b5e30c0a9919e2c4587d11550c8507 (diff) | |
download | rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.gz rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.bz2 rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.zip |
Merge 'upstream/master' into pr-win-erw7
Diffstat (limited to 'runtime')
43 files changed, 578 insertions, 748 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 70e4ca2eec..ad706af087 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -68,9 +68,9 @@ foreach(DF ${DOCFILES}) endforeach() add_custom_target(helptags - COMMAND ${CMAKE_COMMAND} -E remove ${GENERATED_RUNTIME_DIR}/doc/* + COMMAND ${CMAKE_COMMAND} -E remove doc/* COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PROJECT_SOURCE_DIR}/runtime/doc ${GENERATED_RUNTIME_DIR}/doc + ${PROJECT_SOURCE_DIR}/runtime/doc doc COMMAND "${PROJECT_BINARY_DIR}/bin/nvim" -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit DEPENDS @@ -87,7 +87,7 @@ add_custom_command(OUTPUT ${GENERATED_HELP_TAGS} add_custom_target(doc_html COMMAND make html DEPENDS - ${GENERATED_HELP_TAGS} + helptags WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc" ) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 9a04649bfa..9cd8b3801b 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -152,10 +152,10 @@ function! s:check_clipboard() abort endif endfunction -" Get the latest Neovim Python client version from PyPI. +" Get the latest Neovim Python client (pynvim) version from PyPI. function! s:latest_pypi_version() abort let pypi_version = 'unable to get pypi response' - let pypi_response = s:download('https://pypi.python.org/pypi/neovim/json') + let pypi_response = s:download('https://pypi.python.org/pypi/pynvim/json') if !empty(pypi_response) try let pypi_data = json_decode(pypi_response) @@ -192,9 +192,9 @@ function! s:version_info(python) abort let nvim_path = s:trim(s:system([ \ a:python, '-c', \ 'import sys; sys.path.remove(""); ' . - \ 'import neovim; print(neovim.__file__)'])) + \ 'import pynvim; print(pynvim.__file__)'])) if s:shell_error || empty(nvim_path) - return [python_version, 'unable to load neovim Python module', pypi_version, + return [python_version, 'unable to load pynvim Python module', pypi_version, \ nvim_path] endif @@ -206,13 +206,13 @@ function! s:version_info(python) abort return a == b ? 0 : a > b ? 1 : -1 endfunction - " Try to get neovim.VERSION (added in 0.1.11dev). + " Try to get pynvim.VERSION (added in 0.1.11dev). let nvim_version = s:system([a:python, '-c', - \ 'from neovim import VERSION as v; '. + \ 'from pynvim import VERSION as v; '. \ 'print("{}.{}.{}{}".format(v.major, v.minor, v.patch, v.prerelease))'], \ '', 1, 1) if empty(nvim_version) - let nvim_version = 'unable to find neovim Python module version' + let nvim_version = 'unable to find pynvim Python module version' let base = fnamemodify(nvim_path, ':h') let metas = glob(base.'-*/METADATA', 1, 1) \ + glob(base.'-*/PKG-INFO', 1, 1) @@ -293,7 +293,7 @@ function! s:check_python(version) abort let [pyname, pythonx_errs] = provider#pythonx#Detect(a:version) if empty(pyname) - call health#report_warn('No Python interpreter was found with the neovim ' + call health#report_warn('No Python interpreter was found with the pynvim ' \ . 'module. Using the first available for diagnostics.') elseif exists('g:'.host_prog_var) let python_bin = pyname @@ -352,7 +352,7 @@ function! s:check_python(version) abort call health#report_warn('pyenv is not set up optimally.', [ \ printf('Create a virtualenv specifically ' \ . 'for Neovim using pyenv, and set `g:%s`. This will avoid ' - \ . 'the need to install the Neovim Python module in each ' + \ . 'the need to install the pynvim module in each ' \ . 'version/virtualenv.', host_prog_var) \ ]) elseif !empty(venv) @@ -366,7 +366,7 @@ function! s:check_python(version) abort call health#report_warn('Your virtualenv is not set up optimally.', [ \ printf('Create a virtualenv specifically ' \ . 'for Neovim and use `g:%s`. This will avoid ' - \ . 'the need to install Neovim''s Python module in each ' + \ . 'the need to install the pynvim module in each ' \ . 'virtualenv.', host_prog_var) \ ]) endif @@ -400,6 +400,8 @@ function! s:check_python(version) abort endfor endif + let pip = 'pip' . (a:version == 2 ? '' : '3') + if !empty(python_bin) let [pyversion, current, latest, status] = s:version_info(python_bin) if a:version != str2nr(pyversion) @@ -410,28 +412,35 @@ function! s:check_python(version) abort call health#report_warn('Python 3.3+ is recommended.') endif - call health#report_info('Python'.a:version.' version: ' . pyversion) + call health#report_info('Python version: ' . pyversion) if s:is_bad_response(status) - call health#report_info(printf('%s-neovim version: %s (%s)', pyname, current, status)) + call health#report_info(printf('pynvim version: %s (%s)', current, status)) else - call health#report_info(printf('%s-neovim version: %s', pyname, current)) + call health#report_info(printf('pynvim version: %s', current)) + let [module_found, _msg] = provider#pythonx#CheckForModule(python_bin, + \ 'neovim', a:version) + if !module_found + call health#report_error('Importing "neovim" failed.', + \ "Reinstall \"pynvim\" and optionally \"neovim\" packages.\n" . + \ pip ." uninstall pynvim neovim\n" . + \ pip ." install pynvim\n" . + \ pip ." install neovim # only if needed by third-party software") + endif endif if s:is_bad_response(current) call health#report_error( - \ "Neovim Python client is not installed.\nError: ".current, - \ ['Run in shell: pip' . a:version . ' install neovim']) + \ "pynvim is not installed.\nError: ".current, + \ ['Run in shell: '. pip .' install pynvim']) endif if s:is_bad_response(latest) call health#report_warn('Could not contact PyPI to get latest version.') call health#report_error('HTTP request failed: '.latest) elseif s:is_bad_response(status) - call health#report_warn(printf('Latest %s-neovim is NOT installed: %s', - \ pyname, latest)) + call health#report_warn(printf('Latest pynvim is NOT installed: %s', latest)) elseif !s:is_bad_response(current) - call health#report_ok(printf('Latest %s-neovim is installed: %s', - \ pyname, latest)) + call health#report_ok(printf('Latest pynvim is installed.')) endif endif diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 87a0315073..fd32e03666 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -60,6 +60,7 @@ function! provider#clipboard#Executable() abort let s:err = 'clipboard: invalid g:clipboard' return '' endif + let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null }) let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null }) let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0) @@ -71,18 +72,24 @@ function! provider#clipboard#Executable() abort let s:paste['*'] = s:paste['+'] let s:cache_enabled = 0 return 'pbcopy' - elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b') - let s:copy['+'] = 'xsel --nodetach -i -b' - let s:paste['+'] = 'xsel -o -b' - let s:copy['*'] = 'xsel --nodetach -i -p' - let s:paste['*'] = 'xsel -o -p' - return 'xsel' + elseif exists('$WAYLAND_DISPLAY') && executable('wl-copy') && executable('wl-paste') + let s:copy['+'] = 'wl-copy --foreground' + let s:paste['+'] = 'wl-paste --no-newline' + let s:copy['*'] = 'wl-copy --foreground --primary' + let s:paste['*'] = 'wl-paste --no-newline --primary' + return 'wl-copy' elseif exists('$DISPLAY') && executable('xclip') let s:copy['+'] = 'xclip -quiet -i -selection clipboard' let s:paste['+'] = 'xclip -o -selection clipboard' let s:copy['*'] = 'xclip -quiet -i -selection primary' let s:paste['*'] = 'xclip -o -selection primary' return 'xclip' + elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b') + let s:copy['+'] = 'xsel --nodetach -i -b' + let s:paste['+'] = 'xsel -o -b' + let s:copy['*'] = 'xsel --nodetach -i -p' + let s:paste['*'] = 'xsel -o -p' + return 'xsel' elseif executable('lemonade') let s:copy['+'] = 'lemonade copy' let s:paste['+'] = 'lemonade paste' @@ -95,9 +102,9 @@ function! provider#clipboard#Executable() abort let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'doitclient' - elseif executable('win32yank') - let s:copy['+'] = 'win32yank -i --crlf' - let s:paste['+'] = 'win32yank -o --lf' + elseif executable('win32yank.exe') + let s:copy['+'] = 'win32yank.exe -i --crlf' + let s:paste['+'] = 'win32yank.exe -o --lf' let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'win32yank' @@ -121,7 +128,9 @@ if empty(provider#clipboard#Executable()) endif function! s:clipboard.get(reg) abort - if s:selections[a:reg].owner > 0 + if type(s:paste[a:reg]) == v:t_func + return s:paste[a:reg]() + elseif s:selections[a:reg].owner > 0 return s:selections[a:reg].data end return s:try_cmd(s:paste[a:reg]) @@ -135,6 +144,12 @@ function! s:clipboard.set(lines, regtype, reg) abort end return 0 end + + if type(s:copy[a:reg]) == v:t_func + call s:copy[a:reg](a:lines, a:regtype) + return 0 + end + if s:cache_enabled == 0 call s:try_cmd(s:copy[a:reg], a:lines) return 0 diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index 48ea10aed6..35882849bd 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -49,7 +49,7 @@ endfunction function! provider#node#Detect() abort if exists('g:node_host_prog') - return g:node_host_prog + return expand(g:node_host_prog) endif if !s:is_minimum_version(v:null, 6, 0) return '' diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index b51c398410..b8e2ded00d 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -10,7 +10,7 @@ function! provider#pythonx#Require(host) abort " Python host arguments let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog()) - let args = [prog, '-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()'] + let args = [prog, '-c', 'import sys; sys.path.remove(""); import pynvim; pynvim.start_host()'] " Collect registered Python plugins into args let python_plugins = remote#host#PluginsForHost(a:host.name) @@ -24,13 +24,13 @@ endfunction function! provider#pythonx#Detect(major_ver) abort if a:major_ver == 2 if exists('g:python_host_prog') - return [g:python_host_prog, ''] + return [expand(g:python_host_prog), ''] else let progs = ['python2', 'python2.7', 'python2.6', 'python'] endif else if exists('g:python3_host_prog') - return [g:python3_host_prog, ''] + return [expand(g:python3_host_prog), ''] else let progs = ['python3', 'python3.7', 'python3.6', 'python3.5', \ 'python3.4', 'python3.3', 'python'] @@ -40,7 +40,7 @@ function! provider#pythonx#Detect(major_ver) abort let errors = [] for prog in progs - let [result, err] = s:check_interpreter(prog, a:major_ver) + let [result, err] = provider#pythonx#CheckForModule(prog, 'pynvim', a:major_ver) if result return [prog, err] endif @@ -54,46 +54,53 @@ function! provider#pythonx#Detect(major_ver) abort \ . ":\n" . join(errors, "\n")] endfunction -function! s:check_interpreter(prog, major_ver) abort +" Returns array: [prog_exitcode, prog_version] +function! s:import_module(prog, module) abort + let prog_version = system([a:prog, '-c' , printf( + \ 'import sys; ' . + \ 'sys.path.remove(""); ' . + \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' . + \ 'import pkgutil; ' . + \ 'exit(2*int(pkgutil.get_loader("%s") is None))', + \ a:module)]) + return [v:shell_error, prog_version] +endfunction + +" Returns array: [was_success, error_message] +function! provider#pythonx#CheckForModule(prog, module, major_version) abort let prog_path = exepath(a:prog) if prog_path ==# '' return [0, a:prog . ' not found in search path or not executable.'] endif - let min_version = (a:major_ver == 2) ? '2.6' : '3.3' + let min_version = (a:major_version == 2) ? '2.6' : '3.3' - " Try to load neovim module, and output Python version. - " Return codes: - " 0 Neovim module can be loaded. - " 2 Neovim module cannot be loaded. + " Try to load pynvim module, and output Python version. + " Exit codes: + " 0 pynvim module can be loaded. + " 2 pynvim module cannot be loaded. " Otherwise something else went wrong (e.g. 1 or 127). - let prog_ver = system([ a:prog , '-c' , - \ 'import sys; ' . - \ 'sys.path.remove(""); ' . - \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' . - \ 'import pkgutil; ' . - \ 'exit(2*int(pkgutil.get_loader("neovim") is None))' - \ ]) + let [prog_exitcode, prog_version] = s:import_module(a:prog, 'pynvim') - if v:shell_error == 2 || v:shell_error == 0 + if prog_exitcode == 2 || prog_exitcode == 0 " Check version only for expected return codes. - if prog_ver !~ '^' . a:major_ver - return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python ' - \ . a:major_ver . '.'] - elseif prog_ver =~ '^' . a:major_ver && prog_ver < min_version - return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python >= ' + if prog_version !~ '^' . a:major_version + return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python ' + \ . a:major_version . '.'] + elseif prog_version =~ '^' . a:major_version && prog_version < min_version + return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python >= ' \ . min_version . '.'] endif endif - if v:shell_error == 2 - return [0, prog_path.' does not have the "neovim" module. :help provider-python'] - elseif v:shell_error == 127 + if prog_exitcode == 2 + return [0, prog_path.' does not have the "pynvim" module. :help provider-python'] + elseif prog_exitcode == 127 " This can happen with pyenv's shims. - return [0, prog_path . ' does not exist: ' . prog_ver] - elseif v:shell_error + return [0, prog_path . ' does not exist: ' . prog_version] + elseif prog_exitcode return [0, 'Checking ' . prog_path . ' caused an unknown error. ' - \ . '(' . v:shell_error . ', output: ' . prog_ver . ')' + \ . '(' . prog_exitcode . ', output: ' . prog_version . ')' \ . ' Report this at https://github.com/neovim/neovim'] endif diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index ed9436750b..3b4c6c4839 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -45,7 +45,7 @@ endfunction function! s:detect() if exists("g:ruby_host_prog") - return g:ruby_host_prog + return expand(g:ruby_host_prog) elseif has('win32') return exepath('neovim-ruby-host.bat') else diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index d92fe1b180..dc670dbd14 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -153,15 +153,14 @@ fun! tar#Browse(tarfile) let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e') endif - let gzip_command = s:get_gzip_command(tarfile) - let curlast= line("$") if tarfile =~# '\.\(gz\|tgz\)$' + let gzip_command = s:get_gzip_command(tarfile) " call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.lrp' " call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ") - exe "sil! r! cat -- ".shellescape(tarfile,1)."|" . gzip_command . " -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - " + exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$' " call Decho("3: exe silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " @@ -291,17 +290,16 @@ fun! tar#Read(fname,mode) let tar_secure= " " endif - let gzip_command = s:get_gzip_command(tarfile) - if tarfile =~# '\.bz2$' " call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.\(gz\|tgz\)$' + let gzip_command = s:get_gzip_command(tarfile) " call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1)) exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.lrp$' " call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) - exe "sil! r! cat -- ".shellescape(tarfile,1)." | " . gzip_command . " -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp + exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.lzma$' " call Decho("7: exe silent r! lzma -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp @@ -589,8 +587,9 @@ fun! tar#Vimuntar(...) " if necessary, decompress the tarball; then, extract it if tartail =~ '\.tgz' - if executable("bzip2") - silent exe "!bzip2 -d ".shellescape(tartail) + let gzip_command = s:get_gzip_command(tarfile) + if executable(gzip_command) + silent exe "!" . gzip_command . " -d ".shellescape(tartail) elseif executable("gunzip") silent exe "!gunzip ".shellescape(tartail) elseif executable("gzip") @@ -630,11 +629,24 @@ fun! tar#Vimuntar(...) endfun func s:get_gzip_command(file) - if a:file =~# 'z$' && executable('bzip2') - " Some .tgz files are actually compressed with bzip2. Since bzip2 can - " handle the format from gzip, use it if the command exists. + " Try using the "file" command to get the actual compression type, since + " there is no standard way for the naming: ".tgz", ".tbz", ".txz", etc. + " If the "file" command doesn't work fall back to just using the file name. + if a:file =~# 'z$' + let filetype = system('file ' . a:file) + if filetype =~ 'bzip2 compressed' && executable('bzip2') + return 'bzip2' + endif + if filetype =~ 'XZ compressed' && executable('xz') + return 'xz' + endif + endif + if a:file =~# 'bz2$' return 'bzip2' endif + if a:file =~# 'xz$' + return 'xz' + endif return 'gzip' endfunc diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index e816d0ae76..7dab69df22 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -80,6 +80,19 @@ As Nvim evolves the API may change in compliance with this CONTRACT: - Deprecated functions will not be removed until Nvim version 2.0 ============================================================================== +Global events *api-global-events* + +When a client invokes an API request as an async notification, it is not +possible for Nvim to send an error response. Instead, in case of error, the +following notification will be sent to the client: + + *nvim_error_event* +nvim_error_event[{type}, {message}] + +{type} is a numeric id as defined by `api_info().error_types`, and {message} is +a string with the error message. + +============================================================================== Buffer update events *api-buffer-updates* API clients can "attach" to Nvim buffers to subscribe to buffer update events. @@ -97,7 +110,7 @@ nvim_buf_lines_event[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}, When {changedtick} is |v:null| this means the screen lines (display) changed but not the buffer contents. {linedata} contains the changed screen lines. - This happens when |inccommand| shows a buffer preview. + This happens when 'inccommand' shows a buffer preview. Properties:~ {buf} API buffer handle (buffer number) @@ -138,7 +151,7 @@ nvim_buf_changedtick_event[{buf}, {changedtick}] *nvim_buf_changedtick_event* nvim_buf_detach_event[{buf}] *nvim_buf_detach_event* When buffer is detached (i.e. updates are disabled). Triggered explicitly by - |nvim_buf_detach| or implicitly in these cases: + |nvim_buf_detach()| or implicitly in these cases: - Buffer was |abandon|ed and 'hidden' is not set. - Buffer was reloaded, e.g. with |:edit| or an external change triggered |:checktime| or 'autoread'. @@ -206,7 +219,7 @@ Example using the Nvim python-client: buf.clear_highlight(src) < If the highlights don't need to be deleted or updated, just pass -1 as -src_id (this is the default in python). Use |nvim_buf_clear_highlight()| to +src_id (this is the default in python). Use |nvim_buf_clear_namespace()| to clear highlights from a specific source, in a specific line range or the entire buffer by passing in the line range 0, -1 (the latter is the default in python as used above). @@ -218,7 +231,7 @@ An example of calling the api from vimscript: > call nvim_buf_add_highlight(0, src, "Identifier", 0, 5, -1) " later - call nvim_buf_clear_highlight(0, src, 0, -1) + call nvim_buf_clear_namespace(0, src, 0, -1) > ============================================================================== Global Functions *api-global* @@ -478,6 +491,9 @@ nvim_err_writeln({str}) *nvim_err_writeln()* nvim_list_bufs() *nvim_list_bufs()* Gets the current list of buffer handles + Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use + |nvim_buf_is_loaded()| to check if a buffer is loaded. + Return: ~ List of buffer handles @@ -529,6 +545,30 @@ nvim_set_current_tabpage({tabpage}) *nvim_set_current_tabpage()* Parameters: ~ {tabpage} Tabpage handle +nvim_create_namespace({name}) *nvim_create_namespace()* + create a new namespace, or get one with an exisiting name + + Namespaces are currently used for buffer highlighting and + virtual text, see |nvim_buf_add_highlight| and + |nvim_buf_set_virtual_text|. + + Namespaces can have a name of be anonymous. If `name` is a + non-empty string, and a namespace already exists with that + name,the existing namespace id is returned. If an empty string + is used, a new anonymous namespace is returned. + + Parameters: ~ + {name} Name of the namespace or empty string + + Return: ~ + the namespace id + +nvim_get_namespaces() *nvim_get_namespaces()* + Get existing named namespaces + + Return: ~ + dict that maps from names to namespace ids. + nvim_subscribe({event}) *nvim_subscribe()* Subscribes to event broadcasts @@ -638,7 +678,7 @@ nvim_set_client_info({name}, {version}, {type}, {methods}, Clients might define their own keys, but the following are suggested: "website" Website of client (for instance github repository) - "license" Informal descripton of the + "license" Informal description of the license, such as "Apache 2", "GPLv3" or "MIT" "logo" URI or path to image, preferably small logo or icon. .png or .svg @@ -862,8 +902,7 @@ nvim_buf_line_count({buffer}) *nvim_buf_line_count()* {buffer} Buffer handle Return: ~ - Line count, or `0` if the buffer has been unloaded (see - |api-buffer|). + Line count, or 0 for unloaded buffer. |api-buffer| nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* Activate updates from this buffer to the current channel. @@ -912,8 +951,7 @@ nvim_buf_get_lines({buffer}, {start}, {end}, {strict_indexing}) error. Return: ~ - Array of lines. If the buffer has been unloaded then an - empty array will be returned instead. (See |api-buffer|.) + Array of lines, or empty array for unloaded buffer. *nvim_buf_set_lines()* nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, @@ -940,6 +978,25 @@ nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, error. {replacement} Array of lines to use as replacement +nvim_buf_get_offset({buffer}, {index}) *nvim_buf_get_offset()* + Returns the byte offset for a line. + + Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is + one byte. 'fileformat' and 'fileencoding' are ignored. The + line index just after the last line gives the total byte-count + of the buffer. A final EOL byte is counted if it would be + written, see 'eol'. + + Unlike |line2byte()|, throws error for out-of-bounds indexing. + Returns -1 for unloaded buffer. + + Parameters: ~ + {buffer} Buffer handle + {index} Line index + + Return: ~ + Integer byte offset, or -1 for unloaded buffer. + nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()* Gets a buffer-scoped (b:) variable. @@ -1065,35 +1122,36 @@ nvim_buf_get_mark({buffer}, {name}) *nvim_buf_get_mark()* (row, col) tuple *nvim_buf_add_highlight()* -nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line}, +nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start}, {col_end}) Adds a highlight to buffer. Useful for plugins that dynamically generate highlights to a buffer (like a semantic highlighter or linter). The function - adds a single highlight to a buffer. Unlike matchaddpos() + adds a single highlight to a buffer. Unlike |matchaddpos()| highlights follow changes to line numbering (as lines are inserted/removed above the highlighted line), like signs and marks do. - `src_id` is useful for batch deletion/updating of a set of - highlights. When called with `src_id = 0`, an unique source id - is generated and returned. Successive calls can pass that - `src_id` to associate new highlights with the same source - group. All highlights in the same group can be cleared with - `nvim_buf_clear_highlight`. If the highlight never will be - manually deleted, pass `src_id = -1`. + Namespaces are used for batch deletion/updating of a set of + highlights. To create a namespace, use |nvim_create_namespace| + which returns a namespace id. Pass it in to this function as + `ns_id` to add highlights to the namespace. All highlights in + the same namespace can then be cleared with single call to + |nvim_buf_clear_namespace|. If the highlight never will be + deleted by an API call, pass `ns_id = -1`. - If `hl_group` is the empty string no highlight is added, but a - new `src_id` is still returned. This is useful for an external - plugin to synchrounously request an unique `src_id` at - initialization, and later asynchronously add and clear - highlights in response to buffer changes. + As a shorthand, `ns_id = 0` can be used to create a new + namespace for the highlight, the allocated id is then + returned. If `hl_group` is the empty string no highlight is + added, but a new `ns_id` is still returned. This is supported + for backwards compatibility, new code should use + |nvim_create_namespace| to create a new empty namespace. Parameters: ~ {buffer} Buffer handle - {src_id} Source group to use or 0 to use a new group, - or -1 for ungrouped highlight + {ns_id} namespace to use or -1 for ungrouped + highlight {hl_group} Name of the highlight group to use {line} Line to highlight (zero-indexed) {col_start} Start of (byte-indexed) column range to @@ -1102,39 +1160,50 @@ nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line}, highlight, or -1 to highlight to end of line Return: ~ - The src_id that was used + The ns_id that was used - *nvim_buf_clear_highlight()* -nvim_buf_clear_highlight({buffer}, {src_id}, {line_start}, {line_end}) - Clears highlights from a given source group and a range of - lines + *nvim_buf_clear_namespace()* +nvim_buf_clear_namespace({buffer}, {ns_id}, {line_start}, {line_end}) + Clears namespaced objects, highlights and virtual text, from a + line range - To clear a source group in the entire buffer, pass in 0 and -1 + To clear the namespace in the entire buffer, pass in 0 and -1 to line_start and line_end respectively. Parameters: ~ {buffer} Buffer handle - {src_id} Highlight source group to clear, or -1 to - clear all. + {ns_id} Namespace to clear, or -1 to clear all + namespaces. {line_start} Start of range of lines to clear {line_end} End of range of lines to clear (exclusive) - or -1 to clear to end of file. + or -1 to clear to end of buffer. *nvim_buf_set_virtual_text()* -nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks}, - {opts}) +nvim_buf_set_virtual_text({buffer}, {ns_id}, {line}, {chunks}, {opts}) Set the virtual text (annotation) for a buffer line. By default (and currently the only option) the text will be placed after the buffer text. Virtual text will never cause reflow, rather virtual text will be truncated at the end of - the screen line. The virtual text will begin after one cell to - the right of the ordinary text, this will contain the |lcs- - eol| char if set, otherwise just be a space. + the screen line. The virtual text will begin one cell (|lcs- + eol| or space) after the ordinary text. + + Namespaces are used to support batch deletion/updating of + virtual text. To create a namespace, use + |nvim_create_namespace|. Virtual text is cleared using + |nvim_buf_clear_namespace|. The same `ns_id` can be used for + both virtual text and highlights added by + |nvim_buf_add_highlight|, both can then be cleared with a + single call to |nvim_buf_clear_namespace|. If the virtual text + never will be cleared by an API call, pass `ns_id = -1`. + + As a shorthand, `ns_id = 0` can be used to create a new + namespace for the virtual text, the allocated id is then + returned. Parameters: ~ {buffer} Buffer handle - {src_id} Source group to use or 0 to use a new group, or + {ns_id} Namespace to use or 0 to create a namespace, or -1 for a ungrouped annotation {line} Line to annotate with virtual text (zero- indexed) @@ -1145,7 +1214,7 @@ nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks}, {opts} Optional parameters. Currently not used. Return: ~ - The src_id that was used + The ns_id that was used ============================================================================== @@ -1160,6 +1229,13 @@ nvim_win_get_buf({window}) *nvim_win_get_buf()* Return: ~ Buffer handle +nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()* + Sets the current buffer in a window, without side-effects + + Parameters: ~ + {window} Window handle + {buffer} Buffer handle + nvim_win_get_cursor({window}) *nvim_win_get_cursor()* Gets the cursor position in the window diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 75a26bf614..d7b74f99c2 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -278,7 +278,7 @@ Name triggered by ~ |VimEnter| after doing all the startup stuff |GUIEnter| after starting the GUI successfully |GUIFailed| after starting the GUI failed -|TermResponse| after the terminal response to |t_RV| is received +|TermResponse| after the terminal response to t_RV is received |QuitPre| when using `:quit`, before deciding whether to exit |ExitPre| when using a command that may make Vim exit |VimLeavePre| before exiting Nvim, before writing the shada file @@ -521,25 +521,24 @@ CmdUndefined When a user command is used but it isn't command is defined. An alternative is to always define the user command and have it invoke an autoloaded function. See |autoload|. - *CmdlineChanged* -CmdlineChanged After a change was made to the text in the - command line. Be careful not to mess up - the command line, it may cause Vim to lock up. + *CmdlineChanged* +CmdlineChanged After a change was made to the text inside + command line. Be careful not to mess up the + command line, it may cause Vim to lock up. + <afile> is set to the |cmdline-char|. *CmdlineEnter* -CmdlineEnter After moving the cursor to the command line, - where the user can type a command or search - string. - <afile> is set to a single character, - indicating the type of command-line. - |cmdline-char| +CmdlineEnter After entering the command-line (including + non-interactive use of ":" in a mapping: use + |<Cmd>| instead to avoid this). + <afile> is set to the |cmdline-char|. Sets these |v:event| keys: cmdlevel cmdtype *CmdlineLeave* -CmdlineLeave Before leaving the command line. - <afile> is set to a single character, - indicating the type of command-line. - |cmdline-char| +CmdlineLeave Before leaving the command-line (including + non-interactive use of ":" in a mapping: use + |<Cmd>| instead to avoid this). + <afile> is set to the |cmdline-char|. Sets these |v:event| keys: abort (mutable) cmdlevel @@ -630,6 +629,11 @@ CursorMoved After the cursor was moved in Normal or Visual CursorMovedI After the cursor was moved in Insert mode. Not triggered when the popup menu is visible. Otherwise the same as CursorMoved. + *DiffUpdated* +DiffUpdated After diffs have been updated. Depending on + what kind of diff is being used (internal or + external) this can be triggered on every + change or when doing |:diffupdate|. *DirChanged* DirChanged After the |current-directory| was changed. Sets these |v:event| keys: @@ -989,7 +993,7 @@ TermClose When a |terminal| job ends. TermOpen When a |terminal| job is starting. Can be used to configure the terminal buffer. *TermResponse* -TermResponse After the response to |t_RV| is received from +TermResponse After the response to t_RV is received from the terminal. The value of |v:termresponse| can be used to do things depending on the terminal version. Note that this event may be diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index d4f8d170ef..3f22fcb504 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -212,7 +212,7 @@ CTRL-\ e {expr} *c_CTRL-\_e* *c_CTRL-Y* CTRL-Y When there is a modeless selection, copy the selection into - the clipboard. |modeless-selection| + the clipboard. If there is no selection CTRL-Y is inserted as a character. CTRL-M or CTRL-J *c_CTRL-M* *c_CTRL-J* *c_<NL>* *c_<CR>* *c_CR* diff --git a/runtime/doc/debug.txt b/runtime/doc/debug.txt index 441d31c7b9..835b35b388 100644 --- a/runtime/doc/debug.txt +++ b/runtime/doc/debug.txt @@ -162,12 +162,8 @@ In WinDbg: choose Open Crash Dump on the File menu. Follow the instructions in *get-ms-debuggers* 3.5 Obtaining Microsoft Debugging Tools ~ -The Debugging Tools for Windows (including WinDbg) can be downloaded from - http://www.microsoft.com/whdc/devtools/debugging/default.mspx -This includes the WinDbg debugger. - -Visual C++ 2005 Express Edition can be downloaded for free from: - http://msdn.microsoft.com/vstudio/express/visualC/default.aspx +Visual Studio 2017 Community Edition can be downloaded for free from: + https://visualstudio.microsoft.com/downloads/ ========================================================================= vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 7c98b81867..4369ad7894 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -37,15 +37,17 @@ Functions ~ *file_readable()* Obsolete name for |filereadable()|. *highlight_exists()* Obsolete name for |hlexists()|. *highlightID()* Obsolete name for |hlID()|. +*inputdialog()* Use |input()| instead. *jobclose()* Obsolete name for |chanclose()| *jobsend()* Obsolete name for |chansend()| *last_buffer_nr()* Obsolete name for bufnr("$"). Modifiers ~ +*cpo-<* *:menu-<special>* -*:menu-special* <> notation is always enabled. |cpo-<| +*:menu-special* <> notation is always enabled. *:map-<special>* -*:map-special* <> notation is always enabled. |cpo-<| +*:map-special* <> notation is always enabled. Normal commands ~ *]f* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index cd81236f32..2c919f9104 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -6,19 +6,20 @@ Development of Nvim *development* -Nvim is open source software. Everybody is encouraged to contribute. - https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md +This reference describes design constraints and guidelines, for developing +Nvim applications or Nvim itself. +Architecture and internal concepts are covered in src/nvim/README.md -See src/nvim/README.md for an overview of the source code. +Nvim is free and open source. Everybody is encouraged to contribute. + https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md Type |gO| to see the table of contents. ============================================================================== Design goals *design-goals* -Most important things come first (roughly). - -Note that some items conflict; this is intentional. A balance must be found. +Most important things come first (roughly). Some items conflict; this is +intentional. A balance must be found. NVIM IS... IMPROVED *design-improved* @@ -81,41 +82,6 @@ include the kitchen sink... but it's good for plumbing." Developer guidelines *dev* -JARGON *dev-jargon* - -API client ~ -All external UIs and remote plugins (as opposed to regular Vim plugins) are -"clients" in general; but we call something an "API client" if its purpose is -to abstract or wrap the RPC API for the convenience of other applications -(just like a REST client or SDK such as boto3 for AWS: you can speak AWS REST -using an HTTP client like curl, but boto3 wraps that in a convenient python -interface). For example, the Nvim lua-client is an API client: - https://github.com/neovim/lua-client - -Host ~ -A plugin "host" is both a client (of the Nvim API) and a server (of an -external platform, e.g. python). It is a remote plugin that hosts other -plugins. - -Remote plugin ~ -Arbitrary code registered via |:UpdateRemotePlugins|, that runs in a separate -process and communicates with Nvim via the |api|. - -Window ~ -The word "window" is commonly used for several things: A window on the screen, -the xterm window, a window inside Vim to view a buffer. -To avoid confusion, other items that are sometimes called window have been -given another name. Here is an overview of the related items: - -screen The whole display. -shell The Vim application. This can cover the whole screen (e.g., - when running in a console) or part of it (xterm or GUI). -window View on a buffer. There can be several windows in Vim, - together with the command line, menubar, toolbar, etc. they - fit in the shell. -frame Windows are kept in a tree of frames. Each frame contains - a column, row, or window ("leaf" frame). - PROVIDERS *dev-provider* A goal of Nvim is to allow extension of the editor without special knowledge @@ -215,6 +181,8 @@ Standard Features ~ - Clients should call |nvim_set_client_info()| after connecting, so users and plugins can detect the client by handling the |ChanInfo| event. This avoids the need for special variables or other client hints. +- Clients should handle |nvim_error_event| notifications, which will be sent + if an async request to nvim was rejected or caused an error. Package Naming ~ diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index 766240dfb0..ab002b4dcb 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -27,7 +27,9 @@ The second and following arguments may also be a directory name. Vim will then append the file name of the first argument to the directory name to find the file. -This only works when a standard "diff" command is available. See 'diffexpr'. +By default an internal diff library will be used. When 'diffopt' or +'diffexpr' has been set an external "diff" command will be used. This only +works when such a diff program is available. Diffs are local to the current tab page |tab-page|. You can't see diffs with a window in another tab page. This does make it possible to have several @@ -332,8 +334,9 @@ between file1 and file2: > The ">" is replaced with the value of 'shellredir'. -The output of "diff" must be a normal "ed" style diff. Do NOT use a context -diff. This example explains the format that Vim expects: > +The output of "diff" must be a normal "ed" style diff or a unified diff. Do +NOT use a context diff. This example explains the format that Vim expects for +the "ed" style diff: > 1a2 > bbb diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index f03189485c..6dffd6f05e 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2137,8 +2137,6 @@ index({list}, {expr} [, {start} [, {ic}]]) Number index in {list} where {expr} appears input({prompt} [, {text} [, {completion}]]) String get input from the user -inputdialog({prompt} [, {text} [, {completion}]]) - String like input() but in a GUI dialog inputlist({textlist}) Number let the user pick from a choice list inputrestore() Number restore typeahead inputsave() Number save and clear typeahead @@ -2925,7 +2923,7 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) made. It returns the number of the choice. For the first choice this is 1. - {msg} is displayed in a |dialog| with {choices} as the + {msg} is displayed in a dialog with {choices} as the alternatives. When {choices} is missing or empty, "&OK" is used (and translated). {msg} is a String, use '\n' to include a newline. Only on @@ -3381,9 +3379,7 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()* If {list} is given and it is |TRUE|, a List will be returned. Otherwise the result is a String and when there are several - matches, they are separated by <NL> characters. [Note: in - version 5.0 a space was used, which caused problems when a - file name contains a space] + matches, they are separated by <NL> characters. If the expansion fails, the result is an empty string. A name for a non-existing file is not included, unless {expr} does @@ -3444,7 +3440,7 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()* all "README" files in the current directory and below: > :echo expand("**/README") < - Expand() can also be used to expand variables and environment + expand() can also be used to expand variables and environment variables that are only known in a shell. But this can be slow, because a shell may be used to do the expansion. See |expr-env-expand|. @@ -4915,20 +4911,6 @@ input({opts}) : call inputrestore() :endfunction -inputdialog({prompt} [, {text} [, {cancelreturn}]]) *inputdialog()* -inputdialog({opts}) - Like |input()|, but when the GUI is running and text dialogs - are supported, a dialog window pops up to input the text. - Example: > - :let n = inputdialog("value for shiftwidth", shiftwidth()) - :if n != "" - : let &sw = n - :endif -< When the dialog is cancelled {cancelreturn} is returned. When - omitted an empty string is returned. - Hitting <Enter> works like pressing the OK button. Hitting - <Esc> works like pressing the Cancel button. - inputlist({textlist}) *inputlist()* {textlist} must be a |List| of strings. This |List| is displayed, one string per line. The user will be prompted to @@ -8560,7 +8542,7 @@ tag_old_static Compiled with support for old static tags |tag-old-static|. tag_any_white Compiled with support for any white characters in tags files |tag-any-white|. -termresponse Compiled with support for |t_RV| and |v:termresponse|. +termresponse Compiled with support for t_RV and |v:termresponse|. textobjects Compiled with support for |text-objects|. timers Compiled with |timer_start()| support. title Compiled with window title support |'title'|. diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 976402c915..edecc655dd 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -150,6 +150,7 @@ GUI ~ Interfaces ~ |if_cscop.txt| using Cscope with Vim +|if_lua.txt| Lua interface |if_pyth.txt| Python interface |if_ruby.txt| Ruby interface |sign.txt| debugging signs @@ -160,6 +161,9 @@ Versions ~ *standard-plugin-list* Standard plugins ~ |pi_gzip.txt| Reading and writing compressed files +|pi_health.txt| Healthcheck framework +|pi_matchit.txt| Extended "%" matching +|pi_msgpack.txt| msgpack utilities |pi_netrw.txt| Reading and writing files over a network |pi_paren.txt| Highlight matching parens |pi_spec.txt| Filetype plugin to work with rpm spec files diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 17c1a8a329..9dbbf87995 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -229,8 +229,7 @@ shared between command calls. All Lua default libraries are available. In addition, Lua "print" function has its output redirected to the Nvim message area, with arguments separated by a white space instead of a tab. -Lua uses the "vim" module (see |lua-vim|) to issue commands to Nvim -and manage buffers (|lua-buffer|) and windows (|lua-window|). However, +Lua uses the "vim" module (see |lua-vim|) to issue commands to Nvim. However, procedures that alter buffer content, open new buffers, and change cursor position are restricted when the command is executed in the |sandbox|. @@ -261,7 +260,7 @@ vim.stricmp(a, b) *lua-vim.stricmp* greater then b or a is lesser then b respectively. vim.type_idx *lua-vim.type_idx* - Type index for use in |lua-special-tables|. Specifying one of the + Type index for use in |lua-special-tbl|. Specifying one of the values from |lua-vim.types| allows typing the empty table (it is unclear whether empty lua table represents empty list or empty array) and forcing integral numbers to be |Float|. See |lua-special-tbl| for diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index ed3f9a1776..7024a57333 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1472,7 +1472,6 @@ tag command action ~ |:sfind| :sf[ind] split current window and edit file in 'path' |:sfirst| :sfir[st] split window and go to first file in the argument list -|:simalt| :sim[alt] Win32 GUI: simulate Windows ALT key |:sign| :sig[n] manipulate signs |:silent| :sil[ent] run a command silently |:sleep| :sl[eep] do nothing for a few seconds diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index bf2e86ae46..fee7d9aa69 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -1,7 +1,7 @@ *intro.txt* Nvim - VIM REFERENCE MANUAL by Bram Moolenaar + NVIM REFERENCE MANUAL Introduction to Vim *ref* *reference* @@ -9,7 +9,7 @@ Introduction to Vim *ref* *reference* Type |gO| to see the table of contents. ============================================================================== -1. Introduction *intro* +Introduction *intro* Vim stands for Vi IMproved. It used to be Vi IMitation, but there are so many improvements that a name change was appropriate. Vim is a text editor which @@ -28,8 +28,8 @@ is not located in the default place. You can jump to subjects like with tags: Use CTRL-] to jump to a subject under the cursor, use CTRL-T to jump back. *pronounce* -Vim is pronounced as one word, like Jim, not vi-ai-em. It's written with a -capital, since it's a name, again like Jim. +Vim is pronounced as one word, like Jim. Nvim is pronounced as N-vim, or, +continuing with the Jim simile, N-Jim, which sounds like Ninja. This manual is a reference for all the Vim commands and options. This is not an introduction to the use of Vi or Vim, it gets a bit complicated here and @@ -37,134 +37,67 @@ there. For beginners, there is a hands-on |tutor|. To learn using Vim, read the user manual |usr_toc.txt|. *book* -There are many books on Vi that contain a section for beginners. There are -two books I can recommend: +There are many books on Vi and Vim. We recommend these books: - "Vim - Vi Improved" by Steve Oualline + "Practical Vim" by Drew Neil + "Modern Vim" by Drew Neil + https://vimcasts.org/publications/ -This is the very first book completely dedicated to Vim. It is very good for -beginners. The most often used commands are explained with pictures and -examples. The less often used commands are also explained, the more advanced -features are summarized. There is a comprehensive index and a quick -reference. Parts of this book have been included in the user manual -|frombook|. -Published by New Riders Publishing. ISBN: 0735710015 -For more information try one of these: - http://iccf-holland.org/click5.html - http://www.vim.org/iccf/click5.html +"Practical Vim" is a popular because of its focus on quickly learning common +editing tasks with Vim. "Modern Vim" explores new features introduced by Nvim +and Vim 8. - "Learning the Vi editor" by Linda Lamb and Arnold Robbins + "Vim - Vi Improved" by Steve Oualline -This is a book about Vi that includes a chapter on Vim (in the sixth edition). -The first steps in Vi are explained very well. The commands that Vim adds are -only briefly mentioned. There is also a German translation. -Published by O'Reilly. ISBN: 1-56592-426-6. +This is the first book dedicated to Vim. Parts of it were included in the +user manual. |frombook| ISBN: 0735710015 +For more information try one of these: + https://iccf-holland.org/click5.html + https://www.vim.org/iccf/click5.html ============================================================================== -2. Vim on the internet *internet* +Nvim on the interwebs *internet* *www* *WWW* *faq* *FAQ* *distribution* *download* -The Vim pages contain the most recent information about Vim. They also -contain links to the most recent version of Vim. The FAQ is a list of -Frequently Asked Questions. Read this if you have problems. - - Vim home page: http://www.vim.org/ - Vim FAQ: http://vimdoc.sf.net/ - Downloading: ftp://ftp.vim.org/pub/vim/MIRRORS - - -Usenet News group where Vim is discussed: *news* *usenet* - comp.editors -This group is also for other editors. If you write about Vim, don't forget to -mention that. - - *mail-list* *maillist* -There are several mailing lists for Vim: -<vim@vim.org> *vim-use* *vim_use* - For discussions about using existing versions of Vim: Useful mappings, - questions, answers, where to get a specific version, etc. There are - quite a few people watching this list and answering questions, also - for beginners. Don't hesitate to ask your question here. -<vim-dev@vim.org> *vim-dev* *vim_dev* *vimdev* - For discussions about changing Vim: New features, porting, patches, - beta-test versions, etc. -<vim-announce@vim.org> *vim-announce* *vim_announce* - Announcements about new versions of Vim; also for beta-test versions - and ports to different systems. This is a read-only list. -<vim-mac@vim.org> *vim-mac* *vim_mac* - For discussions about using and improving the Macintosh version of - Vim. - -See http://www.vim.org/maillist.php for the latest information. - -NOTE: -- You can only send messages to these lists if you have subscribed! -- You need to send the messages from the same location as where you subscribed - from (to avoid spam mail). -- Maximum message size is 40000 characters. - - *subscribe-maillist* -If you want to join, send a message to - <vim-subscribe@vim.org> -Make sure that your "From:" address is correct. Then the list server will -give you help on how to subscribe. - - *maillist-archive* -For more information and archives look on the Vim maillist page: -http://www.vim.org/maillist.php + + Nvim home page: https://neovim.io/ + Nvim FAQ: https://github.com/neovim/neovim/wiki/FAQ + Downloads: https://github.com/neovim/neovim/releases + Vim FAQ: https://vimhelp.appspot.com/vim_faq.txt.html + Vim home page: https://www.vim.org/ Bug reports: *bugs* *bug-reports* *bugreport.vim* Report bugs on GitHub: https://github.com/neovim/neovim/issues -Please be brief; all the time that is spent on answering mail is subtracted -from the time that is spent on improving Vim! Always give a reproducible -example and try to find out which settings or other things trigger the bug. +Be brief, yet complete. Always give a reproducible example and try to find +out which settings or other things trigger the bug. -Preferably start Vim with: > - vim --clean -u reproduce.vim -Where reproduce.vim is a script that reproduces the problem. Try different -machines, if relevant (is this an MS-Windows specific bug perhaps?). +If Nvim crashes, try to get a backtrace. See |debug.txt|. -Send me patches if you can! +============================================================================== +Sponsor Vim/Nvim development *sponsor* *register* -It will help to include information about the version of Vim you are using and -your setup. You can get the information with this command: > - :so $VIMRUNTIME/bugreport.vim -This will create a file "bugreport.txt" in the current directory, with a lot -of information of your environment. Before sending this out, check if it -doesn't contain any confidential information! +Fixing bugs and adding new features takes a lot of time and effort. To show +your appreciation for the work and motivate Bram and others to continue +working on Vim please send a donation. -If Vim crashes, please try to find out where. You can find help on this here: -|debug.txt|. +Since Bram is back to a paid job the money will now be used to help children +in Uganda. See |uganda|. But at the same time donations increase Bram's +motivation to keep working on Vim! -In case of doubt or when you wonder if the problem has already been fixed but -you can't find a fix for it, become a member of the vim-dev maillist and ask -your question there. |maillist| +For the most recent information about sponsoring look on the Vim web site: - *year-2000* *Y2K* -Since Vim internally doesn't use dates for editing, there is no year 2000 -problem to worry about. Vim does use the time in the form of seconds since -January 1st 1970. It is used for a time-stamp check of the edited file and -the swap file, which is not critical and should only cause warning messages. + https://www.vim.org/sponsor/ -There might be a year 2038 problem, when the seconds don't fit in a 32 bit int -anymore. This depends on the compiler, libraries and operating system. -Specifically, time_t and the ctime() function are used. And the time_t is -stored in four bytes in the swap file. But that's only used for printing a -file date/time for recovery, it will never affect normal editing. -The Vim strftime() function directly uses the strftime() system function. -localtime() uses the time() system function. getftime() uses the time -returned by the stat() system function. If your system libraries are year -2000 compliant, Vim is too. +Neovim development is funded separately from Vim: -The user may create scripts for Vim that use external commands. These might -introduce Y2K problems, but those are not really part of Vim itself. + https://neovim.io/#sponsor ============================================================================== -3. Credits *credits* *author* *Bram* *Moolenaar* +Credits *credits* *author* *Bram* *Moolenaar* Most of Vim was written by Bram Moolenaar <Bram@vim.org>. @@ -273,7 +206,7 @@ Elvis Another Vi clone, made by Steve Kirkendall. Very compact but isn't freely available. ============================================================================== -4. Notation *notation* +Notation *notation* When syntax highlighting is used to read this, text that is not typed literally is often highlighted with the Special group. These are items in [], @@ -494,7 +427,7 @@ examples and use them directly. Or type them literally, including the '<' and ":autocmd"! ============================================================================== -5. Modes, introduction *vim-modes-intro* *vim-modes* +Modes, introduction *vim-modes-intro* *vim-modes* Vim has seven BASIC modes: @@ -579,7 +512,7 @@ Insert Select mode Entered when starting Select mode from Insert mode. is shown at the bottom of the window. ============================================================================== -6. Switching from mode to mode *mode-switching* +Switching from mode to mode *mode-switching* If for any reason you do not know which mode you are in, you can always get back to Normal mode by typing <Esc> twice. This doesn't work for Ex mode @@ -650,7 +583,7 @@ Q or gQ Switch to Ex mode. This is like typing ":" commands Use the ":vi" command |:visual| to exit this mode. ============================================================================== -7. The window contents *window-contents* +The window contents *window-contents* In Normal mode and Insert/Replace mode the screen window will show the current contents of the buffer: What You See Is What You Get. There are two @@ -769,18 +702,15 @@ window. You may make the window as small as you like, but if it gets too small not a single line will fit in it. Make it at least 40 characters wide to be able to read most messages on the last line. -On most Unix systems, resizing the window is recognized and handled correctly -by Vim. - ============================================================================== -8. Definitions *definitions* +Definitions *definitions* *jargon* - buffer Contains lines of text, usually read from a file. - screen The whole area that Vim uses to work in. This can be - a terminal emulator window. Also called "the Vim - window". + buffer Contains lines of text, usually from a file. + screen The whole area that Nvim uses to display things. window A view on a buffer. There can be multiple windows for one buffer. + frame Windows are kept in a tree of frames. Each frame + contains a column, row, or window ("leaf" frame). A screen contains one or more windows, separated by status lines and with the command line at the bottom. @@ -813,7 +743,7 @@ A difference is made between four types of lines: lines with wrapping, line breaks, etc. applied. They can only be as long as the width of the window allows, longer lines are wrapped or truncated. - screen lines The lines of the screen that Vim uses. Consists of + screen lines The lines of the screen that Nvim uses. Consists of the window lines of all windows, with status lines and the command line added. They can only be as long as the width of the screen allows. When the command @@ -837,5 +767,27 @@ buffer lines logical lines window lines screen lines ~ 5. ddd 13. (command line) 6. ~ + +API client ~ +All external UIs and remote plugins (as opposed to regular Vim plugins) are +"clients" in general; but we call something an "API client" if its purpose is +to abstract or wrap the RPC API for the convenience of other applications +(just like a REST client or SDK such as boto3 for AWS: you can speak AWS REST +using an HTTP client like curl, but boto3 wraps that in a convenient python +interface). For example, the Nvim lua-client is an API client: + https://github.com/neovim/lua-client + + +Host ~ +A plugin "host" is both a client (of the Nvim API) and a server (of an +external platform, e.g. python). It is a remote plugin that hosts other +plugins. + + +Remote plugin ~ +Arbitrary code registered via |:UpdateRemotePlugins|, that runs in a separate +process and communicates with Nvim via the |api|. + + ============================================================================== vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 30e7f644b3..fa5e10b5e5 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -286,6 +286,9 @@ current mode (instead of always going to normal-mode). Visual-mode is preserved, so tricks with |gv| are not needed. Commands can be invoked directly in cmdline-mode (which otherwise would require timer hacks). +Because <Cmd> avoids mode-changes (unlike ":") it does not trigger +|CmdlineEnter| and |CmdlineLeave| events. This helps performance. + Unlike <expr> mappings, there are no special restrictions on the <Cmd> command: it is executed as if an (unrestricted) |autocmd| was invoked or an async event event was processed. diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index d52905fc36..a46648119e 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -514,15 +514,6 @@ command. The script can then again read another script. This can continue for about 14 levels. When more nesting is done, Vim assumes that there is a recursive loop somewhere and stops with this error message. - *E319* > - The command is not available in this version - -You have used a command that is not present in the version of Vim you are -using. When compiling Vim, many different features can be enabled or -disabled. This depends on how big Vim has chosen to be and the operating -system. See |+feature-list| for when which feature is available. The -|:version| command shows which feature Vim was compiled with. - *E300* > Swap file already exists (symlink attack?) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 7cf3aa1d60..9aaae6a527 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -703,47 +703,24 @@ A jump table for the options with a short description can be found at |Q_op|. been set. *'background'* *'bg'* -'background' 'bg' string (default "dark" or "light", see below) - global - When set to "dark", Vim will try to use colors that look good on a - dark background. When set to "light", Vim will try to use colors that - look good on a light background. Any other value is illegal. - Vim tries to set the default value according to the terminal used. - This will not always be correct. - Setting this option does not change the background color, it tells Vim - what the background color looks like. For changing the background - color, see |:hi-normal|. - - When 'background' is set Vim will adjust the default color groups for - the new value. But the colors used for syntax highlighting will not - change. *g:colors_name* +'background' 'bg' string (default "dark") + global + When set to "dark" or "light", Nvim will adjust the default color + groups for a dark or light background, respectively. + + This option does NOT change the background color, it tells Nvim what + the "inherited" (terminal/GUI) background looks like. + See |:hi-normal| if you want to set the background color explicitly. + *g:colors_name* When a color scheme is loaded (the "g:colors_name" variable is set) setting 'background' will cause the color scheme to be reloaded. If the color scheme adjusts to the value of 'background' this will work. However, if the color scheme sets 'background' itself the effect may be undone. First delete the "g:colors_name" variable when needed. - When setting 'background' to the default value with: > - :set background& -< Vim will guess the value. In the GUI this should work correctly, - in other cases Vim might not be able to guess the right value. - - When starting the GUI, the default value for 'background' will be - "light". When the value is not set in the gvimrc, and Vim detects - that the background is actually quite dark, 'background' is set to - "dark". But this happens only AFTER the gvimrc file has been read - (because the window needs to be opened to find the actual background - color). To get around this, force the GUI window to be opened by - putting a ":gui" command in the gvimrc file, before where the value - of 'background' is used (e.g., before ":syntax on"). - - For Windows the default is "dark". "dark" should be used if $COLORFGBG - suggests a dark background (not yet implemented). Otherwise the default - is "light". - Normally this option would be set in the vimrc file. Possibly depending on the terminal name. Example: > - :if $TERM == "xterm" + :if $TERM ==# "xterm" : set background=dark :endif < When this option is set, the default settings for the highlight groups @@ -1485,7 +1462,7 @@ A jump table for the options with a short description can be found at |Q_op|. global When 'confirm' is on, certain operations that would normally fail because of unsaved changes to a buffer, e.g. ":q" and ":e", - instead raise a |dialog| asking if you wish to save the current + instead raise a dialog asking if you wish to save the current file(s). You can still use a ! to unconditionally |abandon| a buffer. If 'confirm' is off you can still activate confirmation for one command only (this is most useful in mappings) with the |:confirm| @@ -1882,13 +1859,13 @@ A jump table for the options with a short description can be found at |Q_op|. *'dex'* *'diffexpr'* 'diffexpr' 'dex' string (default "") global - Expression which is evaluated to obtain an ed-style diff file from two - versions of a file. See |diff-diffexpr|. + Expression which is evaluated to obtain a diff file (either ed-style + or unified-style) from two versions of a file. See |diff-diffexpr|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. *'dip'* *'diffopt'* -'diffopt' 'dip' string (default "filler") +'diffopt' 'dip' string (default "internal,filler") global Option settings for diff mode. It can consist of the following items. All are optional. Items must be separated by a comma. @@ -1948,11 +1925,31 @@ A jump table for the options with a short description can be found at |Q_op|. foldcolumn:{n} Set the 'foldcolumn' option to {n} when starting diff mode. Without this 2 is used. - Examples: > + internal Use the internal diff library. This is + ignored when 'diffexpr' is set. *E960* + When running out of memory when writing a + buffer this item will be ignored for diffs + involving that buffer. Set the 'verbose' + option to see when this happens. + + indent-heuristic + Use the indent heuristic for the internal + diff library. + + algorithm:{text} Use the specified diff algorithm with the + internal diff engine. Currently supported + algorithms are: + myers the default algorithm + minimal spend extra time to generate the + smallest possible diff + patience patience diff algorithm + histogram histogram diff algorithm - :set diffopt=filler,context:4 + Examples: > + :set diffopt=internal,filler,context:4 :set diffopt= - :set diffopt=filler,foldcolumn:3 + :set diffopt=internal,filler,foldcolumn:3 + :set diffopt-=internal " do NOT use the internal diff parser < *'digraph'* *'dg'* *'nodigraph'* *'nodg'* 'digraph' 'dg' boolean (default off) @@ -2803,8 +2800,7 @@ A jump table for the options with a short description can be found at |Q_op|. :set guifont=* < will bring up a font requester, where you can pick the font you want. - The font name depends on the GUI used. See |setting-guifont| for a - way to set 'guifont' for various systems. + The font name depends on the GUI used. For Mac OSX you can use something like this: > :set guifont=Monaco:h10 @@ -6586,8 +6582,7 @@ A jump table for the options with a short description can be found at |Q_op|. menu. This conflicts with the use of the ALT key for mappings and entering special characters. This option tells what to do: no Don't use ALT keys for menus. ALT key combinations can be - mapped, but there is no automatic handling. This can then be - done with the |:simalt| command. + mapped, but there is no automatic handling. yes ALT key handling is done by the windowing system. ALT key combinations cannot be mapped. menu Using ALT in combination with a character that is a menu diff --git a/runtime/doc/pi_msgpack.txt b/runtime/doc/pi_msgpack.txt index 2484a13878..951b897f55 100644 --- a/runtime/doc/pi_msgpack.txt +++ b/runtime/doc/pi_msgpack.txt @@ -1,4 +1,4 @@ -*pi_msgpack.txt* Nvim +*pi_msgpack.txt* msgpack utilities Author: Nikolay Pavlov <kp-pav@yandex.ru> Copyright: (c) 2015 by Nikolay Pavlov diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index 0e26dc4515..6ed3c230b9 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -4,14 +4,21 @@ NVIM REFERENCE MANUAL by Thiago de Arruda -Providers *provider* +Providers *provider* -Nvim delegates some features to dynamic "providers". +Nvim delegates some features to dynamic "providers". This document describes +the providers and how to install them. + *E319* +Use of a feature requiring a missing provider is an error: > + + E319: No "foo" provider found. Run ":checkhealth provider" + +Run the |:checkhealth| command, and review the sections below. Type |gO| to see the table of contents. ============================================================================== -Python integration *provider-python* +Python integration *provider-python* Nvim supports Python |remote-plugin|s and the Vim legacy |python2| and |python3| interfaces (which are implemented as remote-plugins). @@ -19,23 +26,23 @@ Note: Only the Vim 7.3 API is supported; bindeval (Vim 7.4) is not. PYTHON QUICKSTART ~ -Install the "neovim" Python package: +Install the "pynvim" Python package: - Run |:checkhealth| to see if you already have the package (some package - managers install the "neovim" Python package with Nvim itself). + managers install the "pynvim" Python package with Nvim itself). - For Python 2 plugins, make sure Python 2.7 is available in your $PATH, then install the package systemwide: > - sudo pip2 install --upgrade neovim + sudo pip2 install --upgrade pynvim < or for the current user: > - pip2 install --user --upgrade neovim + pip2 install --user --upgrade pynvim < If "pip2" is missing, try "pip". - For Python 3 plugins, make sure Python 3.4+ is available in your $PATH, then install the package systemwide: > - sudo pip3 install --upgrade neovim + sudo pip3 install --upgrade pynvim < or for the current user: > - pip3 install --user --upgrade neovim + pip3 install --user --upgrade pynvim < If "pip3" is missing, try "pip". - The `--upgrade` flag ensures you have the latest version even if a previous @@ -64,14 +71,14 @@ PYTHON VIRTUALENVS ~ If you plan to use per-project virtualenvs often, you should assign one virtualenv for Neovim and hard-code the interpreter path via -|g:python3_host_prog| (or |g:python_host_prog|) so that the "neovim" package +|g:python3_host_prog| (or |g:python_host_prog|) so that the "pynvim" package is not required for each virtualenv. Example using pyenv: > pyenv install 3.4.4 pyenv virtualenv 3.4.4 py3nvim pyenv activate py3nvim - pip install neovim + pip install pynvim pyenv which python # Note the path The last command reports the interpreter path, add it to your init.vim: > let g:python3_host_prog = '/path/to/py3nvim/bin/python' @@ -150,16 +157,19 @@ The presence of a working clipboard tool implicitly enables the '+' and '*' registers. Nvim looks for these clipboard tools, in order of priority: - |g:clipboard| - - pbcopy/pbpaste (macOS) - - xsel (if $DISPLAY is set) + - pbcopy, pbpaste (macOS) + - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) - xclip (if $DISPLAY is set) + - xsel (if $DISPLAY is set) - lemonade (for SSH) https://github.com/pocke/lemonade - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ - win32yank (Windows) - tmux (if $TMUX is set) *g:clipboard* -To configure a custom clipboard tool, set `g:clipboard` to a dictionary: > +To configure a custom clipboard tool, set g:clipboard to a dictionary. +For example this configuration integrates the tmux clipboard: > + let g:clipboard = { \ 'name': 'myClipboard', \ 'copy': { @@ -173,9 +183,28 @@ To configure a custom clipboard tool, set `g:clipboard` to a dictionary: > \ 'cache_enabled': 1, \ } -If `cache_enabled` is |TRUE| then when a selection is copied, Nvim will cache +If "cache_enabled" is |TRUE| then when a selection is copied Nvim will cache the selection until the copy command process dies. When pasting, if the copy -process has not died, the cached selection is applied. +process has not died the cached selection is applied. + +g:clipboard can also use functions (see |lambda|) instead of strings. +For example this configuration uses the g:foo variable as a fake clipboard: > + + let g:clipboard = { + \ 'name': 'myClipboard', + \ 'copy': { + \ '+': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) }, + \ '*': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) }, + \ }, + \ 'paste': { + \ '+': {-> get(g:, 'foo', [])}, + \ '*': {-> get(g:, 'foo', [])}, + \ }, + \ } + +The "copy" function stores a list of lines and the register type. The "paste" +function returns the clipboard as a `[lines, regtype]` list, where `lines` is +a list of lines and `regtype` is a register type conforming to |setreg()|. ============================================================================== X11 selection mechanism *clipboard-x11* *x11-selection* diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt index 142d7b492a..6c2ceb45be 100644 --- a/runtime/doc/remote.txt +++ b/runtime/doc/remote.txt @@ -167,11 +167,6 @@ a client and send strings to other instances of Vim on the same X11 display. When an X11 GUI Vim (gvim) is started, it will try to register a send-server name on the 'VimRegistry' property on the root window. -A non GUI Vim with access to the X11 display (|xterm-clipboard| enabled), can -also act as a command server if a server name is explicitly given with the ---servername argument, or when Vim was build with the |+autoservername| -feature. - An empty --servername argument will cause the command server to be disabled. To send commands to a Vim server from another application, read the source diff --git a/runtime/doc/remote_plugin.txt b/runtime/doc/remote_plugin.txt index eeb9cf8150..6a9874660b 100644 --- a/runtime/doc/remote_plugin.txt +++ b/runtime/doc/remote_plugin.txt @@ -42,15 +42,15 @@ what a Python plugin looks like. This plugin exports a command, a function, and an autocmd. The plugin is called 'Limit', and all it does is limit the number of requests made to it. Here's the plugin source code: > - import neovim + import pynvim - @neovim.plugin + @pynvim.plugin class Limit(object): def __init__(self, vim): self.vim = vim self.calls = 0 - @neovim.command('Cmd', range='', nargs='*', sync=True) + @pynvim.command('Cmd', range='', nargs='*', sync=True) def command_handler(self, args, range): self._increment_calls() self.vim.current.line = ( @@ -58,14 +58,14 @@ of requests made to it. Here's the plugin source code: args, range)) - @neovim.autocmd('BufEnter', pattern='*.py', eval='expand("<afile>")', + @pynvim.autocmd('BufEnter', pattern='*.py', eval='expand("<afile>")', sync=True) def autocmd_handler(self, filename): self._increment_calls() self.vim.current.line = ( 'Autocmd: Called %s times, file: %s' % (self.calls, filename)) - @neovim.function('Func') + @pynvim.function('Func') def function_handler(self, args): self._increment_calls() self.vim.current.line = ( diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 82a8c4c5cc..23ae3458ea 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -305,6 +305,9 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. first sourced. The number is used for the script ID |<SID>|. +:scr[iptnames][!] {scriptId} *:script* + Edit script {scriptId}. Suggested name is ":script". + *:fini* *:finish* *E168* :fini[sh] Stop sourcing a script. Can only be used in a Vim script file. This is a quick way to skip the rest of diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt index a26c0a3ac9..273d2b984c 100644 --- a/runtime/doc/sign.txt +++ b/runtime/doc/sign.txt @@ -79,7 +79,6 @@ DEFINING A SIGN. *:sign-define* *E255* *E160* *E612* will cause redraw problems. toolkit supports ~ Win32 .bmp, .ico, .cur - pixmap (.xpm) |+xpm_w32| linehl={group} Highlighting group used for the whole line the sign is placed diff --git a/runtime/doc/sponsor.txt b/runtime/doc/sponsor.txt deleted file mode 100644 index cb6bdad358..0000000000 --- a/runtime/doc/sponsor.txt +++ /dev/null @@ -1,216 +0,0 @@ -*sponsor.txt* Nvim - - - VIM REFERENCE MANUAL by Bram Moolenaar - - - -SPONSOR VIM DEVELOPMENT *sponsor* - -Fixing bugs and adding new features takes a lot of time and effort. To show -your appreciation for the work and motivate Bram and others to continue -working on Vim please send a donation. - -Since Bram is back to a paid job the money will now be used to help children -in Uganda. See |uganda|. But at the same time donations increase Bram's -motivation to keep working on Vim! - -For the most recent information about sponsoring look on the Vim web site: - - http://www.vim.org/sponsor/ - -More explanations can be found in the |sponsor-faq|. - - -REGISTERED VIM USER *register* - -You can become a registered Vim user by sending at least 10 euro. This works -similar to sponsoring Vim, see |sponsor| above. Registration was made -possible for the situation where your boss or bookkeeper may be willing to -register software, but does not like the terms "sponsoring" and "donation". - -More explanations can be found in the |register-faq|. - - -VOTE FOR FEATURES *vote-for-features* - -To give registered Vim users and sponsors an advantage over lurkers they can -vote for the items Bram should work on. How does this voting work? - -1. You send at least 10 euro. See below for ways to transfer money - |send-money|. - -2. You will be e-mailed a registration key. Enter this key on your account - page on the Vim website. You can easily create an account if you don't - have one yet. - -3. You can enter your votes on the voting page. There is a link to that page - on your account page after entering a registration key. Your votes will - be counted for two years. - -4. The voting results appear on the results page, which is visible for - everybody: http://www.vim.org/sponsor/vote_results.php - -Additionally, once you have sent 100 euro or more in total, your name appears -in the "Vim hall of honour": http://www.vim.org/sponsor/hall_of_honour.php -But only if you enable this on your account page. - - -HOW TO SEND MONEY *send-money* - -Credit card Through PayPal, see the PayPal site for information: - https://www.paypal.com/en_US/mrb/pal=XAC62PML3GF8Q - The e-mail address for sending sponsorship money is: - donate@vim.org - The e-mail address for Vim registration is: - register@vim.org - Using Euro is preferred, other currencies are also accepted. - In Euro countries a bank transfer is preferred, this has lower - costs. - -Other methods See |iccf-donations|. - Include "Vim sponsor" or "Vim registration" in the comment of - your money transfer. Send me an e-mail that mentions the - amount you transferred if you want to vote for features and - show others you are a registered Vim user or sponsor. - -Cash Small amounts can be sent with ordinary mail. Put something - around the money, so that it's not noticeable from the - outside. Mention your e-mail address if you want to vote for - features and show others you are a registered Vim user or - sponsor. - -You can use this permanent address: - Bram Moolenaar - Finsterruetihof 1 - 8134 Adliswil - Switzerland - - - -QUESTIONS AND ANSWERS *sponsor-faq* *register-faq* - -Why should I give money? - -If you do not show your appreciation for Vim then Bram will be less motivated -to fix bugs and add new features. He will do something else instead. - - -How much money should I send? - -That is up to you. The more you give, the more children will be helped. -An indication for individuals that use Vim at home: 10 Euro per year. For -professional use: 30 Euro per year per person. Send at least 10 euro to be -able to vote for features. - - -What do I get in return? - -Each registered Vim user and sponsor who donates at least 10 euro will be able -to vote for new features. These votes will give priority to the work on Vim. -The votes are valid for two years. The more money you send the more your -votes count |votes-counted|. - -If you send 100 Euro or more in total you will be mentioned on the "Vim hall -of honour" page on the Vim web site. But only if you enable this on your -account page. You can also select whether the amount will be visible. - - -How do I become a Vim sponsor or registered Vim user? - -Send money, as explained above |send-money| and include your e-mail address. -When the money has been received you will receive a unique registration key. -This key can be used on the Vim website to activate voting on your Vim -account. You will then get an extra page where you can vote for features and -choose whether others will be able to see that you donated. There is a link -to this page on your "My Account" page. - - -What is the difference between sponsoring and registering? - -It has a different name. Use the term "registration" if your boss doesn't -like "sponsoring" or "donation". The benefits are the same. - - -How can I send money? - -See |send-money|. Check the web site for the most recent information: -http://www.vim.org/sponsor/ - - -Why don't you use the SourceForge donation system? - -SourceForge takes 5% of the donations for themselves. If you want to support -SourceForge you can send money to them directly. - - -I cannot afford to send money, may I still use Vim? - -Yes. - - -I did not register Vim, can I use all available features? - -Yes. - - -I noticed a bug, do I need to register before I can report it? - -No, suggestions for improving Vim can always be given. For improvements use -the developer |maillist|, for reporting bugs see |bugs|. - - -How are my votes counted? *votes-counted* - -You may vote when you send 10 euro or more. You can enter up to ten votes. -You can select the same item several times to give it more points. You can -also enter three counter votes, these count as negative points. - -When you send 30 euro or more the points are doubled. Above 100 euro they -count four times, above 300 euro they count six times, above 1000 euro ten -times. - - -Can I change my votes? - -You can change your votes any time you like, up to two years after you -sent money. The points will be counted right away. - - -Can I add an item to vote on? - -Not directly. You can suggest items to vote on to Bram. He will consider -fitting your item into the list. - - -How about Charityware? - -Currently the Vim donations go to |uganda| anyway. Thus it doesn't matter if -you sponsor Vim or ICCF. Except that Vim sponsoring will allow you to vote -for features. - - -I donated $$$, now please add feature XYZ! - -There is no direct relation between your donation and the work Bram does. -Otherwise you would be paying for work and we would have to pay tax over the -donation. If you want to hire Bram for specific work, contact him directly, -don't use the donation system. - - -Are the donations tax deductible? - -That depends on your country. The donations to help the children in |Uganda| -are tax deductible in Holland, Germany, Canada and in the USA. See the ICCF -website http://iccf-holland.org/donate.html. You must send an e-mail to Bram -to let him know that the donation is done because of the use of Vim. - - -Can you send me a bill? - -No, because there is no relation between the money you send and the work that -is done. But a receipt is possible. - - - - vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 1da2441929..82e73035d8 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -410,20 +410,17 @@ accordingly. Vim proceeds in this order: 3. Execute Ex commands, from environment variables and/or files An environment variable is read as one Ex command line, where multiple - commands must be separated with '|' or "<NL>". - *init.vim* *vimrc* *exrc* - A file that contains initialization commands is called a "vimrc" file. - Each line in a vimrc file is executed as an Ex command line. It is - sometimes also referred to as "exrc" file. They are the same type of - file, but "exrc" is what Vi always used, "vimrc" is a Vim specific - name, "init.vim" is Neovim specific location for vimrc file. Also see - |vimrc-intro|. - - Places for your personal initializations (see |base-directories|): - Unix $XDG_CONFIG_HOME/nvim/init.vim - (default for $XDG_CONFIG_HOME is ~/.config) - Windows $XDG_CONFIG_HOME/nvim/init.vim - (default for $XDG_CONFIG_HOME is ~/AppData/Local) + commands must be separated with '|' or <NL>. + *config* *init.vim* *vimrc* *exrc* + A file that contains initialization commands is generically called + a "vimrc" or config file. Each line in a vimrc file is executed as an + Ex command line. See also |vimrc-intro| and |base-directories|. + + The Nvim config file is named "init.vim", located at: + Unix ~/.config/nvim/init.vim + Windows ~/AppData/Local/nvim/init.vim + Or if |$XDG_CONFIG_HOME| is defined: + $XDG_CONFIG_HOME/nvim/init.vim RECOMMENDATION: Put all your Vim configuration stuff in the $HOME/.config/nvim/ directory. That makes it easy to copy it to @@ -439,10 +436,11 @@ accordingly. Vim proceeds in this order: If Vim was started in Ex mode with the "-s" argument, all following initializations until 4. are skipped. Only the "-u" option is interpreted. - *system-vimrc* - a. For Unix, MS-Windows, and Macintosh, the system vimrc file is read for - initializations. The path of this file is shown with the - ":version" command. Mostly it's "$VIM/vimrc". + *system-vimrc* *sysinit.vim* + a. The system vimrc file is read for initializations. If + nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be + used. Otherwise, the system vimrc file is used. The path of this file + is shown with the ":version" command. Mostly it's "$VIM/sysinit.vim". *VIMINIT* *EXINIT* *$MYVIMRC* b. Four places are searched for initializations. The first that exists diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index a0f1b0770e..c021f236c8 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -167,7 +167,7 @@ the editor. mouse support is active. Some options like 'ambiwidth' have already taken effect on the grid, where appropriate empty cells are added, however a UI might still use such options when rendering raw text - sent from Nvim, like for |ui-ext-cmdline|. + sent from Nvim, like for |ui-cmdline|. ["mode_change", mode, mode_idx] The mode changed. The first parameter `mode` is a string representing @@ -325,14 +325,14 @@ numerical highlight `id`:s to the actual attributes. +-------------------------+ src_top | | src (moved up) and dst | | |-------------------------| dst_bot | - | src (cleared) | | + | src (invalid) | | +=========================+ src_bot < If `rows` is less than zero, move a rectangle in the SR down, this can happen while scrolling up. > +=========================+ src_top - | src (cleared) | | + | src (invalid) | | |------------------------ | dst_top | | src (moved down) and dst| | +-------------------------+ src_bot | @@ -348,6 +348,10 @@ numerical highlight `id`:s to the actual attributes. end-exclusive, which is consistent with API conventions, but different from `set_scroll_region` which was end-inclusive. + The scrolled-in area will be filled using |ui-event-grid_line| directly + after the scroll event. The UI thus doesn't need to clear this area as + part of handling the scroll event. + ============================================================================== Legacy Grid Events (cell based) *ui-grid-old* diff --git a/runtime/doc/usr_01.txt b/runtime/doc/usr_01.txt index f96043c409..3deaf181e5 100644 --- a/runtime/doc/usr_01.txt +++ b/runtime/doc/usr_01.txt @@ -68,9 +68,9 @@ For more info see |vimrc|. ============================================================================== *01.3* Using the Vim tutor *tutor* *vimtutor* -Instead of reading the text (boring!) you can use the vimtutor to learn your -first Vim commands. This is a 30 minute tutorial that teaches the most basic -Vim functionality hands-on. +Instead of reading the text (boring!) you can use :Tutor to learn your first +Vim commands. This is a 30 minute tutorial that teaches the most basic Vim +functionality hands-on. To start the tutorial, execute > diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 38e858801b..af17d75656 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -321,7 +321,7 @@ Where can you find plugins? - Some come with Vim. You can find them in the directory $VIMRUNTIME/macros and its sub-directories and under $VIM/vimfiles/pack/dist/opt/. - Download from the net. There is a large collection on http://www.vim.org. -- They are sometimes posted in a Vim |maillist|. +- They are sometimes posted in a Vim maillist. - You could write one yourself, see |write-plugin|. diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt index ae2aae7596..be33f0be6d 100644 --- a/runtime/doc/usr_45.txt +++ b/runtime/doc/usr_45.txt @@ -203,8 +203,7 @@ USING UNICODE IN A UNICODE TERMINAL There are terminals that support Unicode directly. The standard xterm that comes with XFree86 is one of them. Let's use that as an example. - First of all, the xterm must have been compiled with Unicode support. See -|UTF8-xterm| how to check that and how to compile it when needed. + First of all, the xterm must have been compiled with Unicode support. Start the xterm with the "-u8" argument. You might also need so specify a font. Example: > diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 11ee8f8ca9..d78dd90f18 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -381,7 +381,7 @@ T *+tag_binary* binary searching in tags file |tag-binary-search| N *+tag_old_static* old method for static tags |tag-old-static| m *+tag_any_white* any white space allowed in tags file |tag-any-white| B *+termguicolors* 24-bit color in xterm-compatible terminals support -N *+termresponse* support for |t_RV| and |v:termresponse| +N *+termresponse* support for t_RV and |v:termresponse| N *+textobjects* |text-objects| selection N *+timers* the |timer_start()| function N *+title* Setting the window 'title' and 'icon' @@ -517,14 +517,9 @@ m *+xim* X input method |xim| :silent! /^begin :if v:errmsg != "" : ... pattern was not found -< ":silent" will also avoid the hit-enter prompt. When - using this for an external command, this may cause the - screen to be messed up. Use |CTRL-L| to clean it up - then. - ":silent menu ..." defines a menu that will not echo a - Command-line command. The command will still produce - messages though. Use ":silent" in the command itself - to avoid that: ":silent menu .... :silent command". +< ":silent" also skips the hit-enter prompt. + Dialogs that prompt for user input (|confirm()|, + 'swapfile', …) are never silent. *:uns* *:unsilent* :uns[ilent] {command} Execute {command} not silently. Only makes a diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 4fbfb0d7a0..3915763eed 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -27,6 +27,7 @@ a complete and centralized reference of those differences. - 'autoindent' is set by default - 'autoread' is set by default +- 'background' always defaults to "dark" - 'backspace' defaults to "indent,eol,start" - 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|) - 'belloff' defaults to "all" diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index b0fbe9cc35..1da8ed85fc 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -1,3 +1,5 @@ +require('vim.compat') + local buf_hls = {} local function highlight_line(line, linenr) @@ -10,9 +12,9 @@ local function highlight_line(line, linenr) local attr = NONE local byte = 0 -- byte offset - local function end_attr_hl(attr) + local function end_attr_hl(attr_) for i, hl in ipairs(hls) do - if hl.attr == attr and hl.final == -1 then + if hl.attr == attr_ and hl.final == -1 then hl.final = byte hls[i] = hl end @@ -106,7 +108,7 @@ local function highlight_line(line, linenr) -- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117) local sgr = prev_char:match("^%[([\032-\063]*)m$") if sgr then - local match = '' + local match while sgr and #sgr > 0 do -- Match against SGR parameters, which may be separated by ';' match, sgr = sgr:match("^(%d*);?(.*)") diff --git a/runtime/lua/vim/compat.lua b/runtime/lua/vim/compat.lua new file mode 100644 index 0000000000..168979bb95 --- /dev/null +++ b/runtime/lua/vim/compat.lua @@ -0,0 +1,12 @@ +-- Lua 5.1 forward-compatibility layer. +-- For background see https://github.com/neovim/neovim/pull/9280 +-- +-- Reference the lua-compat-5.2 project for hints: +-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/compat52/mstrict.lua +-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/tests/test.lua + +local lua_version = _VERSION:sub(-3) + +if lua_version >= "5.2" then + unpack = table.unpack -- luacheck: ignore 121 143 +end diff --git a/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim b/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim new file mode 100644 index 0000000000..7a6464fc98 --- /dev/null +++ b/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim @@ -0,0 +1,43 @@ +" cfilter.vim: Plugin to filter entries from a quickfix/location list +" Last Change: May 12, 2018 +" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) +" Version: 1.0 +" +" Commands to filter the quickfix list: +" :Cfilter[!] {pat} +" Create a new quickfix list from entries matching {pat} in the current +" quickfix list. Both the file name and the text of the entries are +" matched against {pat}. If ! is supplied, then entries not matching +" {pat} are used. +" :Lfilter[!] {pat} +" Same as :Cfilter but operates on the current location list. +" +if exists("loaded_cfilter") + finish +endif +let loaded_cfilter = 1 + +func s:Qf_filter(qf, pat, bang) + if a:qf + let Xgetlist = function('getqflist') + let Xsetlist = function('setqflist') + let cmd = ':Cfilter' . a:bang + else + let Xgetlist = function('getloclist', [0]) + let Xsetlist = function('setloclist', [0]) + let cmd = ':Lfilter' . a:bang + endif + + if a:bang == '!' + let cond = 'v:val.text !~# a:pat && bufname(v:val.bufnr) !~# a:pat' + else + let cond = 'v:val.text =~# a:pat || bufname(v:val.bufnr) =~# a:pat' + endif + + let items = filter(Xgetlist(), cond) + let title = cmd . ' ' . a:pat + call Xsetlist([], ' ', {'title' : title, 'items' : items}) +endfunc + +com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>) +com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>) diff --git a/runtime/plugin/README.txt b/runtime/plugin/README.txt deleted file mode 100644 index 37e22e57c0..0000000000 --- a/runtime/plugin/README.txt +++ /dev/null @@ -1,19 +0,0 @@ -The plugin directory is for standard Vim plugin scripts. - -All files here ending in .vim will be sourced by Vim when it starts up. -Look in the file for hints on how it can be disabled without deleting it. - -getscriptPlugin.vim get latest version of Vim scripts -gzip.vim edit compressed files -matchparen.vim highlight paren matching the one under the cursor -netrwPlugin.vim edit files over a network and browse (remote) directories -rrhelper.vim used for --remote-wait editing -spellfile.vim download a spellfile when it's missing -tarPlugin.vim edit (compressed) tar files -tohtml.vim convert a file with syntax highlighting to HTML -vimballPlugin.vim create and unpack .vba files -zipPlugin.vim edit zip archives - -Note: the explorer.vim plugin is no longer here, the netrw.vim plugin has -taken over browsing directories (also for remote directories). - diff --git a/runtime/plugin/matchit.vim b/runtime/plugin/matchit.vim index e3171e5cbb..c160522f90 100644 --- a/runtime/plugin/matchit.vim +++ b/runtime/plugin/matchit.vim @@ -1,5 +1,5 @@ " matchit.vim: (global plugin) Extended "%" matching -" Last Change: 2017 Sep 15 +" Last Change: 2018 Jul 3 by Christian Brabandt " Maintainer: Benji Fisher PhD <benji@member.AMS.org> " Version: 1.13.3, for Vim 6.3+ " Fix from Tommy Allen included. @@ -268,7 +268,7 @@ function! s:Match_wrapper(word, forward, mode) range " execute "normal!" . curcol . "l" " endif if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) - let skip = "0" + let skip = '0' else execute "if " . skip . "| let skip = '0' | endif" endif @@ -708,10 +708,16 @@ fun! s:MultiMatch(spflag, mode) let openpat = substitute(openpat, ',', '\\|', 'g') let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g') let closepat = substitute(closepat, ',', '\\|', 'g') + if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) let skip = '0' else - execute "if " . skip . "| let skip = '0' | endif" + try + execute "if " . skip . "| let skip = '0' | endif" + catch /^Vim\%((\a\+)\)\=:E363/ + " We won't find anything, so skip searching, should keep Vim responsive. + return {} + endtry endif mark ' let level = v:count1 diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 23d4beea87..65b9fe57bf 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2018 Jun 23 +" Last Change: 2018 Jul 3 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -103,18 +103,28 @@ function! s:Highlight_Matching_Pair() call cursor(c_lnum, c_col - before) endif - " Build an expression that detects whether the current cursor position is in - " certain syntax types (string, comment, etc.), for use as searchpairpos()'s - " skip argument. - " We match "escape" for special items, such as lispEscapeSpecial. - let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . + if !has("syntax") || !exists("g:syntax_on") + let s_skip = "0" + else + " Build an expression that detects whether the current cursor position is + " in certain syntax types (string, comment, etc.), for use as + " searchpairpos()'s skip argument. + " We match "escape" for special items, such as lispEscapeSpecial. + let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))' - " If executing the expression determines that the cursor is currently in - " one of the syntax types, then we want searchpairpos() to find the pair - " within those syntax types (i.e., not skip). Otherwise, the cursor is - " outside of the syntax types and s_skip should keep its value so we skip any - " matching pair inside the syntax types. - execute 'if' s_skip '| let s_skip = 0 | endif' + " If executing the expression determines that the cursor is currently in + " one of the syntax types, then we want searchpairpos() to find the pair + " within those syntax types (i.e., not skip). Otherwise, the cursor is + " outside of the syntax types and s_skip should keep its value so we skip + " any matching pair inside the syntax types. + " Catch if this throws E363: pattern uses more memory than 'maxmempattern'. + try + execute 'if ' . s_skip . ' | let s_skip = "0" | endif' + catch /^Vim\%((\a\+)\)\=:E363/ + " We won't find anything, so skip searching, should keep Vim responsive. + return + endtry + endif " Limit the search to lines visible in the window. let stoplinebottom = line('w$') diff --git a/runtime/plugin/rrhelper.vim b/runtime/plugin/rrhelper.vim deleted file mode 100644 index b09cbc10b9..0000000000 --- a/runtime/plugin/rrhelper.vim +++ /dev/null @@ -1,48 +0,0 @@ -" Vim plugin with helper function(s) for --remote-wait -" Maintainer: Flemming Madsen <fma@cci.dk> -" Last Change: 2008 May 29 - -" Has this already been loaded? -if exists("loaded_rrhelper") || !has("clientserver") - finish -endif -let loaded_rrhelper = 1 - -" Setup answers for a --remote-wait client who will assume -" a SetupRemoteReplies() function in the command server - -function SetupRemoteReplies() - let cnt = 0 - let max = argc() - - let id = expand("<client>") - if id == 0 - return - endif - while cnt < max - " Handle same file from more clients and file being more than once - " on the command line by encoding this stuff in the group name - let uniqueGroup = "RemoteReply_".id."_".cnt - - " Path separators are always forward slashes for the autocommand pattern. - " Escape special characters with a backslash. - let f = substitute(argv(cnt), '\\', '/', "g") - if exists('*fnameescape') - let f = fnameescape(f) - else - let f = escape(f, " \t\n*?[{`$\\%#'\"|!<") - endif - execute "augroup ".uniqueGroup - execute "autocmd ".uniqueGroup." BufUnload ". f ." call DoRemoteReply('".id."', '".cnt."', '".uniqueGroup."', '". f ."')" - let cnt = cnt + 1 - endwhile - augroup END -endfunc - -function DoRemoteReply(id, cnt, group, file) - call server2client(a:id, a:cnt) - execute 'autocmd! '.a:group.' BufUnload '.a:file - execute 'augroup! '.a:group -endfunc - -" vim: set sw=2 sts=2 : |