diff options
24 files changed, 726 insertions, 604 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index e8270123d7..fffd668919 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1445,12 +1445,11 @@ Lua module: vim.lsp.buf *lsp-buf* vim.lsp.buf.definition({ on_list = on_list }) vim.lsp.buf.references(nil, { on_list = on_list }) < - - If you prefer loclist instead of qflist: >lua + • {loclist}? (`boolean`) Whether to use the |location-list| or the + |quickfix| list. >lua vim.lsp.buf.definition({ loclist = true }) - vim.lsp.buf.references(nil, { loclist = true }) + vim.lsp.buf.references(nil, { loclist = false }) < - • {loclist}? (`boolean`) *vim.lsp.LocationOpts* Extends: |vim.lsp.ListOpts| @@ -1553,7 +1552,7 @@ document_highlight() *vim.lsp.buf.document_highlight()* |hl-LspReferenceWrite| document_symbol({opts}) *vim.lsp.buf.document_symbol()* - Lists all symbols in the current buffer in the quickfix window. + Lists all symbols in the current buffer in the |location-list|. Parameters: ~ • {opts} (`vim.lsp.ListOpts?`) See |vim.lsp.ListOpts|. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index ef97957d22..58dab586d9 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -26,6 +26,9 @@ LSP • `lsp/` runtimepath files should return a table instead of calling |vim.lsp.config()| (or assigning to `vim.lsp.config`). See |lsp-config| +• `vim.lsp.buf.document_symbol()` uses the |location-list| by default. Use + `vim.lsp.buf.document_symbol({ loclist = false })` to use the |quickfix| + list. OPTIONS @@ -316,6 +319,8 @@ PLUGINS • EditorConfig • spelling_language property is now supported. +• 'inccommand' incremental preview can run on 'nomodifiable' buffers and + restores their 'modifiable' state STARTUP diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 83fa2c5a17..3d76c8c0ff 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -1502,6 +1502,9 @@ analysis on a tree should use a timer to throttle too frequent updates. LanguageTree:children() *LanguageTree:children()* Returns a map of language to child tree. + Return: ~ + (`table<string,vim.treesitter.LanguageTree>`) + LanguageTree:contains({range}) *LanguageTree:contains()* Determines whether {range} is contained in the |LanguageTree|. @@ -1566,6 +1569,9 @@ LanguageTree:is_valid({exclude_children}) *LanguageTree:is_valid()* LanguageTree:lang() *LanguageTree:lang()* Gets the language of this tree node. + Return: ~ + (`string`) + *LanguageTree:language_for_range()* LanguageTree:language_for_range({range}) Gets the appropriate language that contains {range}. @@ -1614,6 +1620,12 @@ LanguageTree:node_for_range({range}, {opts}) Return: ~ (`TSNode?`) +LanguageTree:parent() *LanguageTree:parent()* + Returns the parent tree. `nil` for the root tree. + + Return: ~ + (`vim.treesitter.LanguageTree?`) + LanguageTree:parse({range}, {on_parse}) *LanguageTree:parse()* Recursively parse all regions in the language tree using |treesitter-parsers| for the corresponding languages and run injection @@ -1674,6 +1686,9 @@ LanguageTree:register_cbs({cbs}, {recursive}) LanguageTree:source() *LanguageTree:source()* Returns the source content of the language tree (bufnr or string). + Return: ~ + (`integer|string`) + *LanguageTree:tree_for_range()* LanguageTree:tree_for_range({range}, {opts}) Gets the tree that contains {range}. diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 30a9951f6a..31c88c80bd 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1527,7 +1527,6 @@ local function sh(path, contents, name) vim.b[b].is_kornshell = nil vim.b[b].is_sh = nil end - return M.shell(path, contents, 'bash'), on_detect -- Ubuntu links sh to dash elseif matchregex(name, [[\<\(sh\|dash\)\>]]) then on_detect = function(b) diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 0acbc50003..8efc6996dd 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -252,13 +252,13 @@ end --- vim.lsp.buf.definition({ on_list = on_list }) --- vim.lsp.buf.references(nil, { on_list = on_list }) --- ``` +--- @field on_list? fun(t: vim.lsp.LocationOpts.OnList) --- ---- If you prefer loclist instead of qflist: +--- Whether to use the |location-list| or the |quickfix| list. --- ```lua --- vim.lsp.buf.definition({ loclist = true }) ---- vim.lsp.buf.references(nil, { loclist = true }) +--- vim.lsp.buf.references(nil, { loclist = false }) --- ``` ---- @field on_list? fun(t: vim.lsp.LocationOpts.OnList) --- @field loclist? boolean --- @class vim.lsp.LocationOpts.OnList @@ -796,9 +796,10 @@ function M.references(context, opts) end end ---- Lists all symbols in the current buffer in the quickfix window. +--- Lists all symbols in the current buffer in the |location-list|. --- @param opts? vim.lsp.ListOpts function M.document_symbol(opts) + opts = vim.tbl_deep_extend('keep', opts or {}, { loclist = true }) local params = { textDocument = util.make_text_document_params() } request_with_opts(ms.textDocument_documentSymbol, params, opts) end diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index 3c7d1f1469..bdf31d8514 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -231,6 +231,9 @@ end ---@param prefix string ---@return boolean local function match_item_by_value(value, prefix) + if prefix == '' then + return true + end if vim.o.completeopt:find('fuzzy') ~= nil then return next(vim.fn.matchfuzzy({ value }, prefix)) ~= nil end @@ -612,6 +615,12 @@ local function on_complete_done() end end +---@param bufnr integer +---@return string +local function get_augroup(bufnr) + return string.format('nvim.lsp.completion_%d', bufnr) +end + --- @class vim.lsp.completion.BufferOpts --- @field autotrigger? boolean Default: false When true, completion triggers automatically based on the server's `triggerCharacters`. --- @field convert? fun(item: lsp.CompletionItem): table Transforms an LSP CompletionItem to |complete-items|. @@ -636,8 +645,7 @@ local function enable_completions(client_id, bufnr, opts) }) -- Set up autocommands. - local group = - api.nvim_create_augroup(string.format('nvim.lsp.completion_%d', bufnr), { clear = true }) + local group = api.nvim_create_augroup(get_augroup(bufnr), { clear = true }) api.nvim_create_autocmd('CompleteDone', { group = group, buffer = bufnr, @@ -705,7 +713,7 @@ local function disable_completions(client_id, bufnr) handle.clients[client_id] = nil if not next(handle.clients) then buf_handles[bufnr] = nil - api.nvim_del_augroup_by_name(string.format('vim/lsp/completion-%d', bufnr)) + api.nvim_del_augroup_by_name(get_augroup(bufnr)) else for char, clients in pairs(handle.triggers) do --- @param c vim.lsp.Client diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 4e0adf3366..b9b53d36a8 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1568,8 +1568,6 @@ function M.open_floating_preview(contents, syntax, opts) if do_stylize then local width = M._make_floating_popup_size(contents, opts) contents = M._normalize_markdown(contents, { width = width }) - vim.bo[floating_bufnr].filetype = 'markdown' - vim.treesitter.start(floating_bufnr) else -- Clean up input: trim empty lines contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true }) @@ -1635,9 +1633,6 @@ function M.open_floating_preview(contents, syntax, opts) }) end - if do_stylize then - vim.wo[floating_winnr].conceallevel = 2 - end vim.wo[floating_winnr].foldenable = false -- Disable folding. vim.wo[floating_winnr].wrap = opts.wrap -- Soft wrapping. vim.wo[floating_winnr].breakindent = true -- Slightly better list presentation. @@ -1646,6 +1641,12 @@ function M.open_floating_preview(contents, syntax, opts) vim.bo[floating_bufnr].modifiable = false vim.bo[floating_bufnr].bufhidden = 'wipe' + if do_stylize then + vim.wo[floating_winnr].conceallevel = 2 + vim.bo[floating_bufnr].filetype = 'markdown' + vim.treesitter.start(floating_bufnr) + end + return floating_bufnr, floating_winnr end diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 945a2301a9..3db7fe5c9e 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -267,6 +267,7 @@ function LanguageTree:trees() end --- Gets the language of this tree node. +--- @return string function LanguageTree:lang() return self._lang end @@ -307,11 +308,13 @@ function LanguageTree:is_valid(exclude_children) end --- Returns a map of language to child tree. +--- @return table<string,vim.treesitter.LanguageTree> function LanguageTree:children() return self._children end --- Returns the source content of the language tree (bufnr or string). +--- @return integer|string function LanguageTree:source() return self._source end @@ -450,8 +453,8 @@ function LanguageTree:_run_async_callbacks(range, err, trees) for _, cb in ipairs(self._cb_queues[key]) do cb(err, trees) end - self._ranges_being_parsed[key] = false - self._cb_queues[key] = {} + self._ranges_being_parsed[key] = nil + self._cb_queues[key] = nil end --- Run an asynchronous parse, calling {on_parse} when complete. @@ -630,7 +633,8 @@ function LanguageTree:add_child(lang) return self._children[lang] end ---- @package +---Returns the parent tree. `nil` for the root tree. +---@return vim.treesitter.LanguageTree? function LanguageTree:parent() return self._parent end diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim index d3f60bb8dc..ae794954ce 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim @@ -35,7 +35,7 @@ if exists("s:needspatches") endfor endif -let g:loaded_netrw = "v174" +let g:loaded_netrw = "v175" let s:keepcpo= &cpo setl cpo&vim diff --git a/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim b/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim index fd43c16c4e..884d9ce081 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim @@ -1,7 +1,7 @@ " Maintainer: Luca Saccarola <github.e41mv@aleeas.com> " Former Maintainer: Charles E Campbell " Upstream: <https://github.com/saccarosium/netrw.vim> -" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{1 +" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{ " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, @@ -9,13 +9,13 @@ " warranty of any kind, either expressed or implied. By using " this plugin, you agree that in no event will the copyright " holder be liable for any damages resulting from the use -" of this software. +" of this software. }}} -" Load Once: {{{1 -if exists("g:loaded_netrwSettings") || &cp - finish +if &cp || exists("g:loaded_netrwSettings") + finish endif -let g:loaded_netrwSettings = "v174" + +let g:loaded_netrwSettings = "v175" if v:version < 700 echohl WarningMsg echo "***warning*** this version of netrwSettings needs vim 7.0" @@ -23,220 +23,220 @@ if v:version < 700 finish endif -" --------------------------------------------------------------------- -" NetrwSettings: {{{1 -fun! netrwSettings#NetrwSettings() - " this call is here largely just to insure that netrw has been loaded - call netrw#WinPath("") - if !exists("g:loaded_netrw") - echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None - return - endif - - above wincmd s - enew - setlocal noswapfile bh=wipe - set ft=vim - file Netrw\ Settings - - " these variables have the following default effects when they don't - " exist (ie. have not been set by the user in his/her .vimrc) - if !exists("g:netrw_liststyle") - let g:netrw_liststyle= 0 - let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" - endif - if !exists("g:netrw_silent") - let g:netrw_silent= 0 - endif - if !exists("g:netrw_use_nt_rcp") - let g:netrw_use_nt_rcp= 0 - endif - if !exists("g:netrw_ftp") - let g:netrw_ftp= 0 - endif - if !exists("g:netrw_ignorenetrc") - let g:netrw_ignorenetrc= 0 - endif - - put ='+ ---------------------------------------------' - put ='+ NetrwSettings: by Charles E. Campbell' - put ='+ Press <F1> with cursor atop any line for help' - put ='+ ---------------------------------------------' - let s:netrw_settings_stop= line(".") - - put ='' - put ='+ Netrw Protocol Commands' - put = 'let g:netrw_dav_cmd = '.g:netrw_dav_cmd - put = 'let g:netrw_fetch_cmd = '.g:netrw_fetch_cmd - put = 'let g:netrw_ftp_cmd = '.g:netrw_ftp_cmd - put = 'let g:netrw_http_cmd = '.g:netrw_http_cmd - put = 'let g:netrw_rcp_cmd = '.g:netrw_rcp_cmd - put = 'let g:netrw_rsync_cmd = '.g:netrw_rsync_cmd - put = 'let g:netrw_scp_cmd = '.g:netrw_scp_cmd - put = 'let g:netrw_sftp_cmd = '.g:netrw_sftp_cmd - put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd - let s:netrw_protocol_stop= line(".") - put = '' - - put ='+Netrw Transfer Control' - put = 'let g:netrw_cygwin = '.g:netrw_cygwin - put = 'let g:netrw_ftp = '.g:netrw_ftp - put = 'let g:netrw_ftpmode = '.g:netrw_ftpmode - put = 'let g:netrw_ignorenetrc = '.g:netrw_ignorenetrc - put = 'let g:netrw_sshport = '.g:netrw_sshport - put = 'let g:netrw_silent = '.g:netrw_silent - put = 'let g:netrw_use_nt_rcp = '.g:netrw_use_nt_rcp - let s:netrw_xfer_stop= line(".") - put ='' - put ='+ Netrw Messages' - put ='let g:netrw_use_errorwindow = '.g:netrw_use_errorwindow - - put = '' - put ='+ Netrw Browser Control' - if exists("g:netrw_altfile") - put = 'let g:netrw_altfile = '.g:netrw_altfile - else - put = 'let g:netrw_altfile = 0' - endif - put = 'let g:netrw_alto = '.g:netrw_alto - put = 'let g:netrw_altv = '.g:netrw_altv - put = 'let g:netrw_banner = '.g:netrw_banner - if exists("g:netrw_bannerbackslash") - put = 'let g:netrw_bannerbackslash = '.g:netrw_bannerbackslash - else - put = '\" let g:netrw_bannerbackslash = (not defined)' - endif - put = 'let g:netrw_browse_split = '.g:netrw_browse_split - if exists("g:netrw_browsex_viewer") - put = 'let g:netrw_browsex_viewer = '.g:netrw_browsex_viewer - else - put = '\" let g:netrw_browsex_viewer = (not defined)' - endif - put = 'let g:netrw_compress = '.g:netrw_compress - if exists("g:Netrw_corehandler") - put = 'let g:Netrw_corehandler = '.g:Netrw_corehandler - else - put = '\" let g:Netrw_corehandler = (not defined)' - endif - put = 'let g:netrw_ctags = '.g:netrw_ctags - put = 'let g:netrw_cursor = '.g:netrw_cursor - let decompressline= line("$") - put = 'let g:netrw_decompress = '.string(g:netrw_decompress) - if exists("g:netrw_dynamic_maxfilenamelen") - put = 'let g:netrw_dynamic_maxfilenamelen='.g:netrw_dynamic_maxfilenamelen - else - put = '\" let g:netrw_dynamic_maxfilenamelen= (not defined)' - endif - put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax - put = 'let g:netrw_errorlvl = '.g:netrw_errorlvl - put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse - let fnameescline= line("$") - put = 'let g:netrw_fname_escape = '.string(g:netrw_fname_escape) - put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject - put = 'let g:netrw_ftp_list_cmd = '.g:netrw_ftp_list_cmd - put = 'let g:netrw_ftp_sizelist_cmd = '.g:netrw_ftp_sizelist_cmd - put = 'let g:netrw_ftp_timelist_cmd = '.g:netrw_ftp_timelist_cmd - let globescline= line("$") - put = 'let g:netrw_glob_escape = '.string(g:netrw_glob_escape) - put = 'let g:netrw_hide = '.g:netrw_hide - if exists("g:netrw_home") - put = 'let g:netrw_home = '.g:netrw_home - else - put = '\" let g:netrw_home = (not defined)' - endif - put = 'let g:netrw_keepdir = '.g:netrw_keepdir - put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd - put = 'let g:netrw_list_hide = '.g:netrw_list_hide - put = 'let g:netrw_liststyle = '.g:netrw_liststyle - put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd - put = 'let g:netrw_localcopycmdopt = '.g:netrw_localcopycmdopt - put = 'let g:netrw_localmkdir = '.g:netrw_localmkdir - put = 'let g:netrw_localmkdiropt = '.g:netrw_localmkdiropt - put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd - put = 'let g:netrw_localmovecmdopt = '.g:netrw_localmovecmdopt - put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen - put = 'let g:netrw_menu = '.g:netrw_menu - put = 'let g:netrw_mousemaps = '.g:netrw_mousemaps - put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd - if exists("g:netrw_nobeval") - put = 'let g:netrw_nobeval = '.g:netrw_nobeval - else - put = '\" let g:netrw_nobeval = (not defined)' - endif - put = 'let g:netrw_remote_mkdir = '.g:netrw_remote_mkdir - put = 'let g:netrw_preview = '.g:netrw_preview - put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd - put = 'let g:netrw_retmap = '.g:netrw_retmap - put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd - put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd - put = 'let g:netrw_rmf_cmd = '.g:netrw_rmf_cmd - put = 'let g:netrw_sort_by = '.g:netrw_sort_by - put = 'let g:netrw_sort_direction = '.g:netrw_sort_direction - put = 'let g:netrw_sort_options = '.g:netrw_sort_options - put = 'let g:netrw_sort_sequence = '.g:netrw_sort_sequence - put = 'let g:netrw_servername = '.g:netrw_servername - put = 'let g:netrw_special_syntax = '.g:netrw_special_syntax - put = 'let g:netrw_ssh_browse_reject = '.g:netrw_ssh_browse_reject - put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd - put = 'let g:netrw_scpport = '.g:netrw_scpport - put = 'let g:netrw_sepchr = '.g:netrw_sepchr - put = 'let g:netrw_sshport = '.g:netrw_sshport - put = 'let g:netrw_timefmt = '.g:netrw_timefmt - let tmpfileescline= line("$") - put ='let g:netrw_tmpfile_escape...' - put = 'let g:netrw_use_noswf = '.g:netrw_use_noswf - put = 'let g:netrw_xstrlen = '.g:netrw_xstrlen - put = 'let g:netrw_winsize = '.g:netrw_winsize - - put ='' - put ='+ For help, place cursor on line and press <F1>' - - 1d - silent %s/^+/"/e - res 99 - silent %s/= \([^0-9].*\)$/= '\1'/e - silent %s/= $/= ''/e - 1 - - call setline(decompressline,"let g:netrw_decompress = ".substitute(string(g:netrw_decompress),"^'\\(.*\\)'$",'\1','')) - call setline(fnameescline, "let g:netrw_fname_escape = '".escape(g:netrw_fname_escape,"'")."'") - call setline(globescline, "let g:netrw_glob_escape = '".escape(g:netrw_glob_escape,"'")."'") - call setline(tmpfileescline,"let g:netrw_tmpfile_escape = '".escape(g:netrw_tmpfile_escape,"'")."'") - - set nomod - - nmap <buffer> <silent> <F1> :call NetrwSettingHelp()<cr> - nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call NetrwSettingHelp()<cr> - let tmpfile= tempname() - exe 'au BufWriteCmd Netrw\ Settings silent w! '.tmpfile.'|so '.tmpfile.'|call delete("'.tmpfile.'")|set nomod' -endfun - -" --------------------------------------------------------------------- -" NetrwSettingHelp: {{{2 -fun! NetrwSettingHelp() -" call Dfunc("NetrwSettingHelp()") - let curline = getline(".") - if curline =~ '=' - let varhelp = substitute(curline,'^\s*let ','','e') - let varhelp = substitute(varhelp,'\s*=.*$','','e') -" call Decho("trying help ".varhelp) - try - exe "he ".varhelp - catch /^Vim\%((\a\+)\)\=:E149/ - echo "***sorry*** no help available for <".varhelp.">" - endtry - elseif line(".") < s:netrw_settings_stop - he netrw-settings - elseif line(".") < s:netrw_protocol_stop - he netrw-externapp - elseif line(".") < s:netrw_xfer_stop - he netrw-variables - else - he netrw-browse-var - endif -" call Dret("NetrwSettingHelp") -endfun - -" --------------------------------------------------------------------- -" Modelines: {{{1 -" vim:ts=8 fdm=marker +" NetrwSettings: {{{ + +function! netrwSettings#NetrwSettings() + " this call is here largely just to insure that netrw has been loaded + call netrw#WinPath("") + if !exists("g:loaded_netrw") + echohl WarningMsg + echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" + echohl None + return + endif + + above wincmd s + enew + setlocal noswapfile bh=wipe + set ft=vim + file Netrw\ Settings + + " these variables have the following default effects when they don't + " exist (ie. have not been set by the user in his/her .vimrc) + if !exists("g:netrw_liststyle") + let g:netrw_liststyle= 0 + let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" + endif + if !exists("g:netrw_silent") + let g:netrw_silent= 0 + endif + if !exists("g:netrw_use_nt_rcp") + let g:netrw_use_nt_rcp= 0 + endif + if !exists("g:netrw_ftp") + let g:netrw_ftp= 0 + endif + if !exists("g:netrw_ignorenetrc") + let g:netrw_ignorenetrc= 0 + endif + + put ='+ ---------------------------------------------' + put ='+ NetrwSettings: by Charles E. Campbell' + put ='+ Press <F1> with cursor atop any line for help' + put ='+ ---------------------------------------------' + let s:netrw_settings_stop= line(".") + + put ='' + put ='+ Netrw Protocol Commands' + put = 'let g:netrw_dav_cmd = '.g:netrw_dav_cmd + put = 'let g:netrw_fetch_cmd = '.g:netrw_fetch_cmd + put = 'let g:netrw_ftp_cmd = '.g:netrw_ftp_cmd + put = 'let g:netrw_http_cmd = '.g:netrw_http_cmd + put = 'let g:netrw_rcp_cmd = '.g:netrw_rcp_cmd + put = 'let g:netrw_rsync_cmd = '.g:netrw_rsync_cmd + put = 'let g:netrw_scp_cmd = '.g:netrw_scp_cmd + put = 'let g:netrw_sftp_cmd = '.g:netrw_sftp_cmd + put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd + let s:netrw_protocol_stop= line(".") + put = '' + + put ='+Netrw Transfer Control' + put = 'let g:netrw_cygwin = '.g:netrw_cygwin + put = 'let g:netrw_ftp = '.g:netrw_ftp + put = 'let g:netrw_ftpmode = '.g:netrw_ftpmode + put = 'let g:netrw_ignorenetrc = '.g:netrw_ignorenetrc + put = 'let g:netrw_sshport = '.g:netrw_sshport + put = 'let g:netrw_silent = '.g:netrw_silent + put = 'let g:netrw_use_nt_rcp = '.g:netrw_use_nt_rcp + let s:netrw_xfer_stop= line(".") + put ='' + put ='+ Netrw Messages' + put ='let g:netrw_use_errorwindow = '.g:netrw_use_errorwindow + + put = '' + put ='+ Netrw Browser Control' + if exists("g:netrw_altfile") + put = 'let g:netrw_altfile = '.g:netrw_altfile + else + put = 'let g:netrw_altfile = 0' + endif + put = 'let g:netrw_alto = '.g:netrw_alto + put = 'let g:netrw_altv = '.g:netrw_altv + put = 'let g:netrw_banner = '.g:netrw_banner + if exists("g:netrw_bannerbackslash") + put = 'let g:netrw_bannerbackslash = '.g:netrw_bannerbackslash + else + put = '\" let g:netrw_bannerbackslash = (not defined)' + endif + put = 'let g:netrw_browse_split = '.g:netrw_browse_split + if exists("g:netrw_browsex_viewer") + put = 'let g:netrw_browsex_viewer = '.g:netrw_browsex_viewer + else + put = '\" let g:netrw_browsex_viewer = (not defined)' + endif + put = 'let g:netrw_compress = '.g:netrw_compress + if exists("g:Netrw_corehandler") + put = 'let g:Netrw_corehandler = '.g:Netrw_corehandler + else + put = '\" let g:Netrw_corehandler = (not defined)' + endif + put = 'let g:netrw_ctags = '.g:netrw_ctags + put = 'let g:netrw_cursor = '.g:netrw_cursor + let decompressline= line("$") + put = 'let g:netrw_decompress = '.string(g:netrw_decompress) + if exists("g:netrw_dynamic_maxfilenamelen") + put = 'let g:netrw_dynamic_maxfilenamelen='.g:netrw_dynamic_maxfilenamelen + else + put = '\" let g:netrw_dynamic_maxfilenamelen= (not defined)' + endif + put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax + put = 'let g:netrw_errorlvl = '.g:netrw_errorlvl + put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse + let fnameescline= line("$") + put = 'let g:netrw_fname_escape = '.string(g:netrw_fname_escape) + put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject + put = 'let g:netrw_ftp_list_cmd = '.g:netrw_ftp_list_cmd + put = 'let g:netrw_ftp_sizelist_cmd = '.g:netrw_ftp_sizelist_cmd + put = 'let g:netrw_ftp_timelist_cmd = '.g:netrw_ftp_timelist_cmd + let globescline= line("$") + put = 'let g:netrw_glob_escape = '.string(g:netrw_glob_escape) + put = 'let g:netrw_hide = '.g:netrw_hide + if exists("g:netrw_home") + put = 'let g:netrw_home = '.g:netrw_home + else + put = '\" let g:netrw_home = (not defined)' + endif + put = 'let g:netrw_keepdir = '.g:netrw_keepdir + put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd + put = 'let g:netrw_list_hide = '.g:netrw_list_hide + put = 'let g:netrw_liststyle = '.g:netrw_liststyle + put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd + put = 'let g:netrw_localcopycmdopt = '.g:netrw_localcopycmdopt + put = 'let g:netrw_localmkdir = '.g:netrw_localmkdir + put = 'let g:netrw_localmkdiropt = '.g:netrw_localmkdiropt + put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd + put = 'let g:netrw_localmovecmdopt = '.g:netrw_localmovecmdopt + put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen + put = 'let g:netrw_menu = '.g:netrw_menu + put = 'let g:netrw_mousemaps = '.g:netrw_mousemaps + put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd + if exists("g:netrw_nobeval") + put = 'let g:netrw_nobeval = '.g:netrw_nobeval + else + put = '\" let g:netrw_nobeval = (not defined)' + endif + put = 'let g:netrw_remote_mkdir = '.g:netrw_remote_mkdir + put = 'let g:netrw_preview = '.g:netrw_preview + put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd + put = 'let g:netrw_retmap = '.g:netrw_retmap + put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd + put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd + put = 'let g:netrw_rmf_cmd = '.g:netrw_rmf_cmd + put = 'let g:netrw_sort_by = '.g:netrw_sort_by + put = 'let g:netrw_sort_direction = '.g:netrw_sort_direction + put = 'let g:netrw_sort_options = '.g:netrw_sort_options + put = 'let g:netrw_sort_sequence = '.g:netrw_sort_sequence + put = 'let g:netrw_servername = '.g:netrw_servername + put = 'let g:netrw_special_syntax = '.g:netrw_special_syntax + put = 'let g:netrw_ssh_browse_reject = '.g:netrw_ssh_browse_reject + put = 'let g:netrw_ssh_cmd = '.g:netrw_ssh_cmd + put = 'let g:netrw_scpport = '.g:netrw_scpport + put = 'let g:netrw_sepchr = '.g:netrw_sepchr + put = 'let g:netrw_sshport = '.g:netrw_sshport + put = 'let g:netrw_timefmt = '.g:netrw_timefmt + let tmpfileescline= line("$") + put ='let g:netrw_tmpfile_escape...' + put = 'let g:netrw_use_noswf = '.g:netrw_use_noswf + put = 'let g:netrw_xstrlen = '.g:netrw_xstrlen + put = 'let g:netrw_winsize = '.g:netrw_winsize + + put ='' + put ='+ For help, place cursor on line and press <F1>' + + 1d + silent %s/^+/"/e + res 99 + silent %s/= \([^0-9].*\)$/= '\1'/e + silent %s/= $/= ''/e + 1 + + call setline(decompressline, "let g:netrw_decompress = ".substitute(string(g:netrw_decompress),"^'\\(.*\\)'$",'\1','')) + call setline(fnameescline, "let g:netrw_fname_escape = '".escape(g:netrw_fname_escape,"'")."'") + call setline(globescline, "let g:netrw_glob_escape = '".escape(g:netrw_glob_escape,"'")."'") + call setline(tmpfileescline, "let g:netrw_tmpfile_escape = '".escape(g:netrw_tmpfile_escape,"'")."'") + + set nomod + + nmap <buffer> <silent> <F1> :call NetrwSettingHelp()<cr> + nnoremap <buffer> <silent> <leftmouse> <leftmouse> :call NetrwSettingHelp()<cr> + let tmpfile= tempname() + exe 'au BufWriteCmd Netrw\ Settings silent w! '.tmpfile.'|so '.tmpfile.'|call delete("'.tmpfile.'")|set nomod' +endfunction + +" }}} +" NetrwSettingHelp: {{{ + +function! NetrwSettingHelp() + let curline = getline(".") + if curline =~ '=' + let varhelp = substitute(curline,'^\s*let ','','e') + let varhelp = substitute(varhelp,'\s*=.*$','','e') + try + exe "he ".varhelp + catch /^Vim\%((\a\+)\)\=:E149/ + echo "***sorry*** no help available for <".varhelp.">" + endtry + elseif line(".") < s:netrw_settings_stop + he netrw-settings + elseif line(".") < s:netrw_protocol_stop + he netrw-externapp + elseif line(".") < s:netrw_xfer_stop + he netrw-variables + else + he netrw-browse-var + endif +endfunction + +" }}} + +" vim:ts=8 sts=4 sw=4 et fdm=marker diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw_gitignore.vim b/runtime/pack/dist/opt/netrw/autoload/netrw_gitignore.vim index 6c1d8582b8..c76d28db04 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw_gitignore.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw_gitignore.vim @@ -12,7 +12,7 @@ " let g:netrw_list_hide = netrw_gitignore#Hide() " let g:netrw_list_hide = netrw_gitignore#Hide() . 'more,hide,patterns' " -" Copyright: Copyright (C) 2013 Bruno Sutic {{{1 +" Copyright: Copyright (C) 2013 Bruno Sutic {{{ " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, @@ -20,7 +20,10 @@ " warranty of any kind, either expressed or implied. By using " this plugin, you agree that in no event will the copyright " holder be liable for any damages resulting from the use -" of this software. +" of this software. }}} + function! netrw_gitignore#Hide(...) - return substitute(substitute(system('git ls-files --other --ignored --exclude-standard --directory'), '\n', ',', 'g'), ',$', '', '') + return substitute(substitute(system('git ls-files --other --ignored --exclude-standard --directory'), '\n', ',', 'g'), ',$', '', '') endfunction + +" vim:ts=8 sts=4 sw=4 et fdm=marker diff --git a/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim b/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim index ddf4234aa2..8d10c00153 100644 --- a/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim +++ b/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim @@ -1,7 +1,7 @@ " Maintainer: Luca Saccarola <github.e41mv@aleeas.com> " Former Maintainer: Charles E Campbell " Upstream: <https://github.com/saccarosium/netrw.vim> -" Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1 +" Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{ " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, @@ -9,214 +9,206 @@ " *as is* and comes with no warranty of any kind, either " expressed or implied. By using this plugin, you agree that " in no event will the copyright holder be liable for any damages -" resulting from the use of this software. +" resulting from the use of this software. }}} -" Load Once: {{{1 if &cp || exists("g:loaded_netrwPlugin") - finish + finish endif -let g:loaded_netrwPlugin = "v174" + +let g:loaded_netrwPlugin = "v175" + let s:keepcpo = &cpo set cpo&vim -"DechoRemOn -" --------------------------------------------------------------------- -" Public Interface: {{{1 +" Commands Launch/URL: {{{ + +command -complete=shellcmd -nargs=1 Launch call netrw#Launch(trim(<q-args>)) +command -complete=file -nargs=1 Open call netrw#Open(trim(<q-args>)) + +" }}} +" Local Browsing Autocmds: {{{ -" Commands Launch/URL {{{2 -command -complete=shellcmd -nargs=1 Launch call netrw#Launch(trim(<q-args>)) -command -complete=file -nargs=1 Open call netrw#Open(trim(<q-args>)) -" " }}} -" Local Browsing Autocmds: {{{2 augroup FileExplorer - au! - au BufLeave * if &ft != "netrw"|let w:netrw_prvfile= expand("%:p")|endif - au BufEnter * sil call s:LocalBrowse(expand("<amatch>")) - au VimEnter * sil call s:VimEnter(expand("<amatch>")) - if has("win32") - au BufEnter .* sil call s:LocalBrowse(expand("<amatch>")) - endif + au! + au BufLeave * if &ft != "netrw"|let w:netrw_prvfile= expand("%:p")|endif + au BufEnter * sil call s:LocalBrowse(expand("<amatch>")) + au VimEnter * sil call s:VimEnter(expand("<amatch>")) + if has("win32") + au BufEnter .* sil call s:LocalBrowse(expand("<amatch>")) + endif augroup END -" Network Browsing Reading Writing: {{{2 +" }}} +" Network Browsing Reading Writing: {{{ + augroup Network - au! - au BufReadCmd file://* call netrw#FileUrlEdit(expand("<amatch>")) - au BufReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "sil doau BufReadPost ".fnameescape(expand("<amatch>")) - au FileReadCmd ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(1,expand("<amatch>"))|exe "sil doau FileReadPost ".fnameescape(expand("<amatch>")) - au BufWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>")) - au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>")) - try - au SourceCmd ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) - catch /^Vim\%((\a\+)\)\=:E216/ - au SourcePre ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) - endtry + au! + au BufReadCmd file://* call netrw#FileUrlEdit(expand("<amatch>")) + au BufReadCmd ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "sil doau BufReadPost ".fnameescape(expand("<amatch>")) + au FileReadCmd ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(1,expand("<amatch>"))|exe "sil doau FileReadPost ".fnameescape(expand("<amatch>")) + au BufWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>")) + au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://* exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>")) + try + au SourceCmd ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) + catch /^Vim\%((\a\+)\)\=:E216/ + au SourcePre ftp://*,rcp://*,scp://*,http://*,file://*,https://*,dav://*,davs://*,rsync://*,sftp://* exe 'Nsource '.fnameescape(expand("<amatch>")) + endtry augroup END -" Commands: :Nread, :Nwrite, :NetUserPass {{{2 -com! -count=1 -nargs=* Nread let s:svpos= winsaveview()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call winrestview(s:svpos) -com! -range=% -nargs=* Nwrite let s:svpos= winsaveview()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call winrestview(s:svpos) -com! -nargs=* NetUserPass call NetUserPass(<f-args>) -com! -nargs=* Nsource let s:svpos= winsaveview()<bar>call netrw#NetSource(<f-args>)<bar>call winrestview(s:svpos) -com! -nargs=? Ntree call netrw#SetTreetop(1,<q-args>) - -" Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{2 -com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>) -com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>) -com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>) -com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>) -com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>) -com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>) -com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>) -com! -nargs=* -bar -bang -count=0 -complete=dir Lexplore call netrw#Lexplore(<count>,<bang>0,<q-args>) - -" Commands: NetrwSettings {{{2 -com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() -com! -bang NetrwClean call netrw#Clean(<bang>0) - -" Maps: +" }}} +" Commands: :Nread, :Nwrite, :NetUserPass {{{ + +command! -count=1 -nargs=* Nread let s:svpos= winsaveview()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call winrestview(s:svpos) +command! -range=% -nargs=* Nwrite let s:svpos= winsaveview()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call winrestview(s:svpos) +command! -nargs=* NetUserPass call NetUserPass(<f-args>) +command! -nargs=* Nsource let s:svpos= winsaveview()<bar>call netrw#NetSource(<f-args>)<bar>call winrestview(s:svpos) +command! -nargs=? Ntree call netrw#SetTreetop(1,<q-args>) + +" }}} +" Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{ + +command! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>, 0, 0+<bang>0, <q-args>) +command! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>, 1, 0+<bang>0, <q-args>) +command! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>, 1, 2+<bang>0, <q-args>) +command! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>, 1, 4+<bang>0, <q-args>) +command! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>, 0, 6, <q-args>) +command! -nargs=* -bar -bang -count=0 -complete=dir Lexplore call netrw#Lexplore(<count>, <bang>0, <q-args>) +command! -nargs=* -bar -bang Nexplore call netrw#Explore(-1, 0, 0, <q-args>) +command! -nargs=* -bar -bang Pexplore call netrw#Explore(-2, 0, 0, <q-args>) + +" }}} +" Commands: NetrwSettings {{{ + +command! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() +command! -bang NetrwClean call netrw#Clean(<bang>0) + +" }}} +" Maps: {{{ + if !exists("g:netrw_nogx") - if maparg('gx','n') == "" - if !hasmapto('<Plug>NetrwBrowseX') - nmap <unique> gx <Plug>NetrwBrowseX + if maparg('gx','n') == "" + if !hasmapto('<Plug>NetrwBrowseX') + nmap <unique> gx <Plug>NetrwBrowseX + endif + nno <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX()))<cr> endif - nno <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX()))<cr> - endif - if maparg('gx','x') == "" - if !hasmapto('<Plug>NetrwBrowseXVis') - xmap <unique> gx <Plug>NetrwBrowseXVis + if maparg('gx','x') == "" + if !hasmapto('<Plug>NetrwBrowseXVis') + xmap <unique> gx <Plug>NetrwBrowseXVis + endif + xno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr> endif - xno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr> - endif endif + if exists("g:netrw_usetab") && g:netrw_usetab - if maparg('<c-tab>','n') == "" - nmap <unique> <c-tab> <Plug>NetrwShrink - endif - nno <silent> <Plug>NetrwShrink :call netrw#Shrink()<cr> + if maparg('<c-tab>','n') == "" + nmap <unique> <c-tab> <Plug>NetrwShrink + endif + nno <silent> <Plug>NetrwShrink :call netrw#Shrink()<cr> endif -" --------------------------------------------------------------------- -" LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{2 -fun! s:LocalBrowse(dirname) - " Unfortunate interaction -- only DechoMsg debugging calls can be safely used here. - " Otherwise, the BufEnter event gets triggered when attempts to write to - " the DBG buffer are made. - - if !exists("s:vimentered") - " If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will, - " and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined. - " call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered doesn't exist)") - " call Dret("s:LocalBrowse") - return - endif - - " call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered=".s:vimentered.")") - - if has("amiga") - " The check against '' is made for the Amiga, where the empty - " string is the current directory and not checking would break - " things such as the help command. - " call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, amiga)") - if a:dirname != '' && isdirectory(a:dirname) - sil! call netrw#LocalBrowseCheck(a:dirname) - if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt - exe w:netrw_bannercnt - endif - endif +" }}} +" LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{ - elseif isdirectory(a:dirname) - " call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft." (isdirectory, not amiga)") - " call Dredir("LocalBrowse ft last set: ","verbose set ft") - " Jul 13, 2021: for whatever reason, preceding the following call with - " a sil! causes an unbalanced if-endif vim error - call netrw#LocalBrowseCheck(a:dirname) - if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt - exe w:netrw_bannercnt +function! s:LocalBrowse(dirname) + " do not trigger in the terminal + " https://github.com/vim/vim/issues/16463 + if &buftype ==# 'terminal' + return endif - else - " not a directory, ignore it - " call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...") - endif + if !exists("s:vimentered") + " If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will, + " and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined. + return + endif - " call Dret("s:LocalBrowse") -endfun + if has("amiga") + " The check against '' is made for the Amiga, where the empty + " string is the current directory and not checking would break + " things such as the help command. + if a:dirname != '' && isdirectory(a:dirname) + sil! call netrw#LocalBrowseCheck(a:dirname) + if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt + exe w:netrw_bannercnt + endif + endif + elseif isdirectory(a:dirname) + " Jul 13, 2021: for whatever reason, preceding the following call with + " a sil! causes an unbalanced if-endif vim error + call netrw#LocalBrowseCheck(a:dirname) + if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt + exe w:netrw_bannercnt + endif + endif +endfunction -" --------------------------------------------------------------------- -" s:VimEnter: after all vim startup stuff is done, this function is called. {{{2 +" }}} +" s:VimEnter: after all vim startup stuff is done, this function is called. {{{ " Its purpose: to look over all windows and run s:LocalBrowse() on " them, which checks if they're directories and will create a directory " listing when appropriate. " It also sets s:vimentered, letting s:LocalBrowse() know that s:VimEnter() " has already been called. -fun! s:VimEnter(dirname) - " call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">") - if has('nvim') || v:version < 802 - " Johann Höchtl: reported that the call range... line causes an E488: Trailing characters - " error with neovim. I suspect its because neovim hasn't updated with recent - " vim patches. As is, this code will have problems with popup terminals - " instantiated before the VimEnter event runs. - " Ingo Karkat : E488 also in Vim 8.1.1602 - let curwin = winnr() - let s:vimentered = 1 - windo call s:LocalBrowse(expand("%:p")) - exe curwin."wincmd w" - else - " the following complicated expression comes courtesy of lacygoill; largely does the same thing as the windo and - " wincmd which are commented out, but avoids some side effects. Allows popup terminal before VimEnter. - let s:vimentered = 1 - call range(1, winnr('$'))->map({_, v -> win_execute(win_getid(v), 'call expand("%:p")->s:LocalBrowse()')}) - endif - " call Dret("s:VimEnter") -endfun - -" --------------------------------------------------------------------- -" NetrwStatusLine: {{{1 -fun! NetrwStatusLine() - " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".") - if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") - let &stl= s:netrw_explore_stl - if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif - if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif - return "" - else - return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen - endif -endfun - -" ------------------------------------------------------------------------ -" NetUserPass: set username and password for subsequent ftp transfer {{{1 +function! s:VimEnter(dirname) + if has('nvim') || v:version < 802 + " Johann Höchtl: reported that the call range... line causes an E488: Trailing characters + " error with neovim. I suspect its because neovim hasn't updated with recent + " vim patches. As is, this code will have problems with popup terminals + " instantiated before the VimEnter event runs. + " Ingo Karkat : E488 also in Vim 8.1.1602 + let curwin = winnr() + let s:vimentered = 1 + windo call s:LocalBrowse(expand("%:p")) + exe curwin."wincmd w" + else + " the following complicated expression comes courtesy of lacygoill; largely does the same thing as the windo and + " wincmd which are commented out, but avoids some side effects. Allows popup terminal before VimEnter. + let s:vimentered = 1 + call range(1, winnr('$'))->map({_, v -> win_execute(win_getid(v), 'call expand("%:p")->s:LocalBrowse()')}) + endif +endfunction + +" }}} +" NetrwStatusLine: {{{ + +function! NetrwStatusLine() + if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") + let &stl= s:netrw_explore_stl + unlet! w:netrw_explore_bufnr w:netrw_explore_line + return "" + else + return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen + endif +endfunction + +" }}} +" NetUserPass: set username and password for subsequent ftp transfer {{{ " Usage: :call NetUserPass() -- will prompt for userid and password " :call NetUserPass("uid") -- will prompt for password " :call NetUserPass("uid","password") -- sets global userid and password -fun! NetUserPass(...) - - " get/set userid - if a:0 == 0 - " call Dfunc("NetUserPass(a:0<".a:0.">)") - if !exists("g:netrw_uid") || g:netrw_uid == "" - " via prompt - let g:netrw_uid= input('Enter username: ') +function! NetUserPass(...) + " get/set userid + if a:0 == 0 + if !exists("g:netrw_uid") || g:netrw_uid == "" + " via prompt + let g:netrw_uid= input('Enter username: ') + endif + else " from command line + let g:netrw_uid= a:1 + endif + + " get password + if a:0 <= 1 " via prompt + let g:netrw_passwd= inputsecret("Enter Password: ") + else " from command line + let g:netrw_passwd=a:2 endif - else " from command line - " call Dfunc("NetUserPass(a:1<".a:1.">) {") - let g:netrw_uid= a:1 - endif - - " get password - if a:0 <= 1 " via prompt - " call Decho("a:0=".a:0." case <=1:") - let g:netrw_passwd= inputsecret("Enter Password: ") - else " from command line - " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") - let g:netrw_passwd=a:2 - endif - " call Dret("NetUserPass") -endfun - -" ------------------------------------------------------------------------ -" Modelines And Restoration: {{{1 +endfunction + +" }}} + let &cpo= s:keepcpo unlet s:keepcpo -" vim:ts=8 sts=2 sw=2 et fdm=marker + +" vim:ts=8 sts=4 sw=4 et fdm=marker diff --git a/runtime/pack/dist/opt/netrw/syntax/netrw.vim b/runtime/pack/dist/opt/netrw/syntax/netrw.vim index f9b2faba5d..8042854a12 100644 --- a/runtime/pack/dist/opt/netrw/syntax/netrw.vim +++ b/runtime/pack/dist/opt/netrw/syntax/netrw.vim @@ -1,145 +1,149 @@ -Maintainer: Luca Saccarola <github.e41mv@aleeas.com> +" Maintainer: Luca Saccarola <github.e41mv@aleeas.com> " Former Maintainer: Charles E Campbell " Upstream: <https://github.com/saccarosium/netrw.vim> " Language: Netrw Listing Syntax if exists("b:current_syntax") - finish + finish endif -" Directory List Syntax Highlighting: {{{1 -syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion,netrwCopyTgt -syn cluster NetrwTreeGroup contains=netrwDir,netrwSymLink,netrwExe - -syn match netrwPlain "\(\S\+ \)*\S\+" contains=netrwLink,@NoSpell -syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell -syn match netrwDir "\.\{1,2}/" contains=netrwClassify,@NoSpell -syn match netrwDir "\%(\S\+ \)*\S\+/\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell -syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" skipwhite contains=netrwDateSep,@NoSpell nextgroup=netrwTime -syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell -syn match netrwExe "\%(\S\+ \)*\S*[^~]\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell +let b:current_syntax = "netrwlist" + +" Directory List Syntax Highlighting: {{{ + +syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion,netrwCopyTgt +syn cluster NetrwTreeGroup contains=netrwDir,netrwSymLink,netrwExe + +syn match netrwPlain "\(\S\+ \)*\S\+" contains=netrwLink,@NoSpell +syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell +syn match netrwDir "\.\{1,2}/" contains=netrwClassify,@NoSpell +syn match netrwDir "\%(\S\+ \)*\S\+/\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell +syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" skipwhite contains=netrwDateSep,@NoSpell nextgroup=netrwTime +syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell +syn match netrwExe "\%(\S\+ \)*\S*[^~]\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,@NoSpell if has("gui_running") && (&enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4') -syn match netrwTreeBar "^\%([-+|│] \)\+" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup + syn match netrwTreeBar "^\%([-+|│] \)\+" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup else -syn match netrwTreeBar "^\%([-+|] \)\+" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup + syn match netrwTreeBar "^\%([-+|] \)\+" contains=netrwTreeBarSpace nextgroup=@netrwTreeGroup endif -syn match netrwTreeBarSpace " " contained - -syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained -syn match netrwDateSep "/" contained -syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep -syn match netrwTimeSep ":" - -syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup,@NoSpell -syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite contains=@NoSpell nextgroup=netrwHidePat -syn match netrwSlash "/" contained -syn match netrwHidePat "[^,]\+" contained skipwhite contains=@NoSpell nextgroup=netrwHideSep -syn match netrwHideSep "," contained skipwhite nextgroup=netrwHidePat -syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList -syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList -syn match netrwCopyTgt "Copy/Move Tgt:" contained transparent skipwhite nextgroup=netrwList -syn match netrwList ".*$" contained contains=netrwComma,@NoSpell -syn match netrwComma "," contained -syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd,netrwQHTopic,@NoSpell keepend contained -syn match netrwHelpCmd "\S\+\ze:" contained skipwhite contains=@NoSpell nextgroup=netrwCmdSep -syn match netrwQHTopic "([a-zA-Z &]\+)" contained skipwhite -syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote -syn match netrwCmdNote ".\{-}\ze " contained contains=@NoSpell -syn match netrwVersion "(netrw.*)" contained contains=@NoSpell -syn match netrwLink "-->" contained skipwhite - -" ----------------------------- -" Special filetype highlighting {{{1 -" ----------------------------- +syn match netrwTreeBarSpace " " contained + +syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained +syn match netrwDateSep "/" contained +syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep +syn match netrwTimeSep ":" + +syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup,@NoSpell +syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite contains=@NoSpell nextgroup=netrwHidePat +syn match netrwSlash "/" contained +syn match netrwHidePat "[^,]\+" contained skipwhite contains=@NoSpell nextgroup=netrwHideSep +syn match netrwHideSep "," contained skipwhite nextgroup=netrwHidePat +syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList +syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList +syn match netrwCopyTgt "Copy/Move Tgt:" contained transparent skipwhite nextgroup=netrwList +syn match netrwList ".*$" contained contains=netrwComma,@NoSpell +syn match netrwComma "," contained +syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd,netrwQHTopic,@NoSpell keepend contained +syn match netrwHelpCmd "\S\+\ze:" contained skipwhite contains=@NoSpell nextgroup=netrwCmdSep +syn match netrwQHTopic "([a-zA-Z &]\+)" contained skipwhite +syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote +syn match netrwCmdNote ".\{-}\ze " contained contains=@NoSpell +syn match netrwVersion "(netrw.*)" contained contains=@NoSpell +syn match netrwLink "-->" contained skipwhite + +" }}} +" Special filetype highlighting {{{ + if exists("g:netrw_special_syntax") && g:netrw_special_syntax - if exists("+suffixes") && &suffixes != "" - let suflist= join(split(&suffixes,',')) - let suflist= escape(substitute(suflist," ",'\\|','g'),'.~') - exe "syn match netrwSpecFile '\\(\\S\\+ \\)*\\S*\\(".suflist."\\)\\>' contains=netrwTreeBar,@NoSpell" - endif - syn match netrwBak "\(\S\+ \)*\S\+\.bak\>" contains=netrwTreeBar,@NoSpell - syn match netrwCompress "\(\S\+ \)*\S\+\.\%(gz\|bz2\|Z\|zip\)\>" contains=netrwTreeBar,@NoSpell - if has("unix") - syn match netrwCoreDump "\<core\%(\.\d\+\)\=\>" contains=netrwTreeBar,@NoSpell - endif - syn match netrwLex "\(\S\+ \)*\S\+\.\%(l\|lex\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwYacc "\(\S\+ \)*\S\+\.y\>" contains=netrwTreeBar,@NoSpell - syn match netrwData "\(\S\+ \)*\S\+\.dat\>" contains=netrwTreeBar,@NoSpell - syn match netrwDoc "\(\S\+ \)*\S\+\.\%(doc\|txt\|pdf\|ps\|docx\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwHdr "\(\S\+ \)*\S\+\.\%(h\|hpp\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwLib "\(\S\+ \)*\S*\.\%(a\|so\|lib\|dll\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwMakeFile "\<[mM]akefile\>\|\(\S\+ \)*\S\+\.mak\>" contains=netrwTreeBar,@NoSpell - syn match netrwObj "\(\S\+ \)*\S*\.\%(o\|obj\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwPix "\c\(\S\+ \)*\S*\.\%(bmp\|fits\=\|gif\|je\=pg\|pcx\|ppc\|pgm\|png\|ppm\|psd\|rgb\|tif\|xbm\|xcf\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwTags "\<\(ANmenu\|ANtags\)\>" contains=netrwTreeBar,@NoSpell - syn match netrwTags "\<tags\>" contains=netrwTreeBar,@NoSpell - syn match netrwTilde "\(\S\+ \)*\S\+\~\*\=\>" contains=netrwTreeBar,@NoSpell - syn match netrwTmp "\<tmp\(\S\+ \)*\S\+\>\|\(\S\+ \)*\S*tmp\>" contains=netrwTreeBar,@NoSpell + if exists("+suffixes") && &suffixes != "" + let suflist= join(split(&suffixes,',')) + let suflist= escape(substitute(suflist," ",'\\|','g'),'.~') + exe "syn match netrwSpecFile '\\(\\S\\+ \\)*\\S*\\(".suflist."\\)\\>' contains=netrwTreeBar,@NoSpell" + endif + syn match netrwBak "\(\S\+ \)*\S\+\.bak\>" contains=netrwTreeBar,@NoSpell + syn match netrwCompress "\(\S\+ \)*\S\+\.\%(gz\|bz2\|Z\|zip\)\>" contains=netrwTreeBar,@NoSpell + if has("unix") + syn match netrwCoreDump "\<core\%(\.\d\+\)\=\>" contains=netrwTreeBar,@NoSpell + endif + syn match netrwLex "\(\S\+ \)*\S\+\.\%(l\|lex\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwYacc "\(\S\+ \)*\S\+\.y\>" contains=netrwTreeBar,@NoSpell + syn match netrwData "\(\S\+ \)*\S\+\.dat\>" contains=netrwTreeBar,@NoSpell + syn match netrwDoc "\(\S\+ \)*\S\+\.\%(doc\|txt\|pdf\|ps\|docx\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwHdr "\(\S\+ \)*\S\+\.\%(h\|hpp\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwLib "\(\S\+ \)*\S*\.\%(a\|so\|lib\|dll\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwMakeFile "\<[mM]akefile\>\|\(\S\+ \)*\S\+\.mak\>" contains=netrwTreeBar,@NoSpell + syn match netrwObj "\(\S\+ \)*\S*\.\%(o\|obj\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwPix "\c\(\S\+ \)*\S*\.\%(bmp\|fits\=\|gif\|je\=pg\|pcx\|ppc\|pgm\|png\|ppm\|psd\|rgb\|tif\|xbm\|xcf\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwTags "\<\(ANmenu\|ANtags\)\>" contains=netrwTreeBar,@NoSpell + syn match netrwTags "\<tags\>" contains=netrwTreeBar,@NoSpell + syn match netrwTilde "\(\S\+ \)*\S\+\~\*\=\>" contains=netrwTreeBar,@NoSpell + syn match netrwTmp "\<tmp\(\S\+ \)*\S\+\>\|\(\S\+ \)*\S*tmp\>" contains=netrwTreeBar,@NoSpell endif -" --------------------------------------------------------------------- -" Highlighting Links: {{{1 +" }}} +" Highlighting Links: {{{ + if !exists("did_drchip_netrwlist_syntax") - let did_drchip_netrwlist_syntax= 1 - hi default link netrwClassify Function - hi default link netrwCmdSep Delimiter - hi default link netrwComment Comment - hi default link netrwDir Directory - hi default link netrwHelpCmd Function - hi default link netrwQHTopic Number - hi default link netrwHidePat Statement - hi default link netrwHideSep netrwComment - hi default link netrwList Statement - hi default link netrwVersion Identifier - hi default link netrwSymLink Question - hi default link netrwExe PreProc - hi default link netrwDateSep Delimiter - - hi default link netrwTreeBar Special - hi default link netrwTimeSep netrwDateSep - hi default link netrwComma netrwComment - hi default link netrwHide netrwComment - hi default link netrwMarkFile TabLineSel - hi default link netrwLink Special - - " special syntax highlighting (see :he g:netrw_special_syntax) - hi default link netrwCoreDump WarningMsg - hi default link netrwData Folded - hi default link netrwHdr netrwPlain - hi default link netrwLex netrwPlain - hi default link netrwLib DiffChange - hi default link netrwMakefile DiffChange - hi default link netrwYacc netrwPlain - hi default link netrwPix Special - - hi default link netrwBak netrwGray - hi default link netrwCompress netrwGray - hi default link netrwSpecFile netrwGray - hi default link netrwObj netrwGray - hi default link netrwTags netrwGray - hi default link netrwTilde netrwGray - hi default link netrwTmp netrwGray + let did_drchip_netrwlist_syntax= 1 + hi default link netrwClassify Function + hi default link netrwCmdSep Delimiter + hi default link netrwComment Comment + hi default link netrwDir Directory + hi default link netrwHelpCmd Function + hi default link netrwQHTopic Number + hi default link netrwHidePat Statement + hi default link netrwHideSep netrwComment + hi default link netrwList Statement + hi default link netrwVersion Identifier + hi default link netrwSymLink Question + hi default link netrwExe PreProc + hi default link netrwDateSep Delimiter + + hi default link netrwTreeBar Special + hi default link netrwTimeSep netrwDateSep + hi default link netrwComma netrwComment + hi default link netrwHide netrwComment + hi default link netrwMarkFile TabLineSel + hi default link netrwLink Special + + " special syntax highlighting (see :he g:netrw_special_syntax) + hi default link netrwCoreDump WarningMsg + hi default link netrwData Folded + hi default link netrwHdr netrwPlain + hi default link netrwLex netrwPlain + hi default link netrwLib DiffChange + hi default link netrwMakefile DiffChange + hi default link netrwYacc netrwPlain + hi default link netrwPix Special + + hi default link netrwBak netrwGray + hi default link netrwCompress netrwGray + hi default link netrwSpecFile netrwGray + hi default link netrwObj netrwGray + hi default link netrwTags netrwGray + hi default link netrwTilde netrwGray + hi default link netrwTmp netrwGray endif - " set up netrwGray to be understated (but not Ignore'd or Conceal'd, as those - " can be hard/impossible to read). Users may override this in a colorscheme by - " specifying netrwGray highlighting. - redir => s:netrwgray - sil hi netrwGray - redir END - if s:netrwgray !~ 'guifg' - if has("gui") && has("gui_running") - if &bg == "dark" - exe "hi netrwGray gui=NONE guifg=gray30" - else - exe "hi netrwGray gui=NONE guifg=gray70" - endif - else - hi link netrwGray Folded - endif - endif - -" Current Syntax: {{{1 -let b:current_syntax = "netrwlist" -" --------------------------------------------------------------------- -" vim: ts=8 fdm=marker +" set up netrwGray to be understated (but not Ignore'd or Conceal'd, as those +" can be hard/impossible to read). Users may override this in a colorscheme by +" specifying netrwGray highlighting. +redir => s:netrwgray +sil hi netrwGray +redir END + +if s:netrwgray !~ 'guifg' + if has("gui") && has("gui_running") + if &bg == "dark" + exe "hi netrwGray gui=NONE guifg=gray30" + else + exe "hi netrwGray gui=NONE guifg=gray70" + endif + else + hi link netrwGray Folded + endif +endif + +" }}} + +" vim:ts=8 sts=4 sw=4 et fdm=marker diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 77a40e11d3..4f35bba939 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -3,7 +3,8 @@ " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E. Campbell " Last Change: Apr 22, 2022 -" 2024 Feb 19 by Vim Project (announce adoption) +" 2024 Feb 19 by Vim Project: announce adoption +" 2025 Jan 18 by Vim Project: add texEmphStyle to texMatchGroup, #16228 " Version: 121 " Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " @@ -176,11 +177,11 @@ if !s:tex_excludematcher endif if !s:tex_nospell if !s:tex_no_error - syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell + syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texEmphStyle,texZone,texInputFile,texOption,@Spell syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell else - syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell + syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texEmphStyle,texZone,texInputFile,texOption,@Spell syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell endif diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index edc69b907c..4038a65440 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -185,13 +185,13 @@ Vim9 syn keyword vim9Boolean true false " Numbers {{{2 " ======= syn case ignore -syn match vimNumber '\<\d\+\%(\.\d\+\%(e[+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\<0b[01]\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\<0o\=\o\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\<0x\x\+' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\<0z\>' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment -syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst1,vimCommand,@vimComment +syn match vimNumber '\<\d\+\%(\.\d\+\%(e[+-]\=\d\+\)\=\)\=' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\<0b[01]\+' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\<0o\=\o\+' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\<0x\x\+' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\<0z\>' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment +syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst1,@vimComment syn case match " All vimCommands are contained by vimIsCommand. {{{2 @@ -274,10 +274,12 @@ syn keyword vimAugroupKey contained aug[roup] skipwhite nextgroup=vimAugroupBan " Operators: {{{2 " ========= syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimRegister,@vimContinue,vim9Comment,vimVar,vimBoolean,vimNull -syn match vimOper "\a\@<!!" skipwhite nextgroup=vimString,vimSpecFile -syn match vimOper "||\|&&\|[-+*/%.]" skipwhite nextgroup=vimString,vimSpecFile -syn match vimOper "\%#=1\(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\|=\|!\~#\)[?#]\{0,2}" skipwhite nextgroup=vimString,vimSpecFile -syn match vimOper "\(\<is\|\<isnot\)[?#]\{0,2}\>" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "\a\@<!!" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "||\|&&\|[-+*/%.]" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "=" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "\%#=1\%(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\)[?#]\=" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "\<is\%(not\)\=\>" skipwhite nextgroup=vimString,vimSpecFile +syn match vimOper "\<is\%(not\)\=[?#]" skipwhite nextgroup=vimString,vimSpecFile syn region vimOperParen matchgroup=vimParenSep start="(" end=")" contains=@vimOperGroup syn region vimOperParen matchgroup=vimSep start="#\={" end="}" contains=@vimOperGroup nextgroup=vimVar,vimFuncVar if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_noopererror") diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 423b50cd32..1eecee2a38 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -163,6 +163,7 @@ typedef struct { typedef struct { buf_T *buf; OptInt save_b_p_ul; + int save_b_p_ma; int save_b_changed; pos_T save_b_op_start; pos_T save_b_op_end; @@ -2419,6 +2420,7 @@ static void cmdpreview_prepare(CpInfo *cpinfo) if (!set_has(ptr_t, &saved_bufs, buf)) { CpBufInfo cp_bufinfo; cp_bufinfo.buf = buf; + cp_bufinfo.save_b_p_ma = buf->b_p_ma; cp_bufinfo.save_b_p_ul = buf->b_p_ul; cp_bufinfo.save_b_changed = buf->b_changed; cp_bufinfo.save_b_op_start = buf->b_op_start; @@ -2509,6 +2511,7 @@ static void cmdpreview_restore_state(CpInfo *cpinfo) } buf->b_p_ul = cp_bufinfo.save_b_p_ul; // Restore 'undolevels' + buf->b_p_ma = cp_bufinfo.save_b_p_ma; // Restore 'modifiable' } for (size_t i = 0; i < cpinfo->win_info.size; i++) { @@ -2704,7 +2707,6 @@ static int command_line_changed(CommandLineState *s) && current_sctx.sc_sid == 0 // only if interactive && *p_icm != NUL // 'inccommand' is set && !exmode_active // not in ex mode - && curbuf->b_p_ma // buffer is modifiable && cmdline_star == 0 // not typing a password && !vpeekc_any() && cmdpreview_may_show(s)) { diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 031ae30d41..1c9903695e 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3276,7 +3276,11 @@ static void vim_mktempdir(void) expand_env((char *)temp_dirs[i], tmp, TEMP_FILE_PATH_MAXLEN - 64); if (!os_isdir(tmp)) { if (strequal("$TMPDIR", temp_dirs[i])) { - WLOG("$TMPDIR tempdir not a directory (or does not exist): %s", tmp); + if (!os_getenv("TMPDIR")) { + WLOG("$TMPDIR is unset"); + } else { + WLOG("$TMPDIR tempdir not a directory (or does not exist): \"%s\"", tmp); + } } continue; } diff --git a/src/nvim/message.c b/src/nvim/message.c index 5423446ef9..4c20edb7eb 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -153,7 +153,6 @@ static Array *msg_ext_chunks = NULL; static garray_T msg_ext_last_chunk = GA_INIT(sizeof(char), 40); static sattr_T msg_ext_last_attr = -1; static int msg_ext_last_hl_id; -static size_t msg_ext_cur_len = 0; static bool msg_ext_history = false; ///< message was added to history static bool msg_ext_overwrite = false; ///< will overwrite last message @@ -2246,14 +2245,13 @@ static void msg_puts_display(const char *str, int maxlen, int hl_id, int recurse // Concat pieces with the same highlight size_t len = maxlen < 0 ? strlen(str) : strnlen(str, (size_t)maxlen); ga_concat_len(&msg_ext_last_chunk, str, len); - msg_ext_cur_len += len; - msg_col += (int)mb_string2cells(str); - // When message ends in newline, reset variables used to format message: msg_advance(). - assert(len > 0); - if (str[len - 1] == '\n') { - msg_ext_cur_len = 0; - msg_col = 0; - } + + // Find last newline in the message and calculate the current message column + const char *lastline = strrchr(str, '\n'); + maxlen -= (int)(lastline ? (lastline - str) : 0); + const char *p = lastline ? lastline + 1 : str; + int col = (int)(maxlen < 0 ? mb_string2cells(p) : mb_string2cells_len(p, (size_t)(maxlen))); + msg_col = (lastline ? 0 : msg_col) + col; return; } @@ -3155,7 +3153,7 @@ static Array *msg_ext_init_chunks(void) { Array *tofree = msg_ext_chunks; msg_ext_chunks = xcalloc(1, sizeof(*msg_ext_chunks)); - msg_ext_cur_len = 0; + msg_col = 0; return tofree; } @@ -3472,14 +3470,6 @@ void msg_advance(int col) msg_col = col; // for redirection, may fill it up later return; } - if (ui_has(kUIMessages)) { - // TODO(bfredl): use byte count as a basic proxy. - // later on we might add proper support for formatted messages. - while (msg_ext_cur_len < (size_t)col) { - msg_putchar(' '); - } - return; - } col = MIN(col, Columns - 1); // not enough room while (msg_col < col) { msg_putchar(' '); diff --git a/src/nvim/window.c b/src/nvim/window.c index 1c0d8c1027..fa2bfec138 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5243,11 +5243,13 @@ void win_free(win_T *wp, tabpage_T *tp) // freed memory is re-used for another window. FOR_ALL_BUFFERS(buf) { WinInfo *wip_wp = NULL; + size_t pos_wip = kv_size(buf->b_wininfo); size_t pos_null = kv_size(buf->b_wininfo); for (size_t i = 0; i < kv_size(buf->b_wininfo); i++) { WinInfo *wip = kv_A(buf->b_wininfo, i); if (wip->wi_win == wp) { wip_wp = wip; + pos_wip = i; } else if (wip->wi_win == NULL) { pos_null = i; } @@ -5255,11 +5257,12 @@ void win_free(win_T *wp, tabpage_T *tp) if (wip_wp) { wip_wp->wi_win = NULL; - // If there already is an entry with "wi_win" set to NULL it - // must be removed, it would never be used. + // If there already is an entry with "wi_win" set to NULL, only + // the first entry with NULL will ever be used, delete the other one. if (pos_null < kv_size(buf->b_wininfo)) { - free_wininfo(kv_A(buf->b_wininfo, pos_null), buf); - kv_shift(buf->b_wininfo, pos_null, 1); + size_t pos_delete = MAX(pos_null, pos_wip); + free_wininfo(kv_A(buf->b_wininfo, pos_delete), buf); + kv_shift(buf->b_wininfo, pos_delete, 1); } } } diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 078d581b6f..028f0beb38 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -506,6 +506,48 @@ describe('API/win', function() assert_alive() end) + describe('after closing', function() + local buf, win0, win1, win2 + + before_each(function() + win0 = api.nvim_get_current_win() + command('new') + buf = api.nvim_get_current_buf() + win1 = api.nvim_get_current_win() + command('set numberwidth=10') + command('split') + win2 = api.nvim_get_current_win() + command('set numberwidth=15') + command('enew') + api.nvim_set_current_win(win1) + command('normal ix') + command('enew') + api.nvim_set_current_win(win0) + eq(4, api.nvim_get_option_value('numberwidth', {})) + end) + + -- at this point buffer `buf` is current in no windows. Closing shouldn't affect its defaults + it('0 windows', function() + api.nvim_set_current_buf(buf) + eq(10, api.nvim_get_option_value('numberwidth', {})) + end) + + it('1 window', function() + api.nvim_win_close(win1, false) + + api.nvim_set_current_buf(buf) + eq(10, api.nvim_get_option_value('numberwidth', {})) + end) + + it('2 windows', function() + api.nvim_win_close(win1, false) + api.nvim_win_close(win2, false) + + api.nvim_set_current_buf(buf) + eq(10, api.nvim_get_option_value('numberwidth', {})) + end) + end) + it('returns values for unset local options', function() eq(-1, api.nvim_get_option_value('scrolloff', { win = 0, scope = 'local' })) end) diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua index d64c024d7f..b75ff75b05 100644 --- a/test/functional/lua/filetype_spec.lua +++ b/test/functional/lua/filetype_spec.lua @@ -119,7 +119,7 @@ describe('vim.filetype', function() it('works with contents #22180', function() eq( - 'bash', + 'sh', exec_lua(function() -- Needs to be set so detect#sh doesn't fail vim.g.ft_ignore_pat = '\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$' diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index 84c8f5864a..4e90c2fd1b 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -239,13 +239,18 @@ describe('vim.lsp.completion: item conversion', function() }, }, } - local expected = { + assert_completion_matches('<mo', items, { { abbr = 'module', word = '<module', }, - } - assert_completion_matches('<mo', items, expected) + }) + assert_completion_matches('', items, { + { + abbr = 'module', + word = 'module', + }, + }) end) it('fuzzy matches on label when filterText is missing', function() diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 2d26d2c5e0..3eee9a6e07 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -253,6 +253,50 @@ describe("'inccommand' for user commands", function() ]] end) + it("can preview 'nomodifiable' buffer", function() + exec_lua([[ + vim.api.nvim_create_user_command("PreviewTest", function() end, { + preview = function(ev) + vim.bo.modifiable = true + vim.api.nvim_buf_set_lines(0, 0, -1, false, {"cats"}) + return 2 + end, + }) + ]]) + command('set inccommand=split') + + command('set nomodifiable') + eq(false, api.nvim_get_option_value('modifiable', { buf = 0 })) + + feed(':PreviewTest') + + screen:expect([[ + cats | + {1:~ }|*8 + {3:[No Name] [+] }| + | + {1:~ }|*4 + {2:[Preview] }| + :PreviewTest^ | + ]]) + feed('<Esc>') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + ^ | + {1:~ }|*7 + | + ]]) + + eq(false, api.nvim_get_option_value('modifiable', { buf = 0 })) + end) + it('works with inccommand=nosplit', function() command('set inccommand=nosplit') feed(':Replace text cats') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 7213f3b032..020603015f 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -128,9 +128,6 @@ func s:GetFilenameChecks() abort \ 'ave': ['file.ave'], \ 'awk': ['file.awk', 'file.gawk'], \ 'b': ['file.mch', 'file.ref', 'file.imp'], - \ 'bash': ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', - \ '.bash-aliases', '.bash_history', '.bash-history', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', - \ 'PKGBUILD', 'file.bash', 'file.bats', 'file.cygport'], \ 'basic': ['file.bas', 'file.bi', 'file.bm'], \ 'bass': ['file.bass'], \ 'bc': ['file.bc'], @@ -686,10 +683,11 @@ func s:GetFilenameChecks() abort \ 'services': ['/etc/services', 'any/etc/services'], \ 'setserial': ['/etc/serial.conf', 'any/etc/serial.conf'], \ 'sexplib': ['file.sexp'], - \ 'sh': ['/usr/share/doc/bash-completion/filter.sh', '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', - \ '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile', 'user-dirs.defaults', 'user-dirs.dirs', - \ 'makepkg.conf', '.makepkg.conf', 'file.mdd', '.env', '.envrc', 'devscripts.conf', '.devscripts', 'file.lo', - \ 'file.la', 'file.lai'], + \ 'sh': ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history', + \ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh', + \ '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile', + \ 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf', 'file.mdd', 'file.cygport', '.env', '.envrc', 'devscripts.conf', + \ '.devscripts', 'file.lo', 'file.la', 'file.lai'], \ 'shaderslang': ['file.slang'], \ 'sieve': ['file.siv', 'file.sieve'], \ 'sil': ['file.sil'], @@ -981,11 +979,11 @@ func s:GetScriptChecks() abort \ 'clojure': [['#!/path/clojure']], \ 'scala': [['#!/path/scala']], \ 'sh': [['#!/path/sh'], + \ ['#!/path/bash'], + \ ['#!/path/bash2'], \ ['#!/path/dash'], \ ['#!/path/ksh'], \ ['#!/path/ksh93']], - \ 'bash': [['#!/path/bash'], - \ ['#!/path/bash2']], \ 'csh': [['#!/path/csh']], \ 'tcsh': [['#!/path/tcsh']], \ 'zsh': [['#!/path/zsh']], |