diff options
-rw-r--r-- | runtime/doc/usr_05.txt | 2 | ||||
-rw-r--r-- | runtime/doc/usr_21.txt | 38 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 8 | ||||
-rw-r--r-- | runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim | 4 | ||||
-rw-r--r-- | scripts/gen_help_html.lua | 21 | ||||
-rw-r--r-- | src/nvim/textobject.c | 9 | ||||
-rw-r--r-- | test/old/testdir/test_textobjects.vim | 12 |
7 files changed, 62 insertions, 32 deletions
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index f6324a12d5..aa7dd8d05c 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -244,7 +244,7 @@ Automatically execute |:nohlsearch| after 'updatetime' or getting into |Insert| Thus assuming default updatetime, hlsearch would be suspended/turned off after 4 seconds of idle time. -To disable the effect of the plugin after is has been loaded: > +To disable the effect of the plugin after it has been loaded: > au! nohlsearch < diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index 4ae72bbe84..8671f04ba2 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -303,21 +303,21 @@ use, and save this in a session. Then you can go back to this layout whenever you want. For example, this is a nice layout to use: > - +----------------------------------------+ - | VIM - main help file | - | | - |Move around: Use the cursor keys, or "h| - |help.txt================================| - |explorer | | - |dir |~ | - |dir |~ | - |file |~ | - |file |~ | - |file |~ | - |file |~ | - |~/=========|[No File]===================| - | | - +----------------------------------------+ + +----------------------------------------+ + | VIM - main help file | + | | + |Move around: Use the cursor keys, or "h| + |help.txt================================| + |explorer | | + |dir |~ | + |dir |~ | + |file |~ | + |file |~ | + |file |~ | + |file |~ | + |~/=========|[No File]===================| + | | + +----------------------------------------+ < This has a help window at the top, so that you can read this text. The narrow vertical window on the left contains a file explorer. This is a Vim plugin @@ -448,9 +448,9 @@ trust the files you are editing: > :set nomodeline -Use this format for the modeline: +Use this format for the modeline: > - any-text vim:set {option}={value} ... : any-text ~ + any-text vim:set {option}={value} ... : any-text The "any-text" indicates that you can put any text before and after the part that Vim will use. This allows making it look like a comment, like what was @@ -462,9 +462,9 @@ using something like "gvim:" will not work. typing the ":set" command, except that you need to insert a backslash before a colon (otherwise it would be seen as the end of the modeline). -Another example: +Another example: > - // vim:set textwidth=72 dir=c\:\tmp: use c:\tmp here ~ + // vim:set textwidth=72 dir=c\:\tmp: use c:\tmp here There is an extra backslash before the first colon, so that it's included in the ":set" command. The text after the second colon is ignored, thus a remark diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index c8e34258f5..3be22556ab 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1359,6 +1359,10 @@ M.handlers.signs = { bufnr = get_bufnr(bufnr) opts = opts or {} + if not api.nvim_buf_is_loaded(bufnr) then + return + end + if opts.signs and opts.signs.severity then diagnostics = filter_by_severity(opts.signs.severity, diagnostics) end @@ -1441,8 +1445,10 @@ M.handlers.signs = { local numhl = opts.signs.numhl or {} local linehl = opts.signs.linehl or {} + local line_count = api.nvim_buf_line_count(bufnr) + for _, diagnostic in ipairs(diagnostics) do - if api.nvim_buf_is_loaded(diagnostic.bufnr) then + if diagnostic.lnum <= line_count then api.nvim_buf_set_extmark(bufnr, ns.user_data.sign_ns, diagnostic.lnum, 0, { sign_text = text[diagnostic.severity] or text[M.severity[diagnostic.severity]] or 'U', sign_hl_group = sign_highlight_map[diagnostic.severity], diff --git a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim index 6cfe813cfa..8d9930742c 100644 --- a/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim +++ b/runtime/pack/dist/opt/nohlsearch/plugin/nohlsearch.vim @@ -1,5 +1,5 @@ " nohlsearch.vim: Auto turn off hlsearch -" Last Change: 2024-06-18 +" Last Change: 2024-06-19 " Maintainer: Maxim Kim <habamax@gmail.com> " " turn off hlsearch after: @@ -8,7 +8,7 @@ augroup nohlsearch au! noremap <Plug>(nohlsearch) <cmd>nohlsearch<cr> - noremap! <expr> <Plug>(nohlsearch) execute('nohlsearch')[-1] + noremap! <Plug>(nohlsearch) <cmd>nohlsearch<cr> au CursorHold * call feedkeys("\<Plug>(nohlsearch)", 'm') au InsertEnter * call feedkeys("\<Plug>(nohlsearch)", 'm') augroup END diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua index 722efc489f..4584d87bf5 100644 --- a/scripts/gen_help_html.lua +++ b/scripts/gen_help_html.lua @@ -490,7 +490,6 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) or nil -- Parent kind (string). local parent = root:parent() and root:parent():type() or nil - local text = '' -- Gets leading whitespace of `node`. local function ws(node) node = node or root @@ -508,6 +507,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) return string.format('%s%s', ws_, vim.treesitter.get_node_text(node, opt.buf)) end + local text = '' local trimmed ---@type string if root:named_child_count() == 0 or node_name == 'ERROR' then text = node_text() @@ -537,12 +537,17 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) if is_noise(text, stats.noise_lines) then return '' -- Discard common "noise" lines. end - -- Remove "===" and tags from ToC text. - local hname = (node_text():gsub('%-%-%-%-+', ''):gsub('%=%=%=%=+', ''):gsub('%*.*%*', '')) + -- Remove tags from ToC text. + local heading_node = first(root, 'heading') + local hname = trim(node_text(heading_node):gsub('%*.*%*', '')) + if not heading_node or hname == '' then + return '' -- Spurious "===" or "---" in the help doc. + end + -- Use the first *tag* node as the heading anchor, if any. - local tagnode = first(root, 'tag') + local tagnode = first(heading_node, 'tag') -- Use the *tag* as the heading anchor id, if possible. - local tagname = tagnode and url_encode(node_text(tagnode:child(1), false)) + local tagname = tagnode and url_encode(trim(node_text(tagnode:child(1), false))) or to_heading_tag(hname) if node_name == 'h1' or #headings == 0 then ---@type nvim.gen_help_html.heading @@ -555,7 +560,9 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) ) end local el = node_name == 'h1' and 'h2' or 'h3' - return ('<%s id="%s" class="help-heading">%s</%s>\n'):format(el, tagname, text, el) + return ('<%s id="%s" class="help-heading">%s</%s>\n'):format(el, tagname, trimmed, el) + elseif node_name == 'heading' then + return trimmed elseif node_name == 'column_heading' or node_name == 'column_name' then if root:has_error() then return text @@ -695,7 +702,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) return string.format('%s</span>', s) end return s - elseif node_name == 'modeline' then + elseif node_name == 'delimiter' or node_name == 'modeline' then return '' elseif node_name == 'ERROR' then if ignore_parse_error(opt.fname, trimmed) then diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 3c81a840ea..ffc5bc2cb2 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1193,13 +1193,18 @@ again: pos_T end_pos = curwin->w_cursor; if (!do_include) { - // Exclude the start tag. + // Exclude the start tag, + // but skip over '>' if it appears in quotes + bool in_quotes = false; curwin->w_cursor = start_pos; while (inc_cursor() >= 0) { - if (*get_cursor_pos_ptr() == '>') { + p = get_cursor_pos_ptr(); + if (*p == '>' && !in_quotes) { inc_cursor(); start_pos = curwin->w_cursor; break; + } else if (*p == '"' || *p == '\'') { + in_quotes = !in_quotes; } } curwin->w_cursor = end_pos; diff --git a/test/old/testdir/test_textobjects.vim b/test/old/testdir/test_textobjects.vim index a7840860c9..0f41f0a241 100644 --- a/test/old/testdir/test_textobjects.vim +++ b/test/old/testdir/test_textobjects.vim @@ -203,6 +203,18 @@ func Test_string_html_objects() normal! 2k0vaty call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e) + " tag, that includes a > in some attribute + let t = "<div attr=\"attr >> foo >> bar \">Hello</div>" + $put =t + normal! fHyit + call assert_equal("Hello", @", e) + + " tag, that includes a > in some attribute + let t = "<div attr='attr >> foo >> bar '>Hello 123</div>" + $put =t + normal! fHyit + call assert_equal("Hello 123", @", e) + set quoteescape& " this was going beyond the end of the line |