Skip to content

Commit

Permalink
Add [:keyword:] support
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Sep 11, 2023
1 parent 7ebaf26 commit 190b133
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions denops/ddc/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ export async function convertKeywordPattern(
const iskeyword = bufnr === undefined
? await op.iskeyword.getLocal(denops)
: await op.iskeyword.getBuffer(denops, bufnr);
return keywordPattern.replaceAll(
const keyword = vimoption2ts(iskeyword);
const replaced = keywordPattern.replaceAll(
/\\k/g,
() => "[" + vimoption2ts(iskeyword) + "]",
);
() => "[" + keyword + "]",
).replaceAll(
/\[:keyword:\]/g,
() => keyword,
)
return replaced;
}

function vimoption2ts(option: string): string {
Expand Down
3 changes: 2 additions & 1 deletion doc/ddc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ forceCompletionPattern (string)
keywordPattern
It defines the keyword pattern for completion.
NOTE: It is JavaScript regexp.
NOTE: "\k" is converted to 'iskeyword' pattern.
NOTE: "\k" is converted to "['iskeyword']" pattern.
NOTE: "[:keyword:]" is converted to 'iskeyword' pattern.
NOTE: The source/filter must convert 'iskeyword' to use it.

Default: '\k*'
Expand Down

0 comments on commit 190b133

Please sign in to comment.