1
- local config = require (' blink.cmp.config' ). fuzzy
1
+ local config = require (' blink.cmp.config' )
2
2
3
3
local fuzzy = {
4
4
--- @type blink.cmp.Context ?
@@ -59,10 +59,10 @@ function fuzzy.filter_items(needle, items)
59
59
-- so this should generally be good
60
60
-- TODO: make this configurable
61
61
min_score = 6 * needle :len (),
62
- max_items = config .max_items ,
63
- use_frecency = config .use_frecency ,
64
- use_proximity = config .use_proximity ,
65
- sorts = config .sorts ,
62
+ max_items = config .fuzzy . max_items ,
63
+ use_frecency = config .fuzzy . use_frecency ,
64
+ use_proximity = config .fuzzy . use_proximity ,
65
+ sorts = config .fuzzy . sorts ,
66
66
nearby_words = nearby_words ,
67
67
})
68
68
@@ -88,18 +88,14 @@ function fuzzy.filter_items_with_cache(needle, context, items)
88
88
end
89
89
90
90
--- Gets the text under the cursor to be used for fuzzy matching
91
- --- @param regex string | nil
92
91
--- @return string
93
- function fuzzy .get_query (regex )
94
- if regex == nil then regex = ' [%w_\\ -]+$' end
95
-
96
- local bufnr = vim .api .nvim_get_current_buf ()
97
-
98
- local current_line = vim .api .nvim_win_get_cursor (0 )[1 ] - 1
99
- local current_col = vim .api .nvim_win_get_cursor (0 )[2 ] - 1
100
- local line = vim .api .nvim_buf_get_lines (bufnr , current_line , current_line + 1 , false )[1 ]
101
-
102
- return string.sub (line , 1 , current_col + 1 ):match (regex ) or ' '
92
+ function fuzzy .get_query ()
93
+ local line = vim .api .nvim_get_current_line ()
94
+ local range = require (' blink.cmp.utils' ).get_regex_around_cursor (
95
+ config .trigger .completion .keyword_regex ,
96
+ config .fuzzy .keyword_range
97
+ )
98
+ return string.sub (line , range [1 ] + 1 , range [2 ] + 1 )
103
99
end
104
100
105
101
return fuzzy
0 commit comments