diff --git a/lua/blink/cmp/completion/trigger/context.lua b/lua/blink/cmp/completion/trigger/context.lua index 26afe5be..a6b36ca0 100644 --- a/lua/blink/cmp/completion/trigger/context.lua +++ b/lua/blink/cmp/completion/trigger/context.lua @@ -17,6 +17,7 @@ --- @field providers string[] --- --- @field new fun(opts: blink.cmp.ContextOpts): blink.cmp.Context +--- @field get_keyword fun(): string --- @field within_query_bounds fun(self: blink.cmp.Context, cursor: number[]): boolean --- --- @field get_mode fun(): blink.cmp.Mode @@ -64,6 +65,12 @@ function context.new(opts) }, { __index = context }) end +function context.get_keyword() + local keyword = require('blink.cmp.config').completion.keyword + local range = context.get_bounds(keyword.range) + return string.sub(context.get_line(), range.start_col, range.start_col + range.length - 1) +end + --- @param cursor number[] --- @return boolean function context:within_query_bounds(cursor)