summaryrefslogtreecommitdiff
path: root/src/insert_completer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-03-23 08:22:34 +1100
committerMaxime Coste <mawww@kakoune.org>2018-03-23 08:22:34 +1100
commita732037b539db23010fcb379d643159670e05960 (patch)
treee0bd8f7a579310e86572858e12e5a3379a70fb31 /src/insert_completer.cc
parent42404ddb3a6822fd5777e7d2582b2fe74b43c48b (diff)
Support `%` in `path` option to mean current buffer directory
In the end, % is not that painful to work with as its only set seldomly, and we usually dont need to use expansion at the same time. Moreover, it just requires a single \ to be escaped. Fixes #1562
Diffstat (limited to 'src/insert_completer.cc')
-rw-r--r--src/insert_completer.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index 5bd1efe7..8db65556 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -246,6 +246,13 @@ InsertCompletion complete_filename(const SelectionList& sels,
{
if (not dir.empty() and dir.back() != '/')
dir += '/';
+ if (dir.substr(0, 2_byte) == "%/")
+ {
+ if (not (buffer.flags() & Buffer::Flags::File))
+ continue;
+ dir = split_path(buffer.name()).first.str() + '/' + dir.substr(2_byte);
+ }
+
for (auto& filename : Kakoune::complete_filename(dir + prefix,
options["ignored_files"].get<Regex>()))
{