Add 'line' in completers option as a way to force explicit <c-x>f

This commit is contained in:
Delapouite 2017-10-02 18:45:11 +02:00
parent 2f251c9861
commit 6bfc99bf08
4 changed files with 17 additions and 1 deletions

View File

@ -982,6 +982,7 @@ Some options are built in Kakoune, and can be used to control its behaviour:
(`word=all`) or only the current one (`word=buffer`)
- `filename` which tries to detect when a filename is being entered and
provides completion based on local filesystem.
- `line` which complete using lines in current buffer
- `option=<opt-name>` where <opt-name> is a _completions_ option.
* `static_words` _str-list_: list of words that are always added to completion
candidates when completing words in insert mode.

View File

@ -129,6 +129,9 @@ Builtin options
which tries to detect when a filename is being entered and
provides completion based on local filesystem
*line*:::
which complete using lines in current buffer
*option=<opt-name>*:::
where *opt-name* is an option of type 'completions' whose
contents will be used

View File

@ -32,6 +32,8 @@ String option_to_string(const InsertCompleterDesc& opt)
return "filename";
case InsertCompleterDesc::Option:
return "option=" + (opt.param ? *opt.param : "");
case InsertCompleterDesc::Line:
return "line";
}
kak_assert(false);
return "";
@ -61,6 +63,12 @@ void option_from_string(StringView str, InsertCompleterDesc& opt)
opt.param = Optional<String>{};
return;
}
else if (str == "line")
{
opt.mode = InsertCompleterDesc::Line;
opt.param = Optional<String>{};
return;
}
throw runtime_error(format("invalid completer description: '{}'", str));
}
@ -467,6 +475,9 @@ bool InsertCompleter::setup_ifn()
*completer.param == "all" and
try_complete(complete_word<true>))
return true;
if (completer.mode == InsertCompleterDesc::Line and
try_complete(complete_line))
return true;
}
return false;
}

View File

@ -20,7 +20,8 @@ struct InsertCompleterDesc
{
Word,
Option,
Filename
Filename,
Line
};
bool operator==(const InsertCompleterDesc& other) const