mirror of
https://github.com/neovim/neovim.git
synced 2025-11-16 15:21:20 +00:00
vim-patch:9.1.1750: completion: preinserted text highlighed using ComplMatchIns
Problem: completion: preinserted text highlighed using ComplMatchIns
Solution: Use highlighting group PreInsert and update the documentation
(Girish Palya).
When "preinsert" is included in 'completeopt', only the PreInsert
highlight group should be applied, whether autocompletion is active or not.
Previously, ComplMatchIns was used when autocompletion was not enabled.
Related to https://github.com/vim/vim/pull/18213.
closes: vim/vim#18254
2525c56e42
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -1677,13 +1677,13 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
preinsert
|
preinsert
|
||||||
When autocompletion is not enabled, inserts the part of the
|
When autocompletion is not enabled, inserts the part of the
|
||||||
first candidate word beyond the current completion leader,
|
first candidate word beyond the current completion leader,
|
||||||
highlighted with |hl-ComplMatchIns|. The cursor does not
|
highlighted with |hl-PreInsert|. The cursor does not
|
||||||
move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
||||||
|
|
||||||
When 'autocomplete' is enabled, inserts the longest common
|
When 'autocomplete' is enabled, inserts the longest common
|
||||||
prefix of matches (from all shown items or buffer-specific
|
prefix of matches (from all shown items or from the
|
||||||
matches), highlighted with |hl-PreInsert|. This occurs only
|
current buffer items). This occurs only when no menu item
|
||||||
when no menu item is selected. Press CTRL-Y to accept.
|
is selected. Press CTRL-Y to accept.
|
||||||
|
|
||||||
preview Show extra information about the currently selected
|
preview Show extra information about the currently selected
|
||||||
completion in the preview window. Only works in
|
completion in the preview window. Only works in
|
||||||
|
|||||||
@@ -5354,7 +5354,7 @@ PmenuMatchSel Popup menu: Matched text in selected item. Combined with
|
|||||||
*hl-ComplMatchIns*
|
*hl-ComplMatchIns*
|
||||||
ComplMatchIns Matched text of the currently inserted completion.
|
ComplMatchIns Matched text of the currently inserted completion.
|
||||||
*hl-PreInsert*
|
*hl-PreInsert*
|
||||||
PreInsert Text inserted during autocompletion when "preinsert".
|
PreInsert Text inserted when "preinsert" is in 'completeopt'.
|
||||||
*hl-ComplHint*
|
*hl-ComplHint*
|
||||||
ComplHint Virtual text of the currently selected completion.
|
ComplHint Virtual text of the currently selected completion.
|
||||||
*hl-ComplHintMore*
|
*hl-ComplHintMore*
|
||||||
|
|||||||
8
runtime/lua/vim/_meta/options.lua
generated
8
runtime/lua/vim/_meta/options.lua
generated
@@ -1220,13 +1220,13 @@ vim.go.cia = vim.go.completeitemalign
|
|||||||
--- preinsert
|
--- preinsert
|
||||||
--- When autocompletion is not enabled, inserts the part of the
|
--- When autocompletion is not enabled, inserts the part of the
|
||||||
--- first candidate word beyond the current completion leader,
|
--- first candidate word beyond the current completion leader,
|
||||||
--- highlighted with `hl-ComplMatchIns`. The cursor does not
|
--- highlighted with `hl-PreInsert`. The cursor does not
|
||||||
--- move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
--- move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
||||||
---
|
---
|
||||||
--- When 'autocomplete' is enabled, inserts the longest common
|
--- When 'autocomplete' is enabled, inserts the longest common
|
||||||
--- prefix of matches (from all shown items or buffer-specific
|
--- prefix of matches (from all shown items or from the
|
||||||
--- matches), highlighted with `hl-PreInsert`. This occurs only
|
--- current buffer items). This occurs only when no menu item
|
||||||
--- when no menu item is selected. Press CTRL-Y to accept.
|
--- is selected. Press CTRL-Y to accept.
|
||||||
---
|
---
|
||||||
--- preview Show extra information about the currently selected
|
--- preview Show extra information about the currently selected
|
||||||
--- completion in the preview window. Only works in
|
--- completion in the preview window. Only works in
|
||||||
|
|||||||
@@ -1095,10 +1095,14 @@ static void ins_compl_insert_bytes(char *p, int len)
|
|||||||
/// -1 means normal item.
|
/// -1 means normal item.
|
||||||
int ins_compl_col_range_attr(linenr_T lnum, int col)
|
int ins_compl_col_range_attr(linenr_T lnum, int col)
|
||||||
{
|
{
|
||||||
|
const bool has_preinsert = ins_compl_has_preinsert();
|
||||||
|
|
||||||
int attr;
|
int attr;
|
||||||
if ((get_cot_flags() & kOptCotFlagFuzzy)
|
if ((get_cot_flags() & kOptCotFlagFuzzy)
|
||||||
|| (!compl_autocomplete
|
|| (!has_preinsert
|
||||||
&& (attr = syn_name2attr("ComplMatchIns")) == 0)
|
&& (attr = syn_name2attr("ComplMatchIns")) == 0)
|
||||||
|
|| (!compl_autocomplete && has_preinsert
|
||||||
|
&& (attr = syn_name2attr("PreInsert")) == 0)
|
||||||
|| (compl_autocomplete
|
|| (compl_autocomplete
|
||||||
&& (!compl_autocomplete_preinsert
|
&& (!compl_autocomplete_preinsert
|
||||||
|| (attr = syn_name2attr("PreInsert")) == 0))) {
|
|| (attr = syn_name2attr("PreInsert")) == 0))) {
|
||||||
@@ -2283,9 +2287,7 @@ static void ins_compl_new_leader(void)
|
|||||||
compl_enter_selects = false;
|
compl_enter_selects = false;
|
||||||
} else if (ins_compl_has_preinsert() && compl_leader.size > 0) {
|
} else if (ins_compl_has_preinsert() && compl_leader.size > 0) {
|
||||||
if (compl_started && compl_autocomplete && !ins_compl_preinsert_effect()) {
|
if (compl_started && compl_autocomplete && !ins_compl_preinsert_effect()) {
|
||||||
if (ins_compl_insert(true, true) != OK) {
|
if (ins_compl_insert(true, true) == OK) {
|
||||||
(void)ins_compl_insert(false, false);
|
|
||||||
} else {
|
|
||||||
compl_autocomplete_preinsert = true;
|
compl_autocomplete_preinsert = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1702,13 +1702,13 @@ local options = {
|
|||||||
preinsert
|
preinsert
|
||||||
When autocompletion is not enabled, inserts the part of the
|
When autocompletion is not enabled, inserts the part of the
|
||||||
first candidate word beyond the current completion leader,
|
first candidate word beyond the current completion leader,
|
||||||
highlighted with |hl-ComplMatchIns|. The cursor does not
|
highlighted with |hl-PreInsert|. The cursor does not
|
||||||
move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
move. Requires "fuzzy" unset and "menuone" in 'completeopt'.
|
||||||
|
|
||||||
When 'autocomplete' is enabled, inserts the longest common
|
When 'autocomplete' is enabled, inserts the longest common
|
||||||
prefix of matches (from all shown items or buffer-specific
|
prefix of matches (from all shown items or from the
|
||||||
matches), highlighted with |hl-PreInsert|. This occurs only
|
current buffer items). This occurs only when no menu item
|
||||||
when no menu item is selected. Press CTRL-Y to accept.
|
is selected. Press CTRL-Y to accept.
|
||||||
|
|
||||||
preview Show extra information about the currently selected
|
preview Show extra information about the currently selected
|
||||||
completion in the preview window. Only works in
|
completion in the preview window. Only works in
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ describe('completion', function()
|
|||||||
screen:add_extra_attr_ids {
|
screen:add_extra_attr_ids {
|
||||||
[100] = { foreground = Screen.colors.Gray0, background = Screen.colors.Yellow },
|
[100] = { foreground = Screen.colors.Gray0, background = Screen.colors.Yellow },
|
||||||
[101] = { background = Screen.colors.Gray0 },
|
[101] = { background = Screen.colors.Gray0 },
|
||||||
|
[102] = { foreground = Screen.colors.SeaGreen },
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1501,7 +1502,7 @@ describe('completion', function()
|
|||||||
foo |
|
foo |
|
||||||
foobar |
|
foobar |
|
||||||
foobarbaz |
|
foobarbaz |
|
||||||
f^oo |
|
f{102:^oo} |
|
||||||
{12:foo }{1: }|
|
{12:foo }{1: }|
|
||||||
{4:foobar }{1: }|
|
{4:foobar }{1: }|
|
||||||
{4:foobarbaz }{1: }|
|
{4:foobarbaz }{1: }|
|
||||||
|
|||||||
Reference in New Issue
Block a user