diff --git a/README.asciidoc b/README.asciidoc index 8f01a692..b6cdd12f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -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=` where is a _completions_ option. * `static_words` _str-list_: list of words that are always added to completion candidates when completing words in insert mode. diff --git a/doc/manpages/options.asciidoc b/doc/manpages/options.asciidoc index 9bbba625..f0e14ea2 100644 --- a/doc/manpages/options.asciidoc +++ b/doc/manpages/options.asciidoc @@ -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=*::: where *opt-name* is an option of type 'completions' whose contents will be used diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 087dd00a..61670c5c 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -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{}; return; } + else if (str == "line") + { + opt.mode = InsertCompleterDesc::Line; + opt.param = Optional{}; + 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)) return true; + if (completer.mode == InsertCompleterDesc::Line and + try_complete(complete_line)) + return true; } return false; } diff --git a/src/insert_completer.hh b/src/insert_completer.hh index be65cc0b..ca04e3de 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -20,7 +20,8 @@ struct InsertCompleterDesc { Word, Option, - Filename + Filename, + Line }; bool operator==(const InsertCompleterDesc& other) const