-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable winopts
for all commands with positioning relative to the cursor
#545
Comments
The
The current window is hard coded as |
Thanks a lot for your detailed explanation 👍 So I understood the configuration options correct at least ;) vim.keymap.set('n', '<Leader>fs', function() require('fzf-lua').spell_suggest({ winopts = cursor_popup }) end, { desc = 'Fzf: spell suggest' } A direct call uses the global vim.keymap.set('n', '<Leader>fs', require('fzf-lua').spell_suggest, { desc = 'Fzf: spell suggest' }) That's still not quite clear for me. But at least I got a working configuration now. Many thanks for that! And a |
That’s because for some odd reason I decided to define some providers under a
Will add it and keep this thread updated. |
c90a88b - update to this and
This turns out to be already working without any changes :-) Line 624 in c90a88b
For spell suggest you can use: :lua require'fzf-lua'.spell_suggest({ winopts = {relative="cursor"} }) Note that using this breaks preview/scrollbar layout so use this only without preview. |
Now that looks better already! :) My current configuration use({
'ibhagwan/fzf-lua',
requires = {
{ 'junegunn/fzf', run = './install --all --xdg' }
},
config = function()
local fzf_lua = require('fzf-lua')
local bottom_row = {
height = 0.4,
width = 1,
row = 1,
col = 0,
preview = {
layout = 'horizontal',
horizontal = 'right:55%',
}
}
local right_popup = {
height = 0.97,
width = 0.2,
row = 0.3,
col = 1
}
local cursor_popup = {
relative = 'cursor',
height = 0.2,
width = 0.3
}
local right_column = {
height = 1,
width = 0.45,
row = 0,
col = 1,
preview = {
layout = 'vertical',
vertical = 'down:65%'
}
}
local function show_notifications()
local opts = {}
opts.prompt = 'Notifications> '
opts.fzf_opts = {
['--no-multi'] = ''
}
local entries = require('notify').history()
local notifications = {}
for i = 1, #entries do
local all_messages = ''
local formatted_messages = {}
local function diag_level_code(diag)
local level = entries[i].level
if level == "ERROR" then
return fzf_lua.utils.ansi_codes.red(diag)
elseif level == "WARN" then
return fzf_lua.utils.ansi_codes.yellow(diag)
elseif level == "DEBUG" then
return fzf_lua.utils.ansi_codes.yellow(diag)
elseif level == "INFO" then
return fzf_lua.utils.ansi_codes.green(diag)
elseif level == "HINT" then
return fzf_lua.utils.ansi_codes.blue(diag)
end
end
local function format_msg(...)
for _, entry in ipairs(...) do
table.insert(formatted_messages, '\n' .. entry)
end
return formatted_messages
end
local messages = entries[i].message
if #messages > 1 then
format_msg(messages)
all_messages = table.concat(formatted_messages)
else
all_messages = messages[1]
end
table.insert(notifications,
string.format('%-5s %s %16s %s %s',
fzf_lua.utils.ansi_codes.blue(vim.fn.strftime('%F %H:%M', entries[i].time)),
diag_level_code(entries[i].icon),
diag_level_code(entries[i].level),
fzf_lua.utils.ansi_codes.cyan('« ' .. entries[i].title[1] .. ' »'),
all_messages
)
)
end
if vim.tbl_isempty(notifications) then return end
fzf_lua.fzf_exec(notifications, opts)
end
vim.keymap.set('n', '<Leader>F', require('fzf-lua').builtin, { desc = 'Fzf: builtin' })
vim.keymap.set('n', '<Leader>b', require('fzf-lua').buffers, { desc = 'Fzf: buffers' })
vim.keymap.set('n', '<Leader>c', require('fzf-lua').colorschemes, { desc = 'Fzf: colorschemes' })
vim.keymap.set('n', '<Leader>f', require('fzf-lua').files, { desc = 'Fzf: files' })
vim.keymap.set('n', '<Leader>o', require('fzf-lua').oldfiles, { desc = 'Fzf: oldfiles' })
vim.keymap.set('n', '<Leader>fg', require('fzf-lua').lgrep_curbuf, { desc = 'Fzf: grep current file' })
vim.keymap.set('n', '<Leader>fG', require('fzf-lua').live_grep_native, { desc = 'Fzf: grep all files' })
vim.keymap.set('n', '<Leader>h', require('fzf-lua').help_tags, { desc = 'Fzf: help' })
vim.keymap.set('n', '<Leader>M', require('fzf-lua').man_pages, { desc = 'Fzf: man' })
vim.keymap.set('n', '<Leader>m', require('fzf-lua').marks, { desc = 'Fzf: marks' })
vim.keymap.set('n', '<Leader>r', require('fzf-lua').registers, { desc = 'Fzf: registers' })
vim.keymap.set('n', '<Leader>fgb', require('fzf-lua').git_bcommits, { desc = 'Fzf: git buffer commits' })
vim.keymap.set('n', '<Leader>fgc', require('fzf-lua').git_commits, { desc = 'Fzf: git commits' })
vim.keymap.set('n', '<Leader>fgf', require('fzf-lua').git_files, { desc = 'Fzf: git files' })
vim.keymap.set('n', '<Leader>fgs', require('fzf-lua').git_status, { desc = 'Fzf: git status' })
vim.keymap.set('n', '<Leader>fc', require('fzf-lua').command_history, { desc = 'Fzf: command history' })
vim.keymap.set('n', '<Leader>fm', require('fzf-lua').keymaps, { desc = 'Fzf: keymaps' })
vim.keymap.set('n', '<Leader>fq', require('fzf-lua').quickfix, { desc = 'Fzf: quickfix' })
vim.keymap.set('n', '<Leader>fs', require('fzf-lua').spell_suggest, { desc = 'Fzf: spell suggest' })
vim.keymap.set('n', '<Leader>fw', require('fzf-lua').grep_cword, { desc = 'Fzf: grep string' })
vim.keymap.set('n', '<Leader>fn', function() show_notifications() end, { desc = 'Fzf: notifications' })
fzf_lua.register_ui_select({
winopts = cursor_popup
})
fzf_lua.setup({
global_resume = true,
winopts = bottom_row,
builtin = {
winopts = right_column
},
colorschemes = {
winopts = right_popup
},
diagnostics = {
winopts = right_column
},
files = {
prompt = 'Files❯ ',
},
git = {
branches = {
winopts = right_column
},
bcommits = {
winopts = right_column
},
commits = {
winopts = right_column
},
status = {
winopts = right_column
},
},
grep = {
cmd = 'ugrep -RIjnkzs --hidden --ignore-files --exclude-dir=".git"',
winopts = right_column
},
highlights = {
winopts = right_column
},
lsp = {
code_actions = {
winopts = cursor_popup
}
},
spell_suggest = {
winopts = cursor_popup
}
})
end
}) |
Have you tried this? It pops up right at the cursor position :lua require'fzf-lua'.spell_suggest({ winopts = {relative="cursor",row=0, col=0, height=0.2, width=0.5} }
) Also, since sizes/positioning are relative sizes to current neovim window anything
:lua require'fzf-lua'.spell_suggest({ winopts = {relative="cursor",row=1.01, col=0, height=0.2, width=0.5
} }) |
This is simply brilliant 😃️ ❤️ |
Info
Operating System: Gentoo Base System release 2.9 (~amd64)
Shell: zsh 5.9
Terminal: wezterm 20221016-210733-84de038d
nvim --version
: NVIM v0.9.0-dev-115-g042eb74fzf --version
: 0.34.0 (04d0b02)The issue is reproducible with
mini.sh
fzf-lua configuration
Description
Is it possible to make
winopts
available for all commands?After switching from Telescope I tried to mimic the
get_cursor
theme which is really useful for spell suggestions or code actions with a popup relative to the cursor. You can see my attempts to achieve that above but until now I didn't succeed (due to a lack of deeper understanding how things work ;))The text was updated successfully, but these errors were encountered: