diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/health/provider.vim | 24 | ||||
-rw-r--r-- | runtime/autoload/provider/pythonx.vim | 4 | ||||
-rw-r--r-- | runtime/doc/builtin.txt | 8 | ||||
-rw-r--r-- | runtime/doc/index.txt | 3 | ||||
-rw-r--r-- | runtime/doc/tabpage.txt | 7 | ||||
-rw-r--r-- | runtime/filetype.lua | 38 | ||||
-rw-r--r-- | runtime/filetype.vim | 2 | ||||
-rw-r--r-- | runtime/lua/vim/_editor.lua | 104 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 3 |
9 files changed, 123 insertions, 70 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 2f35179338..6022e05c22 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -301,7 +301,7 @@ function! s:check_python() abort call health#report_info(printf('Using: g:%s = "%s"', host_prog_var, get(g:, host_prog_var))) endif - let [pyname, pythonx_errors] = provider#pythonx#Detect(3) + let [pyname, pythonx_warnings] = provider#pythonx#Detect(3) if empty(pyname) call health#report_warn('No Python executable found that can `import neovim`. ' @@ -311,8 +311,9 @@ function! s:check_python() abort endif " No Python executable could `import neovim`, or host_prog_var was used. - if !empty(pythonx_errors) - call health#report_error('Python provider error:', pythonx_errors) + if !empty(pythonx_warnings) + call health#report_warn(pythonx_warnings, ['See :help provider-python for more information.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim']) elseif !empty(pyname) && empty(python_exe) if !exists('g:'.host_prog_var) @@ -573,7 +574,8 @@ function! s:check_ruby() abort \ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.', \ 'Run `gem environment` to ensure the gem bin directory is in $PATH.', \ 'If you are using rvm/rbenv/chruby, try "rehashing".', - \ 'See :help g:ruby_host_prog for non-standard gem installations.']) + \ 'See :help g:ruby_host_prog for non-standard gem installations.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim']) return endif call health#report_info('Host: '. host) @@ -634,7 +636,8 @@ function! s:check_node() abort if empty(host) call health#report_warn('Missing "neovim" npm (or yarn) package.', \ ['Run in shell: npm install -g neovim', - \ 'Run in shell (if you use yarn): yarn global add neovim']) + \ 'Run in shell (if you use yarn): yarn global add neovim', + \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim']) return endif call health#report_info('Nvim node.js host: '. host) @@ -683,14 +686,15 @@ function! s:check_perl() abort return endif - let [perl_exec, perl_errors] = provider#perl#Detect() + let [perl_exec, perl_warnings] = provider#perl#Detect() if empty(perl_exec) - if !empty(perl_errors) - call health#report_error('perl provider error:', perl_errors) - else + if !empty(perl_warnings) + call health#report_warn(perl_warnings, ['See :help provider-perl for more information.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim']) + else call health#report_warn('No usable perl executable found') endif - return + return endif call health#report_info('perl executable: '. perl_exec) diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 5b299b322c..048f898e62 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -56,7 +56,7 @@ function! provider#pythonx#DetectByModule(module, major_version) abort endfor " No suitable Python executable found. - return ['', 'provider/pythonx: Could not load Python '.a:major_version.":\n".join(errors, "\n")] + return ['', 'Could not load Python '.a:major_version.":\n".join(errors, "\n")] endfunction " Returns array: [prog_exitcode, prog_version] @@ -99,7 +99,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort endif if prog_exitcode == 2 - return [0, prog_path.' does not have the "' . a:module . '" module. :help provider-python'] + return [0, prog_path.' does not have the "' . a:module . '" module.'] elseif prog_exitcode == 127 " This can happen with pyenv's shims. return [0, prog_path . ' does not exist: ' . prog_version] diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index ccc02e83b2..9eec23b7b7 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -8103,15 +8103,15 @@ tabpagebuflist([{arg}]) *tabpagebuflist()* tabpagenr([{arg}]) *tabpagenr()* The result is a Number, which is the number of the current tab page. The first tab page has number 1. + The optional argument {arg} supports the following values: $ the number of the last tab page (the tab page count). - # the number of the last accessed tab page (where - |g<Tab>| goes to). If there is no previous - tab page, 0 is returned. + # the number of the last accessed tab page + (where |g<Tab>| goes to). If there is no + previous tab page, 0 is returned. The number can be used with the |:tab| command. - tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* Like |winnr()| but for tab page {tabarg}. {tabarg} specifies the number of tab page to be used. diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index d02ab1b759..572b4e3f93 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -431,6 +431,7 @@ tag char note action in Normal mode ~ |<C-LeftMouse>| <C-LeftMouse> ":ta" to the keyword at the mouse click |<C-Right>| <C-Right> 1 same as "w" |<C-RightMouse>| <C-RightMouse> same as "CTRL-T" +|<C-Tab>| <C-Tab> same as "g<Tab>" |<Del>| ["x]<Del> 2 same as "x" |N<Del>| {count}<Del> remove the last digit from {count} |<Down>| <Down> 1 same as "j" @@ -577,7 +578,7 @@ tag command action in Normal mode ~ following the file name. |CTRL-W_gt| CTRL-W g t same as `gt`: go to next tab page |CTRL-W_gT| CTRL-W g T same as `gT`: go to previous tab page -|CTRL-W_g<Tab>| CTRL-W g <Tab> same as `g<Tab>` : go to last accessed tab +|CTRL-W_g<Tab>| CTRL-W g <Tab> same as |g<Tab>|: go to last accessed tab page |CTRL-W_h| CTRL-W h go to Nth left window (stop at first window) |CTRL-W_i| CTRL-W i split window and jump to declaration of diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index 78b5101da7..f06a6bcc34 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -196,10 +196,6 @@ gt *i_CTRL-<PageDown>* *i_<C-PageDown>* {count}<C-PageDown> {count}gt Go to tab page {count}. The first tab page has number one. -CTRL-<Tab> *CTRL-<Tab>* -CTRL-W g<Tab> *g<Tab>* *CTRL-W_g<Tab>* -g<Tab> Go to previous (last accessed) tab page. - :tabp[revious] *:tabp* *:tabprevious* *gT* *:tabN* :tabN[ext] *:tabNext* *CTRL-<PageUp>* <C-PageUp> *<C-PageUp>* *i_CTRL-<PageUp>* *i_<C-PageUp>* @@ -219,6 +215,9 @@ gT Go to the previous tab page. Wraps around from the first one *:tabl* *:tablast* :tabl[ast] Go to the last tab page. +<C-Tab> *CTRL-<Tab>* *<C-Tab>* +CTRL-W g<Tab> *g<Tab>* *CTRL-W_g<Tab>* +g<Tab> Go to the last accessed tab page. Other commands: *:tabs* diff --git a/runtime/filetype.lua b/runtime/filetype.lua index 74e427c358..8224b79534 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -7,26 +7,36 @@ if vim.g.do_filetype_lua ~= 1 then return end --- TODO: Remove vim.cmd once Lua autocommands land -vim.cmd [[ -augroup filetypedetect -au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>')) +vim.api.nvim_create_augroup("filetypedetect", {clear = false}) + +vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + group = "filetypedetect", + callback = function() + vim.filetype.match(vim.fn.expand("<afile>")) + end, +}) -" These *must* be sourced after the autocommand above is created +-- These *must* be sourced after the autocommand above is created +vim.cmd [[ runtime! ftdetect/*.vim runtime! ftdetect/*.lua +]] -" Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim -let g:did_load_ftdetect = 1 +-- Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim +vim.g.did_load_ftdetect = 1 -" If filetype.vim is disabled, set up the autocmd to use scripts.vim -if exists('did_load_filetypes') - au BufRead,BufNewFile * if !did_filetype() && expand('<amatch>') !~ g:ft_ignore_pat | runtime! scripts.vim | endif - au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif -endif +-- If filetype.vim is disabled, set up the autocmd to use scripts.vim +if vim.g.did_load_filetypes then + vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + group = "filetypedetect", + command = "if !did_filetype() && expand('<amatch>') !~ g:ft_ignore_pat | runtime! scripts.vim | endif", + }) -augroup END -]] + vim.api.nvim_create_autocmd("StdinReadPost", { + group = "filetypedetect", + command = "if !did_filetype() | runtime! scripts.vim | endif", + }) +end if not vim.g.ft_ignore_pat then vim.g.ft_ignore_pat = "\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$" diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 8114ad4092..9df89674e3 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -664,7 +664,7 @@ au BufNewFile,BufRead *.fs call dist#ft#FTfs() au BufNewFile,BufRead *.fsi,*.fsx setf fsharp " GDB command files -au BufNewFile,BufRead .gdbinit,gdbinit setf gdb +au BufNewFile,BufRead .gdbinit,gdbinit,.gdbearlyinit,gdbearlyinit,*.gdb setf gdb " GDMO au BufNewFile,BufRead *.mo,*.gdmo setf gdmo diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index a0c60a7dcf..d4db4850bd 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -128,7 +128,7 @@ local function inspect(object, options) -- luacheck: no unused end do - local tdots, tick, got_line1 = 0, 0, false + local tdots, tick, got_line1, undo_started, trailing_nl = 0, 0, false, false, false --- Paste handler, invoked by |nvim_paste()| when a conforming UI --- (such as the |TUI|) pastes text into the editor. @@ -156,44 +156,80 @@ do --- - 3: ends the paste (exactly once) ---@returns false if client should cancel the paste. function vim.paste(lines, phase) - local call = vim.api.nvim_call_function local now = vim.loop.now() - local mode = call('mode', {}):sub(1,1) - if phase < 2 then -- Reset flags. - tdots, tick, got_line1 = now, 0, false - elseif mode ~= 'c' then + local is_first_chunk = phase < 2 + local is_last_chunk = phase == -1 or phase == 3 + if is_first_chunk then -- Reset flags. + tdots, tick, got_line1, undo_started, trailing_nl = now, 0, false, false, false + end + if #lines == 0 then + lines = {''} + end + if #lines == 1 and lines[1] == '' and not is_last_chunk then + -- An empty chunk can cause some edge cases in streamed pasting, + -- so don't do anything unless it is the last chunk. + return true + end + -- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead. + if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line. + if not got_line1 then + got_line1 = (#lines > 1) + vim.api.nvim_set_option('paste', true) -- For nvim_input(). + -- Escape "<" and control characters + local line1 = lines[1]:gsub('<', '<lt>'):gsub('(%c)', '\022%1') + vim.api.nvim_input(line1) + vim.api.nvim_set_option('paste', false) + end + return true + end + local mode = vim.api.nvim_get_mode().mode + if undo_started then vim.api.nvim_command('undojoin') end - if mode == 'c' and not got_line1 then -- cmdline-mode: paste only 1 line. - got_line1 = (#lines > 1) - vim.api.nvim_set_option('paste', true) -- For nvim_input(). - local line1 = lines[1]:gsub('<', '<lt>'):gsub('[\r\n\012\027]', ' ') -- Scrub. - vim.api.nvim_input(line1) - vim.api.nvim_set_option('paste', false) - elseif mode ~= 'c' then - if phase < 2 and mode:find('^[vV\22sS\19]') then - vim.api.nvim_command([[exe "normal! \<Del>"]]) - vim.api.nvim_put(lines, 'c', false, true) - elseif phase < 2 and not mode:find('^[iRt]') then - vim.api.nvim_put(lines, 'c', true, true) - -- XXX: Normal-mode: workaround bad cursor-placement after first chunk. - vim.api.nvim_command('normal! a') - elseif phase < 2 and mode == 'R' then - local nchars = 0 - for _, line in ipairs(lines) do - nchars = nchars + line:len() + if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer + vim.api.nvim_put(lines, 'c', false, true) + elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode + -- TODO: implement Replace mode streamed pasting + -- TODO: support Virtual Replace mode + local nchars = 0 + for _, line in ipairs(lines) do + nchars = nchars + line:len() + end + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1] + local firstline = lines[1] + firstline = bufline:sub(1, col)..firstline + lines[1] = firstline + lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len()) + vim.api.nvim_buf_set_lines(0, row-1, row, false, lines) + elseif mode:find('^[nvV\22sS\19]') then -- Normal or Visual or Select mode + if mode:find('^n') then -- Normal mode + -- When there was a trailing new line in the previous chunk, + -- the cursor is on the first character of the next line, + -- so paste before the cursor instead of after it. + vim.api.nvim_put(lines, 'c', not trailing_nl, false) + else -- Visual or Select mode + vim.api.nvim_command([[exe "silent normal! \<Del>"]]) + local del_start = vim.fn.getpos("'[") + local cursor_pos = vim.fn.getpos('.') + if mode:find('^[VS]') then -- linewise + if cursor_pos[2] < del_start[2] then -- replacing lines at eof + -- create a new line + vim.api.nvim_put({''}, 'l', true, true) + end + vim.api.nvim_put(lines, 'c', false, false) + else + -- paste after cursor when replacing text at eol, otherwise paste before cursor + vim.api.nvim_put(lines, 'c', cursor_pos[3] < del_start[3], false) end - local row, col = unpack(vim.api.nvim_win_get_cursor(0)) - local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1] - local firstline = lines[1] - firstline = bufline:sub(1, col)..firstline - lines[1] = firstline - lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len()) - vim.api.nvim_buf_set_lines(0, row-1, row, false, lines) - else - vim.api.nvim_put(lines, 'c', false, true) end + -- put cursor at the end of the text instead of one character after it + vim.fn.setpos('.', vim.fn.getpos("']")) + trailing_nl = lines[#lines] == '' + else -- Don't know what to do in other modes + return false end + undo_started = true if phase ~= -1 and (now - tdots >= 100) then local dots = ('.'):rep(tick % 4) tdots = now @@ -202,7 +238,7 @@ do -- message when there are zero dots. vim.api.nvim_command(('echo "%s"'):format(dots)) end - if phase == -1 or phase == 3 then + if is_last_chunk then vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or '')) end return true -- Paste will not continue if not returning `true`. diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f5e4dabfb6..b356f5e3dc 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -225,6 +225,7 @@ local extension = { fsi = "fsharp", fsx = "fsharp", fusion = "fusion", + gdb = "gdb", gdmo = "gdmo", mo = "gdmo", tres = "gdresource", @@ -919,6 +920,8 @@ local filename = { mtab = "fstab", [".gdbinit"] = "gdb", gdbinit = "gdb", + [".gdbearlyinit"] = "gdb", + gdbearlyinit = "gdb", ["lltxxxxx.txt"] = "gedcom", ["TAG_EDITMSG"] = "gitcommit", ["MERGE_MSG"] = "gitcommit", |