From ed898b6a48766b14b348b4317cda61fdba22d2f4 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sun, 5 Jan 2025 10:59:30 -0800 Subject: [PATCH] fix: Fix fzf-lua registering as vim.ui.select --- nvim/lua/plugins/editor/fzf-lua.lua | 82 +++++++++++++---------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/nvim/lua/plugins/editor/fzf-lua.lua b/nvim/lua/plugins/editor/fzf-lua.lua index 0d9ea72..4836a75 100644 --- a/nvim/lua/plugins/editor/fzf-lua.lua +++ b/nvim/lua/plugins/editor/fzf-lua.lua @@ -86,6 +86,7 @@ projectPick = function() if choice == 1 then history.delete_project({ value = path }) end + ---@diagnostic disable-next-line:need-check-nil projectPick() end, }, @@ -96,7 +97,8 @@ end return { 'fzf-lua', - cmd = 'FzfLua', + event = { 'DeferredUIEnter' }, + cmd = { 'FzfLua' }, keys = { -- Find. { @@ -180,49 +182,6 @@ return { { '/', pick('live_grep'), desc = 'grep (root dir)' }, { ':', pick('command_history'), desc = 'command history' }, }, - before_all = function() - vim.ui.select = function(...) - require('lz.n').trigger_load('fzf-lua') - - require('fzf-lua').register_ui_select(function(fzf_opts, items) - return vim.tbl_deep_extend('force', fzf_opts, { - prompt = ' ', - winopts = { - title = ' ' - .. vim.trim((fzf_opts.prompt or 'Select'):gsub('%s*:%s*$', '')) - .. ' ', - title_pos = 'center', - }, - }, fzf_opts.kind == 'codeaction' and { - winopts = { - layout = 'vertical', - height = math.floor( - math.min(vim.o.lines * 0.8 - 16, #items + 2) + 0.5 - ) + 16, - preview = not vim.tbl_isempty( - vim.lsp.get_clients({ bufnr = 0, name = 'vtsls' }) - ) - and { - layout = 'vertical', - vertical = 'down:15,border-top', - hidden = 'hidden', - } - or { - layout = 'vertical', - vertical = 'down:15,border-top', - }, - }, - } or { - winopts = { - width = 0.5, - height = math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5), - }, - }) - end) - - return vim.ui.select(...) - end - end, after = function() local config = require('fzf-lua.config') local actions = require('fzf-lua.actions') @@ -336,6 +295,41 @@ return { opts[1] = nil require('fzf-lua').setup(opts) + require('fzf-lua').register_ui_select(function(fzf_opts, items) + return vim.tbl_deep_extend('force', fzf_opts, { + prompt = ' ', + winopts = { + title = ' ' + .. vim.trim((fzf_opts.prompt or 'Select'):gsub('%s*:%s*$', '')) + .. ' ', + title_pos = 'center', + }, + }, fzf_opts.kind == 'codeaction' and { + winopts = { + layout = 'vertical', + height = math.floor( + math.min(vim.o.lines * 0.8 - 16, #items + 2) + 0.5 + ) + 16, + preview = not vim.tbl_isempty( + vim.lsp.get_clients({ bufnr = 0, name = 'vtsls' }) + ) + and { + layout = 'vertical', + vertical = 'down:15,border-top', + hidden = 'hidden', + } + or { + layout = 'vertical', + vertical = 'down:15,border-top', + }, + }, + } or { + winopts = { + width = 0.5, + height = math.floor(math.min(vim.o.lines * 0.8, #items + 2) + 0.5), + }, + }) + end) -- LSP keybinds. MarleyVim.lsp.on_attach(function(client)