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
This commit is contained in:
committed by
GitHub
parent
c3ed9fb17b
commit
7c2d46f1e2
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
"param-type-mismatch": "Warning",
|
"param-type-mismatch": "Warning",
|
||||||
"assign-type-mismatch": "Warning",
|
"assign-type-mismatch": "Warning",
|
||||||
"cast-type-mismatch": "Warning",
|
"cast-type-mismatch": "Warning",
|
||||||
"deprecated": "Hint",
|
"deprecated": "Warning",
|
||||||
"undefined-doc-param": "Hint"
|
"undefined-doc-param": "Warning"
|
||||||
},
|
},
|
||||||
"neededFileStatus": {
|
"neededFileStatus": {
|
||||||
"undefined-global": "Any",
|
"undefined-global": "Any",
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@
|
|||||||
"param-type-mismatch": "Warning",
|
"param-type-mismatch": "Warning",
|
||||||
"assign-type-mismatch": "Warning",
|
"assign-type-mismatch": "Warning",
|
||||||
"cast-type-mismatch": "Warning",
|
"cast-type-mismatch": "Warning",
|
||||||
"deprecated": "Hint",
|
"deprecated": "Warning",
|
||||||
"undefined-doc-param": "Hint"
|
"undefined-doc-param": "Warning"
|
||||||
},
|
},
|
||||||
"neededFileStatus": {
|
"neededFileStatus": {
|
||||||
"undefined-global": "Any",
|
"undefined-global": "Any",
|
||||||
|
|||||||
Generated
-67
@@ -492,7 +492,6 @@ dependencies = [
|
|||||||
"notify",
|
"notify",
|
||||||
"notify-debouncer-full 0.7.0",
|
"notify-debouncer-full 0.7.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"openssl",
|
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -531,7 +530,6 @@ dependencies = [
|
|||||||
"notify",
|
"notify",
|
||||||
"notify-debouncer-full 0.6.0",
|
"notify-debouncer-full 0.6.0",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"openssl",
|
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"rand",
|
"rand",
|
||||||
"rayon",
|
"rayon",
|
||||||
@@ -564,21 +562,6 @@ dependencies = [
|
|||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "foreign-types"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
|
||||||
dependencies = [
|
|
||||||
"foreign-types-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "foreign-types-shared"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
@@ -630,7 +613,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"libgit2-sys",
|
"libgit2-sys",
|
||||||
"log",
|
"log",
|
||||||
"openssl-sys",
|
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -986,7 +968,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
"libz-sys",
|
"libz-sys",
|
||||||
"openssl-sys",
|
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1301,54 +1282,6 @@ version = "11.1.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl"
|
|
||||||
version = "0.10.73"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"cfg-if",
|
|
||||||
"foreign-types",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"openssl-macros",
|
|
||||||
"openssl-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl-macros"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl-src"
|
|
||||||
version = "300.5.1+3.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "735230c832b28c000e3bc117119e6466a663ec73506bc0a9907ea4187508e42a"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl-sys"
|
|
||||||
version = "0.9.109"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"openssl-src",
|
|
||||||
"pkg-config",
|
|
||||||
"vcpkg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "option-ext"
|
name = "option-ext"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ dunce = "1.0"
|
|||||||
# git2 - base config without TLS (each crate adds platform-specific TLS)
|
# git2 - base config without TLS (each crate adds platform-specific TLS)
|
||||||
git2 = { version = "0.20.2", default-features = false, features = [
|
git2 = { version = "0.20.2", default-features = false, features = [
|
||||||
"vendored-libgit2",
|
"vendored-libgit2",
|
||||||
"vendored-openssl",
|
|
||||||
] }
|
] }
|
||||||
glidesort = "0.1"
|
glidesort = "0.1"
|
||||||
grep-matcher = "0.1.8"
|
grep-matcher = "0.1.8"
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ require('fff').setup({
|
|||||||
preview_scroll_down = '<C-d>',
|
preview_scroll_down = '<C-d>',
|
||||||
toggle_debug = '<F2>',
|
toggle_debug = '<F2>',
|
||||||
-- grep mode: cycle between plain text, regex, and fuzzy search
|
-- grep mode: cycle between plain text, regex, and fuzzy search
|
||||||
toggle_grep_regex = '<S-Tab>',
|
cycle_grep_modes = '<S-Tab>',
|
||||||
-- goes to the previous query in history
|
-- goes to the previous query in history
|
||||||
cycle_previous_query = '<C-Up>',
|
cycle_previous_query = '<C-Up>',
|
||||||
-- multi-select keymaps for quickfix
|
-- multi-select keymaps for quickfix
|
||||||
@@ -185,16 +185,14 @@ require('fff').setup({
|
|||||||
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
|
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
|
||||||
focus_list = '<leader>l',
|
focus_list = '<leader>l',
|
||||||
focus_preview = '<leader>p',
|
focus_preview = '<leader>p',
|
||||||
toggle_grep_regex = '<S-Tab>',
|
|
||||||
},
|
},
|
||||||
hl = {
|
hl = {
|
||||||
border = 'FloatBorder',
|
border = 'FloatBorder',
|
||||||
normal = 'Normal',
|
normal = 'Normal',
|
||||||
cursor = 'CursorLine',
|
cursor = 'CursorLine', -- Falls back to 'Visual' if CursorLine is not defined
|
||||||
matched = 'IncSearch',
|
matched = 'IncSearch',
|
||||||
title = 'Title',
|
title = 'Title',
|
||||||
prompt = 'Question',
|
prompt = 'Question',
|
||||||
cursor = fallback_hl({ 'CursorLine', 'Visual' }),
|
|
||||||
frecency = 'Number',
|
frecency = 'Number',
|
||||||
debug = 'Comment',
|
debug = 'Comment',
|
||||||
combo_header = 'Number',
|
combo_header = 'Number',
|
||||||
@@ -271,7 +269,7 @@ require('fff').setup({
|
|||||||
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
|
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
|
||||||
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
|
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
|
||||||
},
|
},
|
||||||
}})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Key Features
|
### Key Features
|
||||||
|
|||||||
@@ -50,11 +50,6 @@ smartstring = { version = "1.0.1", features = ["serde"] }
|
|||||||
tracing-appender = "0.2"
|
tracing-appender = "0.2"
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
zlob = { workspace = true }
|
zlob = { workspace = true }
|
||||||
|
|
||||||
# Platform-specific: Use vendored OpenSSL on non-Windows (Linux, macOS)
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
|
||||||
|
|
||||||
# Platform-specific: dunce for Windows to avoid \\?\ extended path prefix
|
# Platform-specific: dunce for Windows to avoid \\?\ extended path prefix
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
dunce = { workspace = true }
|
dunce = { workspace = true }
|
||||||
|
|||||||
@@ -78,7 +78,3 @@ harness = false
|
|||||||
name = "query_tracker_bench"
|
name = "query_tracker_bench"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
# Platform-specific: Use vendored OpenSSL on non-Windows (Linux, macOS)
|
|
||||||
# On Windows, git2 uses the native SChannel TLS backend
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
|
||||||
|
|||||||
+4
-6
@@ -1,4 +1,4 @@
|
|||||||
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 25
|
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 26
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Table of Contents *fff.nvim-table-of-contents*
|
Table of Contents *fff.nvim-table-of-contents*
|
||||||
@@ -184,7 +184,7 @@ all available options:
|
|||||||
preview_scroll_down = '<C-d>',
|
preview_scroll_down = '<C-d>',
|
||||||
toggle_debug = '<F2>',
|
toggle_debug = '<F2>',
|
||||||
-- grep mode: cycle between plain text, regex, and fuzzy search
|
-- grep mode: cycle between plain text, regex, and fuzzy search
|
||||||
toggle_grep_regex = '<S-Tab>',
|
cycle_grep_modes = '<S-Tab>',
|
||||||
-- goes to the previous query in history
|
-- goes to the previous query in history
|
||||||
cycle_previous_query = '<C-Up>',
|
cycle_previous_query = '<C-Up>',
|
||||||
-- multi-select keymaps for quickfix
|
-- multi-select keymaps for quickfix
|
||||||
@@ -193,16 +193,14 @@ all available options:
|
|||||||
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
|
-- this are specific for the normal mode (you can exit it using any other keybind like jj)
|
||||||
focus_list = '<leader>l',
|
focus_list = '<leader>l',
|
||||||
focus_preview = '<leader>p',
|
focus_preview = '<leader>p',
|
||||||
toggle_grep_regex = '<S-Tab>',
|
|
||||||
},
|
},
|
||||||
hl = {
|
hl = {
|
||||||
border = 'FloatBorder',
|
border = 'FloatBorder',
|
||||||
normal = 'Normal',
|
normal = 'Normal',
|
||||||
cursor = 'CursorLine',
|
cursor = 'CursorLine', -- Falls back to 'Visual' if CursorLine is not defined
|
||||||
matched = 'IncSearch',
|
matched = 'IncSearch',
|
||||||
title = 'Title',
|
title = 'Title',
|
||||||
prompt = 'Question',
|
prompt = 'Question',
|
||||||
cursor = fallback_hl({ 'CursorLine', 'Visual' }),
|
|
||||||
frecency = 'Number',
|
frecency = 'Number',
|
||||||
debug = 'Comment',
|
debug = 'Comment',
|
||||||
combo_header = 'Number',
|
combo_header = 'Number',
|
||||||
@@ -279,7 +277,7 @@ all available options:
|
|||||||
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
|
time_budget_ms = 150, -- Max search time in ms per call (prevents UI freeze, 0 = no limit)
|
||||||
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
|
modes = { 'plain', 'regex', 'fuzzy' }, -- Available grep modes and their cycling order
|
||||||
},
|
},
|
||||||
}})
|
})
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,14 +57,13 @@ end
|
|||||||
|
|
||||||
local function apply_header_highlights(buf, ns_id, line_idx, text_len, border_hl)
|
local function apply_header_highlights(buf, ns_id, line_idx, text_len, border_hl)
|
||||||
local config = require('fff.conf').get()
|
local config = require('fff.conf').get()
|
||||||
vim.api.nvim_buf_add_highlight(buf, ns_id, border_hl, line_idx - 1, 0, -1)
|
vim.api.nvim_buf_set_extmark(buf, ns_id, line_idx - 1, 0, { end_row = line_idx, end_col = 0, hl_group = border_hl })
|
||||||
vim.api.nvim_buf_add_highlight(
|
vim.api.nvim_buf_set_extmark(
|
||||||
buf,
|
buf,
|
||||||
ns_id,
|
ns_id,
|
||||||
config.hl.combo_header,
|
|
||||||
line_idx - 1,
|
line_idx - 1,
|
||||||
LEFT_HEADER_PADDING,
|
LEFT_HEADER_PADDING,
|
||||||
LEFT_HEADER_PADDING + text_len
|
{ end_col = LEFT_HEADER_PADDING + text_len, hl_group = config.hl.combo_header }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -72,18 +71,18 @@ local function get_or_create_overlay_buf(state_key)
|
|||||||
if not overlay_state[state_key] or not vim.api.nvim_buf_is_valid(overlay_state[state_key]) then
|
if not overlay_state[state_key] or not vim.api.nvim_buf_is_valid(overlay_state[state_key]) then
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
---@diagnostic disable-next-line: assign-type-mismatch
|
||||||
overlay_state[state_key] = vim.api.nvim_create_buf(false, true)
|
overlay_state[state_key] = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(overlay_state[state_key], 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = overlay_state[state_key] })
|
||||||
end
|
end
|
||||||
return overlay_state[state_key]
|
return overlay_state[state_key]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_overlay_content(buf, content, border_hl)
|
local function update_overlay_content(buf, content, border_hl)
|
||||||
-- Batch all buffer operations together for performance
|
-- Batch all buffer operations together for performance
|
||||||
vim.api.nvim_buf_set_option(buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = buf })
|
||||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { content })
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { content })
|
||||||
vim.api.nvim_buf_clear_namespace(buf, overlay_state.ns_id, 0, -1)
|
vim.api.nvim_buf_clear_namespace(buf, overlay_state.ns_id, 0, -1)
|
||||||
vim.api.nvim_buf_add_highlight(buf, overlay_state.ns_id, border_hl, 0, 0, -1)
|
vim.api.nvim_buf_set_extmark(buf, overlay_state.ns_id, 0, 0, { end_row = 1, end_col = 0, hl_group = border_hl })
|
||||||
vim.api.nvim_buf_set_option(buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = buf })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function position_overlay_window(state_key, buf, width, row, col)
|
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)
|
|||||||
overlay_state[state_key] = vim.api.nvim_open_win(buf, false, win_config)
|
overlay_state[state_key] = vim.api.nvim_open_win(buf, false, win_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_win_set_option(overlay_state[state_key], 'winhl', 'Normal:Normal')
|
vim.api.nvim_set_option_value('winhighlight', 'Normal:Normal', { win = overlay_state[state_key] })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_overlays(list_win, combo_header_line, border_hl)
|
local function update_overlays(list_win, combo_header_line, border_hl)
|
||||||
|
|||||||
+78
-5
@@ -1,8 +1,81 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
--@class fff.conf.State
|
--- @class FffLayoutConfig
|
||||||
|
--- @field height number
|
||||||
|
--- @field width number
|
||||||
|
--- @field prompt_position string
|
||||||
|
--- @field preview_position string
|
||||||
|
--- @field preview_size number
|
||||||
|
--- @field show_scrollbar boolean
|
||||||
|
--- @field path_shorten_strategy string
|
||||||
|
|
||||||
|
--- @class FffPreviewConfig
|
||||||
|
--- @field enabled boolean
|
||||||
|
--- @field max_size number
|
||||||
|
--- @field chunk_size number
|
||||||
|
--- @field binary_file_threshold number
|
||||||
|
--- @field imagemagick_info_format_str string
|
||||||
|
--- @field line_numbers boolean
|
||||||
|
--- @field wrap_lines boolean
|
||||||
|
--- @field filetypes table<string, table>
|
||||||
|
|
||||||
|
--- @class FffKeymapsConfig
|
||||||
|
--- @field close string
|
||||||
|
--- @field select string
|
||||||
|
--- @field select_split string
|
||||||
|
--- @field select_vsplit string
|
||||||
|
--- @field select_tab string
|
||||||
|
--- @field move_up string|string[]
|
||||||
|
--- @field move_down string|string[]
|
||||||
|
--- @field preview_scroll_up string
|
||||||
|
--- @field preview_scroll_down string
|
||||||
|
--- @field toggle_debug string
|
||||||
|
--- @field cycle_grep_modes string
|
||||||
|
--- @field cycle_previous_query string
|
||||||
|
--- @field toggle_select string
|
||||||
|
--- @field send_to_quickfix string
|
||||||
|
--- @field focus_list string
|
||||||
|
--- @field focus_preview string
|
||||||
|
|
||||||
|
--- @class FffFrecencyConfig
|
||||||
|
--- @field enabled boolean
|
||||||
|
--- @field db_path string
|
||||||
|
|
||||||
|
--- @class FffHistoryConfig
|
||||||
|
--- @field enabled boolean
|
||||||
|
--- @field db_path string
|
||||||
|
--- @field min_combo_count number
|
||||||
|
--- @field combo_boost_score_multiplier number
|
||||||
|
|
||||||
|
--- @class FffGrepConfig
|
||||||
|
--- @field max_file_size number
|
||||||
|
--- @field max_matches_per_file number
|
||||||
|
--- @field smart_case boolean
|
||||||
|
--- @field time_budget_ms number
|
||||||
|
--- @field modes string[]
|
||||||
|
|
||||||
|
--- @class FffConfig
|
||||||
|
--- @field base_path string
|
||||||
|
--- @field prompt string
|
||||||
|
--- @field title string
|
||||||
|
--- @field max_results number
|
||||||
|
--- @field max_threads number
|
||||||
|
--- @field lazy_sync boolean
|
||||||
|
--- @field layout FffLayoutConfig
|
||||||
|
--- @field preview FffPreviewConfig
|
||||||
|
--- @field keymaps FffKeymapsConfig
|
||||||
|
--- @field hl table<string, string>
|
||||||
|
--- @field frecency FffFrecencyConfig
|
||||||
|
--- @field history FffHistoryConfig
|
||||||
|
--- @field git table
|
||||||
|
--- @field debug table
|
||||||
|
--- @field logging table
|
||||||
|
--- @field file_picker table
|
||||||
|
--- @field grep FffGrepConfig
|
||||||
|
|
||||||
|
---@class fff.conf.State
|
||||||
local state = {
|
local state = {
|
||||||
---@type table | nil
|
---@type FffConfig|nil
|
||||||
config = nil,
|
config = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +235,7 @@ local function init()
|
|||||||
preview_scroll_down = '<C-d>',
|
preview_scroll_down = '<C-d>',
|
||||||
toggle_debug = '<F2>',
|
toggle_debug = '<F2>',
|
||||||
-- grep mode: cycle between plain text, regex, and fuzzy search
|
-- grep mode: cycle between plain text, regex, and fuzzy search
|
||||||
toggle_grep_regex = '<S-Tab>',
|
cycle_grep_modes = '<S-Tab>',
|
||||||
-- goes to the previous query in history
|
-- goes to the previous query in history
|
||||||
cycle_previous_query = '<C-Up>',
|
cycle_previous_query = '<C-Up>',
|
||||||
-- multi-select keymaps for quickfix
|
-- multi-select keymaps for quickfix
|
||||||
@@ -264,10 +337,10 @@ local function init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Setup the file picker with the given configuration
|
--- Setup the file picker with the given configuration
|
||||||
--- @param config table Configuration options
|
--- @param config FffConfig Configuration options
|
||||||
function M.setup(config) vim.g.fff = config end
|
function M.setup(config) vim.g.fff = config end
|
||||||
|
|
||||||
--- @return table the fff configuration
|
--- @return FffConfig the fff configuration
|
||||||
function M.get()
|
function M.get()
|
||||||
if not state.config then init() end
|
if not state.config then init() end
|
||||||
return state.config
|
return state.config
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ local function reserve_image_buffer_space(bufnr, metadata_lines_count)
|
|||||||
table.insert(buffer_lines, '')
|
table.insert(buffer_lines, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
local was_modifiable = vim.api.nvim_buf_get_option(bufnr, 'modifiable')
|
local was_modifiable = vim.api.nvim_get_option_value('modifiable', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
|
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, buffer_lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, buffer_lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', was_modifiable)
|
vim.api.nvim_set_option_value('modifiable', was_modifiable, { buf = bufnr })
|
||||||
|
|
||||||
return metadata_lines_count or 2
|
return metadata_lines_count or 2
|
||||||
end
|
end
|
||||||
@@ -44,9 +44,9 @@ local function update_metadata_lines(bufnr, info_lines, reserved_lines_count)
|
|||||||
metadata_lines[i] = info_lines[i] or ''
|
metadata_lines[i] = info_lines[i] or ''
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, reserved_lines_count, false, metadata_lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, reserved_lines_count, false, metadata_lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function identify_image_lines_async(file_path, bufnr, callback)
|
local function identify_image_lines_async(file_path, bufnr, callback)
|
||||||
@@ -146,7 +146,10 @@ end
|
|||||||
--- @param bufnr number Buffer number to display in
|
--- @param bufnr number Buffer number to display in
|
||||||
--- @return boolean
|
--- @return boolean
|
||||||
function M.display_image(file_path, bufnr)
|
function M.display_image(file_path, bufnr)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'number', false)
|
local wins = vim.fn.win_findbuf(bufnr)
|
||||||
|
for _, win in ipairs(wins) do
|
||||||
|
vim.api.nvim_set_option_value('number', false, { win = win })
|
||||||
|
end
|
||||||
|
|
||||||
local reserved_metadata_lines = reserve_image_buffer_space(bufnr, 2)
|
local reserved_metadata_lines = reserve_image_buffer_space(bufnr, 2)
|
||||||
local image_content_starts_at_line = reserved_metadata_lines + 1
|
local image_content_starts_at_line = reserved_metadata_lines + 1
|
||||||
@@ -163,9 +166,9 @@ function M.display_image(file_path, bufnr)
|
|||||||
'',
|
'',
|
||||||
'snacks.nvim plugin is not installed or not available.',
|
'snacks.nvim plugin is not installed or not available.',
|
||||||
}
|
}
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -176,9 +179,9 @@ function M.display_image(file_path, bufnr)
|
|||||||
'Terminal does not support image preview.',
|
'Terminal does not support image preview.',
|
||||||
'Please use a terminal that supports images, such as Kitty, Wezterm or Alacritty.',
|
'Please use a terminal that supports images, such as Kitty, Wezterm or Alacritty.',
|
||||||
}
|
}
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -189,9 +192,9 @@ function M.display_image(file_path, bufnr)
|
|||||||
'File format is not supported for image preview.',
|
'File format is not supported for image preview.',
|
||||||
'File: ' .. vim.fn.fnamemodify(file_path, ':t'),
|
'File: ' .. vim.fn.fnamemodify(file_path, ':t'),
|
||||||
}
|
}
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
vim.api.nvim_buf_set_lines(bufnr, image_content_starts_at_line, -1, false, error_lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ local M = {}
|
|||||||
local function set_buffer_lines(bufnr, lines)
|
local function set_buffer_lines(bufnr, lines)
|
||||||
if not bufnr or not vim.api.nvim_buf_is_valid(bufnr) then return end
|
if not bufnr or not vim.api.nvim_buf_is_valid(bufnr) then return end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function append_buffer_lines(bufnr, lines)
|
local function append_buffer_lines(bufnr, lines)
|
||||||
if not bufnr or not vim.api.nvim_buf_is_valid(bufnr) then return end
|
if not bufnr or not vim.api.nvim_buf_is_valid(bufnr) then return end
|
||||||
if not lines or #lines == 0 then return end
|
if not lines or #lines == 0 then return end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
local current_lines = vim.api.nvim_buf_line_count(bufnr)
|
local current_lines = vim.api.nvim_buf_line_count(bufnr)
|
||||||
vim.api.nvim_buf_set_lines(bufnr, current_lines, current_lines, false, lines)
|
vim.api.nvim_buf_set_lines(bufnr, current_lines, current_lines, false, lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function find_existing_buffer(file_path)
|
local function find_existing_buffer(file_path)
|
||||||
@@ -272,8 +272,8 @@ local function link_buffer_content(source_bufnr, target_bufnr)
|
|||||||
local lines = vim.api.nvim_buf_get_lines(source_bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(source_bufnr, 0, -1, false)
|
||||||
set_buffer_lines(target_bufnr, lines)
|
set_buffer_lines(target_bufnr, lines)
|
||||||
|
|
||||||
local source_ft = vim.api.nvim_buf_get_option(source_bufnr, 'filetype')
|
local source_ft = vim.api.nvim_get_option_value('filetype', { buf = source_bufnr })
|
||||||
if source_ft ~= '' then vim.api.nvim_buf_set_option(target_bufnr, 'filetype', source_ft) end
|
if source_ft ~= '' then vim.api.nvim_set_option_value('filetype', source_ft, { buf = target_bufnr }) end
|
||||||
|
|
||||||
M.state.has_more_content = false
|
M.state.has_more_content = false
|
||||||
M.state.total_file_lines = #lines
|
M.state.total_file_lines = #lines
|
||||||
@@ -315,7 +315,6 @@ end
|
|||||||
|
|
||||||
--- Check if file is too big for initial preview (inspired by snacks.nvim)
|
--- Check if file is too big for initial preview (inspired by snacks.nvim)
|
||||||
--- @param file_path string Path to the file
|
--- @param file_path string Path to the file
|
||||||
--- @param bufnr number|nil Buffer number to check (unused with dynamic loading)
|
|
||||||
--- @return boolean True if file is too big for initial preview
|
--- @return boolean True if file is too big for initial preview
|
||||||
function M.is_big_file(file_path)
|
function M.is_big_file(file_path)
|
||||||
-- Only check file size for early detection - no line limits with dynamic loading
|
-- Only check file size for early detection - no line limits with dynamic loading
|
||||||
@@ -485,10 +484,12 @@ function M.preview_file(file_path, bufnr)
|
|||||||
if success then
|
if success then
|
||||||
local file_config = M.get_file_config(file_path)
|
local file_config = M.get_file_config(file_path)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
|
vim.api.nvim_set_option_value('readonly', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'wrap', file_config.wrap_lines or M.config.wrap_lines)
|
if M.state.winid and vim.api.nvim_win_is_valid(M.state.winid) then
|
||||||
|
vim.api.nvim_set_option_value('wrap', file_config.wrap_lines or M.config.wrap_lines, { win = M.state.winid })
|
||||||
|
end
|
||||||
|
|
||||||
M.state.scroll_offset = 0
|
M.state.scroll_offset = 0
|
||||||
|
|
||||||
@@ -528,11 +529,13 @@ function M.preview_file(file_path, bufnr)
|
|||||||
set_buffer_lines(bufnr, content)
|
set_buffer_lines(bufnr, content)
|
||||||
|
|
||||||
local file_config = M.get_file_config(file_path)
|
local file_config = M.get_file_config(file_path)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'filetype', info.filetype)
|
vim.api.nvim_set_option_value('filetype', info.filetype, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
|
vim.api.nvim_set_option_value('readonly', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'wrap', file_config.wrap_lines or M.config.wrap_lines)
|
if M.state.winid and vim.api.nvim_win_is_valid(M.state.winid) then
|
||||||
|
vim.api.nvim_set_option_value('wrap', file_config.wrap_lines or M.config.wrap_lines, { win = M.state.winid })
|
||||||
|
end
|
||||||
|
|
||||||
M.state.content_height = #content
|
M.state.content_height = #content
|
||||||
M.state.scroll_offset = 0
|
M.state.scroll_offset = 0
|
||||||
@@ -560,9 +563,9 @@ function M.preview_binary_file(file_path, bufnr)
|
|||||||
local lines = {}
|
local lines = {}
|
||||||
|
|
||||||
set_buffer_lines(bufnr, lines)
|
set_buffer_lines(bufnr, lines)
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'filetype', 'text')
|
vim.api.nvim_set_option_value('filetype', 'text', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
|
vim.api.nvim_set_option_value('readonly', true, { buf = bufnr })
|
||||||
|
|
||||||
if vim.fn.executable('file') == 1 then
|
if vim.fn.executable('file') == 1 then
|
||||||
local cmd = { 'file', '-b', file_path }
|
local cmd = { 'file', '-b', file_path }
|
||||||
@@ -726,10 +729,10 @@ function M.update_file_info_buffer(file, bufnr, file_index)
|
|||||||
end
|
end
|
||||||
set_buffer_lines(bufnr, file_info_lines)
|
set_buffer_lines(bufnr, file_info_lines)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
|
vim.api.nvim_set_option_value('readonly', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'wrap', false)
|
vim.api.nvim_set_option_value('wrap', false, { buf = bufnr })
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -769,10 +772,10 @@ function M.clear_buffer(bufnr)
|
|||||||
|
|
||||||
pcall(vim.treesitter.stop, bufnr)
|
pcall(vim.treesitter.stop, bufnr)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'filetype', '')
|
vim.api.nvim_set_option_value('filetype', '', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'syntax', '')
|
vim.api.nvim_set_option_value('syntax', '', { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = bufnr })
|
||||||
|
|
||||||
set_buffer_lines(bufnr, {})
|
set_buffer_lines(bufnr, {})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -106,7 +106,13 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
|
|||||||
-- 2. Icon
|
-- 2. Icon
|
||||||
if icon and icon_hl_group and vim.fn.strdisplaywidth(icon) > 0 then
|
if icon and icon_hl_group and vim.fn.strdisplaywidth(icon) > 0 then
|
||||||
local icon_hl = is_current_file and 'Comment' or icon_hl_group
|
local icon_hl = is_current_file and 'Comment' or icon_hl_group
|
||||||
vim.api.nvim_buf_add_highlight(buf, ns_id, icon_hl, line_idx - 1, 0, vim.fn.strdisplaywidth(icon))
|
vim.api.nvim_buf_set_extmark(
|
||||||
|
buf,
|
||||||
|
ns_id,
|
||||||
|
line_idx - 1,
|
||||||
|
0,
|
||||||
|
{ end_col = vim.fn.strdisplaywidth(icon), hl_group = icon_hl }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 3. Git text color (filename)
|
-- 3. Git text color (filename)
|
||||||
@@ -114,7 +120,13 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
|
|||||||
local git_text_hl = item.git_status and git_utils.get_text_highlight(item.git_status) or nil
|
local git_text_hl = item.git_status and git_utils.get_text_highlight(item.git_status) or nil
|
||||||
if git_text_hl and git_text_hl ~= '' and not is_current_file then
|
if git_text_hl and git_text_hl ~= '' and not is_current_file then
|
||||||
local filename_start = #icon + 1
|
local filename_start = #icon + 1
|
||||||
vim.api.nvim_buf_add_highlight(buf, ns_id, git_text_hl, line_idx - 1, filename_start, filename_start + #filename)
|
vim.api.nvim_buf_set_extmark(
|
||||||
|
buf,
|
||||||
|
ns_id,
|
||||||
|
line_idx - 1,
|
||||||
|
filename_start,
|
||||||
|
{ end_col = filename_start + #filename, hl_group = git_text_hl }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -122,7 +134,13 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
|
|||||||
if ctx.debug_enabled then
|
if ctx.debug_enabled then
|
||||||
local start_pos, end_pos = line_content:find('[⭐️🔥✨•]%d+')
|
local start_pos, end_pos = line_content:find('[⭐️🔥✨•]%d+')
|
||||||
if start_pos and end_pos then
|
if start_pos and end_pos then
|
||||||
vim.api.nvim_buf_add_highlight(buf, ns_id, ctx.config.hl.frecency, line_idx - 1, start_pos - 1, end_pos)
|
vim.api.nvim_buf_set_extmark(
|
||||||
|
buf,
|
||||||
|
ns_id,
|
||||||
|
line_idx - 1,
|
||||||
|
start_pos - 1,
|
||||||
|
{ end_col = end_pos, hl_group = ctx.config.hl.frecency }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -132,13 +150,12 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
|
|||||||
if icon then
|
if icon then
|
||||||
prefix_len = prefix_len + #icon + 1 -- if icon add icon bytes + space
|
prefix_len = prefix_len + #icon + 1 -- if icon add icon bytes + space
|
||||||
end
|
end
|
||||||
vim.api.nvim_buf_add_highlight(
|
vim.api.nvim_buf_set_extmark(
|
||||||
buf,
|
buf,
|
||||||
ns_id,
|
ns_id,
|
||||||
ctx.config.hl.directory_path,
|
|
||||||
line_idx - 1,
|
line_idx - 1,
|
||||||
prefix_len,
|
prefix_len,
|
||||||
prefix_len + #dir_path
|
{ end_col = prefix_len + #dir_path, hl_group = ctx.config.hl.directory_path }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -210,13 +227,12 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
|
|||||||
if ctx.query and ctx.query ~= '' then
|
if ctx.query and ctx.query ~= '' then
|
||||||
local match_start, match_end = string.find(line_content, ctx.query, 1)
|
local match_start, match_end = string.find(line_content, ctx.query, 1)
|
||||||
if match_start and match_end then
|
if match_start and match_end then
|
||||||
vim.api.nvim_buf_add_highlight(
|
vim.api.nvim_buf_set_extmark(
|
||||||
buf,
|
buf,
|
||||||
ns_id,
|
ns_id,
|
||||||
ctx.config.hl.matched or 'IncSearch',
|
|
||||||
line_idx - 1,
|
line_idx - 1,
|
||||||
match_start - 1,
|
match_start - 1,
|
||||||
match_end
|
{ end_col = match_end, hl_group = ctx.config.hl.matched or 'IncSearch' }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
--- @class ListRenderContext
|
--- @class ListRenderContext
|
||||||
--- @field config table User configuration
|
--- @field config FffConfig User configuration
|
||||||
--- @field items table[] Array of data items to render
|
--- @field items table[] Array of data items to render
|
||||||
--- @field cursor number Current cursor position (1-based index into items)
|
--- @field cursor number Current cursor position (1-based index into items)
|
||||||
--- @field win_height number Window height in lines
|
--- @field win_height number Window height in lines
|
||||||
@@ -162,9 +162,9 @@ local function update_buffer_and_cursor(lines, item_to_lines, ctx, list_buf, lis
|
|||||||
if cursor_item then cursor_line = cursor_item.last end
|
if cursor_item then cursor_line = cursor_item.last end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(list_buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = list_buf })
|
||||||
vim.api.nvim_buf_set_lines(list_buf, 0, -1, false, lines)
|
vim.api.nvim_buf_set_lines(list_buf, 0, -1, false, lines)
|
||||||
vim.api.nvim_buf_set_option(list_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = list_buf })
|
||||||
|
|
||||||
vim.api.nvim_buf_clear_namespace(list_buf, ns_id, 0, -1)
|
vim.api.nvim_buf_clear_namespace(list_buf, ns_id, 0, -1)
|
||||||
|
|
||||||
@@ -225,7 +225,14 @@ function M.render(ctx, list_buf, list_win, ns_id)
|
|||||||
for i = 0, #lines - 1 do
|
for i = 0, #lines - 1 do
|
||||||
local line = lines[i + 1]
|
local line = lines[i + 1]
|
||||||
if line and line:match('^%s+No results found') then
|
if line and line:match('^%s+No results found') then
|
||||||
pcall(vim.api.nvim_buf_add_highlight, list_buf, ns_id, suggestion_hl, i, 0, -1)
|
pcall(
|
||||||
|
vim.api.nvim_buf_set_extmark,
|
||||||
|
list_buf,
|
||||||
|
ns_id,
|
||||||
|
i,
|
||||||
|
0,
|
||||||
|
{ end_row = i + 1, end_col = 0, hl_group = suggestion_hl }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+5
-12
@@ -18,14 +18,7 @@ function M.find_files(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Live grep: search file contents in the current directory
|
--- Live grep: search file contents in the current directory
|
||||||
--- @param opts? table Optional configuration overrides
|
--- @param opts? {cwd?: string, title?: string, prompt?: string, layout?: table, grep?: {max_file_size?: number, smart_case?: boolean, max_matches_per_file?: number, modes?: string[]}, query?: string} Optional configuration overrides
|
||||||
--- @param opts.cwd? string Custom working directory
|
|
||||||
--- @param opts.title? string Window title (default: "Live Grep")
|
|
||||||
--- @param opts.prompt? string Input prompt text (default: "grep> ")
|
|
||||||
--- @param opts.layout? table Layout overrides
|
|
||||||
--- @param opts.grep? table Grep-specific overrides {max_file_size, smart_case, max_matches_per_file, modes}
|
|
||||||
--- @param opts.grep.modes? table Available search modes and their cycling order (default: {'plain', 'regex', 'fuzzy'})
|
|
||||||
--- @param opts.query? string Initial search query to pre-fill
|
|
||||||
function M.live_grep(opts)
|
function M.live_grep(opts)
|
||||||
local picker_ok, picker_ui = pcall(require, 'fff.picker_ui')
|
local picker_ok, picker_ui = pcall(require, 'fff.picker_ui')
|
||||||
if not picker_ok then
|
if not picker_ok then
|
||||||
@@ -38,13 +31,13 @@ function M.live_grep(opts)
|
|||||||
|
|
||||||
local grep_config = vim.tbl_deep_extend('force', config.grep or {}, (opts and opts.grep) or {})
|
local grep_config = vim.tbl_deep_extend('force', config.grep or {}, (opts and opts.grep) or {})
|
||||||
|
|
||||||
local picker_opts = vim.tbl_deep_extend('force', opts or {}, {
|
local picker_opts = vim.tbl_deep_extend('force', {
|
||||||
title = (opts and opts.title) or 'Live Grep',
|
title = 'Live Grep',
|
||||||
mode = 'grep',
|
mode = 'grep',
|
||||||
renderer = grep_renderer,
|
renderer = grep_renderer,
|
||||||
grep_config = grep_config,
|
grep_config = grep_config,
|
||||||
query = opts and opts.query or nil,
|
query = '',
|
||||||
})
|
}, opts or {})
|
||||||
|
|
||||||
picker_ui.open(picker_opts)
|
picker_ui.open(picker_opts)
|
||||||
end
|
end
|
||||||
|
|||||||
+75
-77
@@ -447,19 +447,19 @@ function M.create_ui()
|
|||||||
M.state.layout = layout
|
M.state.layout = layout
|
||||||
|
|
||||||
M.state.input_buf = vim.api.nvim_create_buf(false, true)
|
M.state.input_buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(M.state.input_buf, 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = M.state.input_buf })
|
||||||
|
|
||||||
M.state.list_buf = vim.api.nvim_create_buf(false, true)
|
M.state.list_buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = M.state.list_buf })
|
||||||
|
|
||||||
if M.enabled_preview() then
|
if M.enabled_preview() then
|
||||||
M.state.preview_buf = vim.api.nvim_create_buf(false, true)
|
M.state.preview_buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = M.state.preview_buf })
|
||||||
end
|
end
|
||||||
|
|
||||||
if debug_enabled_in_preview then
|
if debug_enabled_in_preview then
|
||||||
M.state.file_info_buf = vim.api.nvim_create_buf(false, true)
|
M.state.file_info_buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = M.state.file_info_buf })
|
||||||
else
|
else
|
||||||
M.state.file_info_buf = nil
|
M.state.file_info_buf = nil
|
||||||
end
|
end
|
||||||
@@ -581,8 +581,8 @@ function M.setup_buffers()
|
|||||||
vim.api.nvim_buf_set_name(M.state.list_buf, 'fffiles list')
|
vim.api.nvim_buf_set_name(M.state.list_buf, 'fffiles list')
|
||||||
if M.enabled_preview() then vim.api.nvim_buf_set_name(M.state.preview_buf, 'fffile preview') end
|
if M.enabled_preview() then vim.api.nvim_buf_set_name(M.state.preview_buf, 'fffile preview') end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(M.state.input_buf, 'buftype', 'prompt')
|
vim.api.nvim_set_option_value('buftype', 'prompt', { buf = M.state.input_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.input_buf, 'filetype', 'fff_input')
|
vim.api.nvim_set_option_value('filetype', 'fff_input', { buf = M.state.input_buf })
|
||||||
|
|
||||||
vim.fn.prompt_setprompt(M.state.input_buf, M.state.config.prompt)
|
vim.fn.prompt_setprompt(M.state.input_buf, M.state.config.prompt)
|
||||||
|
|
||||||
@@ -590,23 +590,23 @@ function M.setup_buffers()
|
|||||||
-- syntax highlighting. This makes sure that it's always off.
|
-- syntax highlighting. This makes sure that it's always off.
|
||||||
vim.api.nvim_create_autocmd('Syntax', {
|
vim.api.nvim_create_autocmd('Syntax', {
|
||||||
buffer = M.state.input_buf,
|
buffer = M.state.input_buf,
|
||||||
callback = function() vim.api.nvim_buf_set_option(M.state.input_buf, 'syntax', '') end,
|
callback = function() vim.api.nvim_set_option_value('syntax', '', { buf = M.state.input_buf }) end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = M.state.list_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'filetype', 'fff_list')
|
vim.api.nvim_set_option_value('filetype', 'fff_list', { buf = M.state.list_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.list_buf })
|
||||||
|
|
||||||
if M.state.file_info_buf then
|
if M.state.file_info_buf then
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = M.state.file_info_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'filetype', 'fff_file_info')
|
vim.api.nvim_set_option_value('filetype', 'fff_file_info', { buf = M.state.file_info_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.file_info_buf })
|
||||||
end
|
end
|
||||||
|
|
||||||
if M.enabled_preview() then
|
if M.enabled_preview() then
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'buftype', 'nofile')
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = M.state.preview_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'filetype', 'fff_preview')
|
vim.api.nvim_set_option_value('filetype', 'fff_preview', { buf = M.state.preview_buf })
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.preview_buf })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -614,34 +614,34 @@ function M.setup_windows()
|
|||||||
local hl = M.state.config.hl
|
local hl = M.state.config.hl
|
||||||
local win_hl = string.format('Normal:%s,FloatBorder:%s,FloatTitle:%s', hl.normal, hl.border, hl.title)
|
local win_hl = string.format('Normal:%s,FloatBorder:%s,FloatTitle:%s', hl.normal, hl.border, hl.title)
|
||||||
|
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'wrap', false)
|
vim.api.nvim_set_option_value('wrap', false, { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'cursorline', false)
|
vim.api.nvim_set_option_value('cursorline', false, { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'number', false)
|
vim.api.nvim_set_option_value('number', false, { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'relativenumber', false)
|
vim.api.nvim_set_option_value('relativenumber', false, { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'signcolumn', 'no')
|
vim.api.nvim_set_option_value('signcolumn', 'no', { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'foldcolumn', '0')
|
vim.api.nvim_set_option_value('foldcolumn', '0', { win = M.state.input_win })
|
||||||
vim.api.nvim_win_set_option(M.state.input_win, 'winhighlight', win_hl)
|
vim.api.nvim_set_option_value('winhighlight', win_hl, { win = M.state.input_win })
|
||||||
|
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'wrap', false)
|
vim.api.nvim_set_option_value('wrap', false, { win = M.state.list_win })
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'cursorline', false)
|
vim.api.nvim_set_option_value('cursorline', false, { win = M.state.list_win })
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'number', false)
|
vim.api.nvim_set_option_value('number', false, { win = M.state.list_win })
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'relativenumber', false)
|
vim.api.nvim_set_option_value('relativenumber', false, { win = M.state.list_win })
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'signcolumn', 'yes:1') -- Enable signcolumn for git status borders
|
vim.api.nvim_set_option_value('signcolumn', 'yes:1', { win = M.state.list_win }) -- Enable signcolumn for git status borders
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'foldcolumn', '0')
|
vim.api.nvim_set_option_value('foldcolumn', '0', { win = M.state.list_win })
|
||||||
vim.api.nvim_win_set_option(M.state.list_win, 'winhighlight', win_hl)
|
vim.api.nvim_set_option_value('winhighlight', win_hl, { win = M.state.list_win })
|
||||||
|
|
||||||
if M.enabled_preview() then
|
if M.enabled_preview() then
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'wrap', false)
|
vim.api.nvim_set_option_value('wrap', false, { win = M.state.preview_win })
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'cursorline', M.state.mode == 'grep')
|
vim.api.nvim_set_option_value('cursorline', M.state.mode == 'grep', { win = M.state.preview_win })
|
||||||
vim.api.nvim_win_set_option(
|
vim.api.nvim_set_option_value(
|
||||||
M.state.preview_win,
|
|
||||||
'number',
|
'number',
|
||||||
M.state.mode == 'grep' or (preview_config and preview_config.line_numbers or false)
|
M.state.mode == 'grep' or (preview_config and preview_config.line_numbers or false),
|
||||||
|
{ win = M.state.preview_win }
|
||||||
)
|
)
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'relativenumber', false)
|
vim.api.nvim_set_option_value('relativenumber', false, { win = M.state.preview_win })
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'signcolumn', 'no')
|
vim.api.nvim_set_option_value('signcolumn', 'no', { win = M.state.preview_win })
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'foldcolumn', '0')
|
vim.api.nvim_set_option_value('foldcolumn', '0', { win = M.state.preview_win })
|
||||||
vim.api.nvim_win_set_option(M.state.preview_win, 'winhighlight', win_hl)
|
vim.api.nvim_set_option_value('winhighlight', win_hl, { win = M.state.preview_win })
|
||||||
end
|
end
|
||||||
|
|
||||||
local picker_group = vim.api.nvim_create_augroup('fff_picker_focus', { clear = true })
|
local picker_group = vim.api.nvim_create_augroup('fff_picker_focus', { clear = true })
|
||||||
@@ -779,7 +779,7 @@ function M.setup_keymaps()
|
|||||||
set_keymap({ 'i', 'n' }, keymaps.toggle_debug, M.toggle_debug, input_opts)
|
set_keymap({ 'i', 'n' }, keymaps.toggle_debug, M.toggle_debug, input_opts)
|
||||||
set_keymap({ 'i', 'n' }, keymaps.toggle_select, M.toggle_select, input_opts)
|
set_keymap({ 'i', 'n' }, keymaps.toggle_select, M.toggle_select, input_opts)
|
||||||
set_keymap({ 'i', 'n' }, keymaps.send_to_quickfix, M.send_to_quickfix, input_opts)
|
set_keymap({ 'i', 'n' }, keymaps.send_to_quickfix, M.send_to_quickfix, input_opts)
|
||||||
set_keymap({ 'i', 'n' }, keymaps.toggle_grep_regex, M.toggle_grep_regex, input_opts)
|
set_keymap({ 'i', 'n' }, keymaps.cycle_grep_modes, M.cycle_grep_modes, input_opts)
|
||||||
|
|
||||||
-- List buffer
|
-- List buffer
|
||||||
set_keymap('n', keymaps.close, M.close, list_opts)
|
set_keymap('n', keymaps.close, M.close, list_opts)
|
||||||
@@ -878,7 +878,7 @@ end
|
|||||||
--- Cycle through grep search modes based on configured modes list.
|
--- Cycle through grep search modes based on configured modes list.
|
||||||
--- Only works when the picker is in grep mode. Triggers a re-search
|
--- Only works when the picker is in grep mode. Triggers a re-search
|
||||||
--- with the current query using the new mode.
|
--- with the current query using the new mode.
|
||||||
function M.toggle_grep_regex()
|
function M.cycle_grep_modes()
|
||||||
if not M.state.active or M.state.mode ~= 'grep' then return end
|
if not M.state.active or M.state.mode ~= 'grep' then return end
|
||||||
|
|
||||||
local config = conf.get()
|
local config = conf.get()
|
||||||
@@ -929,7 +929,7 @@ function M.on_input_change()
|
|||||||
|
|
||||||
query = query:gsub('\r', ''):match('^%s*(.-)%s*$') or ''
|
query = query:gsub('\r', ''):match('^%s*(.-)%s*$') or ''
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(M.state.input_buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = M.state.input_buf })
|
||||||
vim.api.nvim_buf_set_lines(M.state.input_buf, 0, -1, false, { M.state.config.prompt .. query })
|
vim.api.nvim_buf_set_lines(M.state.input_buf, 0, -1, false, { M.state.config.prompt .. query })
|
||||||
|
|
||||||
-- Move cursor to end
|
-- Move cursor to end
|
||||||
@@ -1125,7 +1125,7 @@ function M.load_page_at_index(new_page_index, adjust_cursor_fn)
|
|||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
vim.notify('Error in paginated search: ' .. tostring(results), vim.log.levels.ERROR)
|
vim.notify('Error in paginated search: ' .. tostring(results), vim.log.levels.ERROR)
|
||||||
vim.api.nvim_err_writeln('FFF ERROR: Paginated search failed: ' .. tostring(results))
|
vim.notify('FFF ERROR: Paginated search failed: ' .. tostring(results))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1343,16 +1343,23 @@ local function render_grep_empty_state(ctx)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = M.state.list_buf })
|
||||||
vim.api.nvim_buf_set_lines(M.state.list_buf, 0, -1, false, content)
|
vim.api.nvim_buf_set_lines(M.state.list_buf, 0, -1, false, content)
|
||||||
vim.api.nvim_buf_set_option(M.state.list_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.list_buf })
|
||||||
|
|
||||||
vim.api.nvim_buf_clear_namespace(M.state.list_buf, M.state.ns_id, 0, -1)
|
vim.api.nvim_buf_clear_namespace(M.state.list_buf, M.state.ns_id, 0, -1)
|
||||||
|
|
||||||
-- For bottom prompt, ensure empty state is anchored at the bottom
|
-- For bottom prompt, ensure empty state is anchored at the bottom
|
||||||
if prompt_position == 'bottom' then scroll_to_bottom() end
|
if prompt_position == 'bottom' then scroll_to_bottom() end
|
||||||
for _, h in ipairs(hl_cmds) do
|
for _, h in ipairs(hl_cmds) do
|
||||||
pcall(vim.api.nvim_buf_add_highlight, M.state.list_buf, M.state.ns_id, h.hl, h.row, h.col_start, h.col_end)
|
pcall(
|
||||||
|
vim.api.nvim_buf_set_extmark,
|
||||||
|
M.state.list_buf,
|
||||||
|
M.state.ns_id,
|
||||||
|
h.row,
|
||||||
|
h.col_start,
|
||||||
|
{ end_col = h.col_end, hl_group = h.hl }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 0, #content - 1 do
|
for i = 0, #content - 1 do
|
||||||
@@ -1360,18 +1367,24 @@ local function render_grep_empty_state(ctx)
|
|||||||
if
|
if
|
||||||
line and (line:match('^%s+Start typing') or line:match('^%s+Tips') or line:match('^%s+"') or line:match('^%s+!'))
|
line and (line:match('^%s+Start typing') or line:match('^%s+Tips') or line:match('^%s+"') or line:match('^%s+!'))
|
||||||
then
|
then
|
||||||
pcall(vim.api.nvim_buf_add_highlight, M.state.list_buf, M.state.ns_id, 'Comment', i, 0, -1)
|
pcall(
|
||||||
|
vim.api.nvim_buf_set_extmark,
|
||||||
|
M.state.list_buf,
|
||||||
|
M.state.ns_id,
|
||||||
|
i,
|
||||||
|
0,
|
||||||
|
{ end_row = i + 1, end_col = 0, hl_group = 'Comment' }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
-- Dim border characters
|
-- Dim border characters
|
||||||
if line and (line:match('^%s+[╭╰│]') or line:match('[╮╯│]%s*$')) then
|
if line and (line:match('^%s+[╭╰│]') or line:match('[╮╯│]%s*$')) then
|
||||||
pcall(
|
pcall(
|
||||||
vim.api.nvim_buf_add_highlight,
|
vim.api.nvim_buf_set_extmark,
|
||||||
M.state.list_buf,
|
M.state.list_buf,
|
||||||
M.state.ns_id,
|
M.state.ns_id,
|
||||||
config.hl.border or 'FloatBorder',
|
|
||||||
i,
|
i,
|
||||||
0,
|
0,
|
||||||
-1
|
{ end_row = i + 1, end_col = 0, hl_group = config.hl.border or 'FloatBorder' }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1403,7 +1416,7 @@ local function build_render_context()
|
|||||||
local text_width = win_width - text_offset
|
local text_width = win_width - text_offset
|
||||||
|
|
||||||
-- Combo detection (only in file picker mode with real results, not grep or suggestions)
|
-- Combo detection (only in file picker mode with real results, not grep or suggestions)
|
||||||
local combo_boost_score_multiplier = config.history and config.history.combo_boost_multiplier or 100
|
local combo_boost_score_multiplier = config.history and config.history.combo_boost_score_multiplier or 100
|
||||||
local has_combo, combo_header_line, combo_header_text_len, combo_item_index
|
local has_combo, combo_header_line, combo_header_text_len, combo_item_index
|
||||||
if M.state.mode == 'grep' or M.state.suggestion_source then
|
if M.state.mode == 'grep' or M.state.suggestion_source then
|
||||||
has_combo = false
|
has_combo = false
|
||||||
@@ -1669,7 +1682,7 @@ function M.clear_preview()
|
|||||||
})
|
})
|
||||||
|
|
||||||
if M.state.file_info_buf then
|
if M.state.file_info_buf then
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = M.state.file_info_buf })
|
||||||
vim.api.nvim_buf_set_lines(M.state.file_info_buf, 0, -1, false, {
|
vim.api.nvim_buf_set_lines(M.state.file_info_buf, 0, -1, false, {
|
||||||
'File Info Panel',
|
'File Info Panel',
|
||||||
'',
|
'',
|
||||||
@@ -1682,12 +1695,12 @@ function M.clear_preview()
|
|||||||
'',
|
'',
|
||||||
'Navigate: ↑↓ or Ctrl+p/n',
|
'Navigate: ↑↓ or Ctrl+p/n',
|
||||||
})
|
})
|
||||||
vim.api.nvim_buf_set_option(M.state.file_info_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.file_info_buf })
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'modifiable', true)
|
vim.api.nvim_set_option_value('modifiable', true, { buf = M.state.preview_buf })
|
||||||
vim.api.nvim_buf_set_lines(M.state.preview_buf, 0, -1, false, { 'No preview available' })
|
vim.api.nvim_buf_set_lines(M.state.preview_buf, 0, -1, false, { 'No preview available' })
|
||||||
vim.api.nvim_buf_set_option(M.state.preview_buf, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = M.state.preview_buf })
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update status information on the right side of input using virtual text
|
--- Update status information on the right side of input using virtual text
|
||||||
@@ -1716,8 +1729,7 @@ function M.update_status(progress)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Grep mode: show keybind + label, e.g. "<S-Tab> fuzzy"
|
local keybind = config.keymaps.cycle_grep_modes
|
||||||
local keybind = config.keymaps.toggle_grep_regex
|
|
||||||
-- Normalize: if it's a table of keys, use the first one for display
|
-- Normalize: if it's a table of keys, use the first one for display
|
||||||
if type(keybind) == 'table' then keybind = keybind[1] or '<S-Tab>' end
|
if type(keybind) == 'table' then keybind = keybind[1] or '<S-Tab>' end
|
||||||
|
|
||||||
@@ -2005,9 +2017,9 @@ local function find_suitable_window()
|
|||||||
if vim.api.nvim_win_is_valid(win) then
|
if vim.api.nvim_win_is_valid(win) then
|
||||||
local buf = vim.api.nvim_win_get_buf(win)
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
if vim.api.nvim_buf_is_valid(buf) then
|
if vim.api.nvim_buf_is_valid(buf) then
|
||||||
local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')
|
local buftype = vim.api.nvim_get_option_value('buftype', { buf = buf })
|
||||||
local modifiable = vim.api.nvim_buf_get_option(buf, 'modifiable')
|
local modifiable = vim.api.nvim_get_option_value('modifiable', { buf = buf })
|
||||||
local filetype = vim.api.nvim_buf_get_option(buf, 'filetype')
|
local filetype = vim.api.nvim_get_option_value('filetype', { buf = buf })
|
||||||
|
|
||||||
local is_picker_window = (
|
local is_picker_window = (
|
||||||
win == M.state.input_win
|
win == M.state.input_win
|
||||||
@@ -2210,8 +2222,8 @@ function M.select(action)
|
|||||||
|
|
||||||
if action == 'edit' then
|
if action == 'edit' then
|
||||||
local current_buf = vim.api.nvim_get_current_buf()
|
local current_buf = vim.api.nvim_get_current_buf()
|
||||||
local current_buftype = vim.api.nvim_buf_get_option(current_buf, 'buftype')
|
local current_buftype = vim.api.nvim_get_option_value('buftype', { buf = current_buf })
|
||||||
local current_buf_modifiable = vim.api.nvim_buf_get_option(current_buf, 'modifiable')
|
local current_buf_modifiable = vim.api.nvim_get_option_value('modifiable', { buf = current_buf })
|
||||||
|
|
||||||
-- If current active buffer is not a normal buffer we find a suitable window with a tab otherwise opening a new split
|
-- If current active buffer is not a normal buffer we find a suitable window with a tab otherwise opening a new split
|
||||||
if current_buftype ~= '' or not current_buf_modifiable then
|
if current_buftype ~= '' or not current_buf_modifiable then
|
||||||
@@ -2467,21 +2479,7 @@ function M.open_with_callback(query, callback, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Open the file picker UI
|
--- Open the file picker UI
|
||||||
--- @param opts? table Optional configuration to override defaults
|
--- @param opts? {cwd?: string, title?: string, prompt?: string, max_results?: number, max_threads?: number, layout?: {width?: number|function, height?: number|function, prompt_position?: string|function, preview_position?: string|function, preview_size?: number|function}, renderer?: table, mode?: string, grep_config?: table, query?: string} Optional configuration to override defaults
|
||||||
--- @param opts.cwd? string Custom working directory (default: vim.fn.getcwd())
|
|
||||||
--- @param opts.title? string Window title (default: "FFFiles")
|
|
||||||
--- @param opts.prompt? string Input prompt text (default: "🪿 ")
|
|
||||||
--- @param opts.max_results? number Maximum number of results to display (default: 100)
|
|
||||||
--- @param opts.max_threads? number Maximum number of threads for file scanning (default: 4)
|
|
||||||
--- @param opts.layout? table Layout configuration
|
|
||||||
--- @param opts.layout.width? number|function Window width as ratio (0.0-1.0) or function(terminal_width, terminal_height): number (default: 0.8)
|
|
||||||
--- @param opts.layout.height? number|function Window height as ratio (0.0-1.0) or function(terminal_width, terminal_height): number (default: 0.8)
|
|
||||||
--- @param opts.layout.prompt_position? string|function Prompt position: 'top'|'bottom' or function(terminal_width, terminal_height): string (default: 'bottom')
|
|
||||||
--- @param opts.layout.preview_position? string|function Preview position: 'left'|'right'|'top'|'bottom' or function(terminal_width, terminal_height): string (default: 'right')
|
|
||||||
--- @param opts.layout.preview_size? number|function Preview size as ratio (0.0-1.0) or function(terminal_width, terminal_height): number (default: 0.5)
|
|
||||||
--- @param opts.renderer? table Custom renderer implementing {render_line, apply_highlights} interface (default: file_renderer)
|
|
||||||
--- @param opts.mode? string Picker mode: nil (default file picker) or 'grep' (live grep)
|
|
||||||
--- @param opts.grep_config? table Grep-specific config overrides {max_file_size, smart_case, max_matches_per_file}
|
|
||||||
function M.open(opts)
|
function M.open(opts)
|
||||||
if M.state.active then return end
|
if M.state.active then return end
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function M.render(layout, config, list_win, pagination, prompt_position)
|
|||||||
-- rendering in a separate buffer to overflow the border
|
-- rendering in a separate buffer to overflow the border
|
||||||
if not scrollbar_exists then
|
if not scrollbar_exists then
|
||||||
scrollbar_state.buf = vim.api.nvim_create_buf(false, true)
|
scrollbar_state.buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(scrollbar_state.buf, 'bufhidden', 'wipe')
|
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = scrollbar_state.buf })
|
||||||
|
|
||||||
scrollbar_state.win = vim.api.nvim_open_win(scrollbar_state.buf, false, {
|
scrollbar_state.win = vim.api.nvim_open_win(scrollbar_state.buf, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
@@ -52,7 +52,7 @@ function M.render(layout, config, list_win, pagination, prompt_position)
|
|||||||
})
|
})
|
||||||
|
|
||||||
local scrollbar_hl = string.format('Normal:%s', config.hl.border)
|
local scrollbar_hl = string.format('Normal:%s', config.hl.border)
|
||||||
vim.api.nvim_win_set_option(scrollbar_state.win, 'winhighlight', scrollbar_hl)
|
vim.api.nvim_set_option_value('winhighlight', scrollbar_hl, { win = scrollbar_state.win })
|
||||||
|
|
||||||
scrollbar_state.ever_shown = true
|
scrollbar_state.ever_shown = true
|
||||||
end
|
end
|
||||||
@@ -83,9 +83,9 @@ function M.render(layout, config, list_win, pagination, prompt_position)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pcall(vim.api.nvim_buf_set_option, scrollbar_state.buf, 'modifiable', true)
|
pcall(vim.api.nvim_set_option_value, 'modifiable', true, { buf = scrollbar_state.buf })
|
||||||
pcall(vim.api.nvim_buf_set_lines, scrollbar_state.buf, 0, -1, false, lines)
|
pcall(vim.api.nvim_buf_set_lines, scrollbar_state.buf, 0, -1, false, lines)
|
||||||
pcall(vim.api.nvim_buf_set_option, scrollbar_state.buf, 'modifiable', false)
|
pcall(vim.api.nvim_set_option_value, 'modifiable', false, { buf = scrollbar_state.buf })
|
||||||
|
|
||||||
pcall(vim.api.nvim_buf_clear_namespace, scrollbar_state.buf, ns_id, 0, -1)
|
pcall(vim.api.nvim_buf_clear_namespace, scrollbar_state.buf, ns_id, 0, -1)
|
||||||
if thumb_size > 0 then
|
if thumb_size > 0 then
|
||||||
|
|||||||
Reference in New Issue
Block a user