Skip to content

Commit 7c2d46f

Browse files
chore: Upgrade every used neovim deprecated lua apis (#261)
* chore: Do not use any neovim deprecated apis * chore: Update docs for - chore: Do not use any neovim deprecated apis
1 parent c3ed9fb commit 7c2d46f

17 files changed

Lines changed: 263 additions & 252 deletions

.luarc.ci.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"param-type-mismatch": "Warning",
2424
"assign-type-mismatch": "Warning",
2525
"cast-type-mismatch": "Warning",
26-
"deprecated": "Hint",
27-
"undefined-doc-param": "Hint"
26+
"deprecated": "Warning",
27+
"undefined-doc-param": "Warning"
2828
},
2929
"neededFileStatus": {
3030
"undefined-global": "Any",

.luarc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"param-type-mismatch": "Warning",
2222
"assign-type-mismatch": "Warning",
2323
"cast-type-mismatch": "Warning",
24-
"deprecated": "Hint",
25-
"undefined-doc-param": "Hint"
24+
"deprecated": "Warning",
25+
"undefined-doc-param": "Warning"
2626
},
2727
"neededFileStatus": {
2828
"undefined-global": "Any",

Cargo.lock

Lines changed: 0 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ dunce = "1.0"
2020
# git2 - base config without TLS (each crate adds platform-specific TLS)
2121
git2 = { version = "0.20.2", default-features = false, features = [
2222
"vendored-libgit2",
23-
"vendored-openssl",
2423
] }
2524
glidesort = "0.1"
2625
grep-matcher = "0.1.8"

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ require('fff').setup({
176176
preview_scroll_down = '<C-d>',
177177
toggle_debug = '<F2>',
178178
-- grep mode: cycle between plain text, regex, and fuzzy search
179-
toggle_grep_regex = '<S-Tab>',
179+
cycle_grep_modes = '<S-Tab>',
180180
-- goes to the previous query in history
181181
cycle_previous_query = '<C-Up>',
182182
-- multi-select keymaps for quickfix
@@ -185,16 +185,14 @@ require('fff').setup({
185185
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
186186
focus_list = '<leader>l',
187187
focus_preview = '<leader>p',
188-
toggle_grep_regex = '<S-Tab>',
189188
},
190189
hl = {
191190
border = 'FloatBorder',
192191
normal = 'Normal',
193-
cursor = 'CursorLine',
192+
cursor = 'CursorLine', -- Falls back to 'Visual' if CursorLine is not defined
194193
matched = 'IncSearch',
195194
title = 'Title',
196195
prompt = 'Question',
197-
cursor = fallback_hl({ 'CursorLine', 'Visual' }),
198196
frecency = 'Number',
199197
debug = 'Comment',
200198
combo_header = 'Number',
@@ -271,7 +269,7 @@ require('fff').setup({
271269
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
272270
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
273271
},
274-
}})
272+
})
275273
```
276274

277275
### Key Features

crates/fff-core/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ smartstring = { version = "1.0.1", features = ["serde"] }
5050
tracing-appender = "0.2"
5151
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
5252
zlob = { workspace = true }
53-
54-
# Platform-specific: Use vendored OpenSSL on non-Windows (Linux, macOS)
55-
[target.'cfg(not(windows))'.dependencies]
56-
openssl = { version = "0.10", features = ["vendored"] }
57-
5853
# Platform-specific: dunce for Windows to avoid \\?\ extended path prefix
5954
[target.'cfg(windows)'.dependencies]
6055
dunce = { workspace = true }

crates/fff-nvim/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,3 @@ harness = false
7878
name = "query_tracker_bench"
7979
harness = false
8080

81-
# Platform-specific: Use vendored OpenSSL on non-Windows (Linux, macOS)
82-
# On Windows, git2 uses the native SChannel TLS backend
83-
[target.'cfg(not(windows))'.dependencies]
84-
openssl = { version = "0.10", features = ["vendored"] }

doc/fff.nvim.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 25
1+
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 26
22

33
==============================================================================
44
Table of Contents *fff.nvim-table-of-contents*
@@ -184,7 +184,7 @@ all available options:
184184
preview_scroll_down = '<C-d>',
185185
toggle_debug = '<F2>',
186186
-- grep mode: cycle between plain text, regex, and fuzzy search
187-
toggle_grep_regex = '<S-Tab>',
187+
cycle_grep_modes = '<S-Tab>',
188188
-- goes to the previous query in history
189189
cycle_previous_query = '<C-Up>',
190190
-- multi-select keymaps for quickfix
@@ -193,16 +193,14 @@ all available options:
193193
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
194194
focus_list = '<leader>l',
195195
focus_preview = '<leader>p',
196-
toggle_grep_regex = '<S-Tab>',
197196
},
198197
hl = {
199198
border = 'FloatBorder',
200199
normal = 'Normal',
201-
cursor = 'CursorLine',
200+
cursor = 'CursorLine', -- Falls back to 'Visual' if CursorLine is not defined
202201
matched = 'IncSearch',
203202
title = 'Title',
204203
prompt = 'Question',
205-
cursor = fallback_hl({ 'CursorLine', 'Visual' }),
206204
frecency = 'Number',
207205
debug = 'Comment',
208206
combo_header = 'Number',
@@ -279,7 +277,7 @@ all available options:
279277
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
280278
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
281279
},
282-
}})
280+
})
283281
<
284282

285283

lua/fff/combo_renderer.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,32 @@ end
5757

5858
local function apply_header_highlights(buf, ns_id, line_idx, text_len, border_hl)
5959
local config = require('fff.conf').get()
60-
vim.api.nvim_buf_add_highlight(buf, ns_id, border_hl, line_idx - 1, 0, -1)
61-
vim.api.nvim_buf_add_highlight(
60+
vim.api.nvim_buf_set_extmark(buf, ns_id, line_idx - 1, 0, { end_row = line_idx, end_col = 0, hl_group = border_hl })
61+
vim.api.nvim_buf_set_extmark(
6262
buf,
6363
ns_id,
64-
config.hl.combo_header,
6564
line_idx - 1,
6665
LEFT_HEADER_PADDING,
67-
LEFT_HEADER_PADDING + text_len
66+
{ end_col = LEFT_HEADER_PADDING + text_len, hl_group = config.hl.combo_header }
6867
)
6968
end
7069

7170
local function get_or_create_overlay_buf(state_key)
7271
if not overlay_state[state_key] or not vim.api.nvim_buf_is_valid(overlay_state[state_key]) then
7372
---@diagnostic disable-next-line: assign-type-mismatch
7473
overlay_state[state_key] = vim.api.nvim_create_buf(false, true)
75-
vim.api.nvim_buf_set_option(overlay_state[state_key], 'bufhidden', 'wipe')
74+
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = overlay_state[state_key] })
7675
end
7776
return overlay_state[state_key]
7877
end
7978

8079
local function update_overlay_content(buf, content, border_hl)
8180
-- Batch all buffer operations together for performance
82-
vim.api.nvim_buf_set_option(buf, 'modifiable', true)
81+
vim.api.nvim_set_option_value('modifiable', true, { buf = buf })
8382
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { content })
8483
vim.api.nvim_buf_clear_namespace(buf, overlay_state.ns_id, 0, -1)
85-
vim.api.nvim_buf_add_highlight(buf, overlay_state.ns_id, border_hl, 0, 0, -1)
86-
vim.api.nvim_buf_set_option(buf, 'modifiable', false)
84+
vim.api.nvim_buf_set_extmark(buf, overlay_state.ns_id, 0, 0, { end_row = 1, end_col = 0, hl_group = border_hl })
85+
vim.api.nvim_set_option_value('modifiable', false, { buf = buf })
8786
end
8887

8988
local function position_overlay_window(state_key, buf, width, row, col)
@@ -106,7 +105,7 @@ local function position_overlay_window(state_key, buf, width, row, col)
106105
overlay_state[state_key] = vim.api.nvim_open_win(buf, false, win_config)
107106
end
108107

109-
vim.api.nvim_win_set_option(overlay_state[state_key], 'winhl', 'Normal:Normal')
108+
vim.api.nvim_set_option_value('winhighlight', 'Normal:Normal', { win = overlay_state[state_key] })
110109
end
111110

112111
local function update_overlays(list_win, combo_header_line, border_hl)

lua/fff/conf.lua

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,81 @@
11
local M = {}
22

3-
--@class fff.conf.State
3+
--- @class FffLayoutConfig
4+
--- @field height number
5+
--- @field width number
6+
--- @field prompt_position string
7+
--- @field preview_position string
8+
--- @field preview_size number
9+
--- @field show_scrollbar boolean
10+
--- @field path_shorten_strategy string
11+
12+
--- @class FffPreviewConfig
13+
--- @field enabled boolean
14+
--- @field max_size number
15+
--- @field chunk_size number
16+
--- @field binary_file_threshold number
17+
--- @field imagemagick_info_format_str string
18+
--- @field line_numbers boolean
19+
--- @field wrap_lines boolean
20+
--- @field filetypes table<string, table>
21+
22+
--- @class FffKeymapsConfig
23+
--- @field close string
24+
--- @field select string
25+
--- @field select_split string
26+
--- @field select_vsplit string
27+
--- @field select_tab string
28+
--- @field move_up string|string[]
29+
--- @field move_down string|string[]
30+
--- @field preview_scroll_up string
31+
--- @field preview_scroll_down string
32+
--- @field toggle_debug string
33+
--- @field cycle_grep_modes string
34+
--- @field cycle_previous_query string
35+
--- @field toggle_select string
36+
--- @field send_to_quickfix string
37+
--- @field focus_list string
38+
--- @field focus_preview string
39+
40+
--- @class FffFrecencyConfig
41+
--- @field enabled boolean
42+
--- @field db_path string
43+
44+
--- @class FffHistoryConfig
45+
--- @field enabled boolean
46+
--- @field db_path string
47+
--- @field min_combo_count number
48+
--- @field combo_boost_score_multiplier number
49+
50+
--- @class FffGrepConfig
51+
--- @field max_file_size number
52+
--- @field max_matches_per_file number
53+
--- @field smart_case boolean
54+
--- @field time_budget_ms number
55+
--- @field modes string[]
56+
57+
--- @class FffConfig
58+
--- @field base_path string
59+
--- @field prompt string
60+
--- @field title string
61+
--- @field max_results number
62+
--- @field max_threads number
63+
--- @field lazy_sync boolean
64+
--- @field layout FffLayoutConfig
65+
--- @field preview FffPreviewConfig
66+
--- @field keymaps FffKeymapsConfig
67+
--- @field hl table<string, string>
68+
--- @field frecency FffFrecencyConfig
69+
--- @field history FffHistoryConfig
70+
--- @field git table
71+
--- @field debug table
72+
--- @field logging table
73+
--- @field file_picker table
74+
--- @field grep FffGrepConfig
75+
76+
---@class fff.conf.State
477
local state = {
5-
---@type table | nil
78+
---@type FffConfig|nil
679
config = nil,
780
}
881

@@ -162,7 +235,7 @@ local function init()
162235
preview_scroll_down = '<C-d>',
163236
toggle_debug = '<F2>',
164237
-- grep mode: cycle between plain text, regex, and fuzzy search
165-
toggle_grep_regex = '<S-Tab>',
238+
cycle_grep_modes = '<S-Tab>',
166239
-- goes to the previous query in history
167240
cycle_previous_query = '<C-Up>',
168241
-- multi-select keymaps for quickfix
@@ -264,10 +337,10 @@ local function init()
264337
end
265338

266339
--- Setup the file picker with the given configuration
267-
--- @param config table Configuration options
340+
--- @param config FffConfig Configuration options
268341
function M.setup(config) vim.g.fff = config end
269342

270-
--- @return table the fff configuration
343+
--- @return FffConfig the fff configuration
271344
function M.get()
272345
if not state.config then init() end
273346
return state.config

0 commit comments

Comments
 (0)