feat: improve inverse search cmd

This commit is contained in:
Barrett Ruth 2026-03-12 15:42:20 -04:00
parent aea9d07ae9
commit f1cc5ca1ba
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
6 changed files with 42 additions and 28 deletions

View file

@ -2,65 +2,66 @@ local M = {}
local Methods = vim.lsp.protocol.Methods
local function fzf_or(fzf_cmd, fallback)
return function()
if pcall(require, 'fzf-lua') then
vim.cmd('FzfLua ' .. fzf_cmd)
else
fallback()
end
end
end
function M.on_attach(client, bufnr)
if client:supports_method(Methods.textDocument_hover) then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = bufnr })
end
local ok, _ = pcall(require, 'fzf-lua')
local mappings = {
{
Methods.textDocument_codeAction,
'gra',
ok and '<cmd>FzfLua lsp_code_actions<CR>'
or vim.lsp.buf.code_action,
fzf_or('lsp_code_actions', vim.lsp.buf.code_action),
},
{
Methods.textDocument_declaration,
'gD',
ok and '<cmd>FzfLua lsp_declarations<CR>'
or vim.lsp.buf.declaration,
fzf_or('lsp_declarations', vim.lsp.buf.declaration),
},
{
Methods.textDocument_definition,
'gd',
ok and '<cmd>FzfLua lsp_definitions<CR>' or vim.lsp.buf.definition,
fzf_or('lsp_definitions', vim.lsp.buf.definition),
},
{
Methods.textDocument_implementation,
'gri',
ok and '<cmd>FzfLua lsp_implementations<CR>'
or vim.lsp.buf.implementation,
fzf_or('lsp_implementations', vim.lsp.buf.implementation),
},
{
Methods.textDocument_references,
'grr',
ok and '<cmd>FzfLua lsp_references<CR>' or vim.lsp.buf.references,
fzf_or('lsp_references', vim.lsp.buf.references),
},
{
Methods.textDocument_typeDefinition,
'grt',
ok and '<cmd>FzfLua lsp_typedefs<CR>'
or vim.lsp.buf.type_definition,
fzf_or('lsp_typedefs', vim.lsp.buf.type_definition),
},
{
Methods.textDocument_documentSymbol,
'gs',
ok and '<cmd>FzfLua lsp_document_symbols<CR>'
or vim.lsp.buf.document_symbol,
fzf_or('lsp_document_symbols', vim.lsp.buf.document_symbol),
},
{
Methods.workspace_diagnostic,
'gw',
ok and '<cmd>FzfLua lsp_workspace_diagnostics<CR>'
or vim.diagnostic.setqflist,
fzf_or('lsp_workspace_diagnostics', vim.diagnostic.setqflist),
},
{
Methods.workspace_symbol,
'gS',
ok and '<cmd>FzfLua lsp_workspace_symbols<CR>'
or vim.lsp.buf.workspace_symbol,
fzf_or('lsp_workspace_symbols', vim.lsp.buf.workspace_symbol),
},
}

View file

@ -161,10 +161,7 @@ return {
end
end
end,
group = vim.api.nvim_create_augroup(
'AOil',
{ clear = true }
),
group = vim.api.nvim_create_augroup('AOil', { clear = true }),
})
end,
event = 'DeferredUIEnter',
@ -335,7 +332,7 @@ return {
vim.filetype.add({
extension = { puml = 'plantuml', pu = 'plantuml' },
})
vim.fn.serverstart('/tmp/nvim-preview.sock')
vim.api.nvim_create_autocmd('User', {
pattern = 'PreviewCompileSuccess',
callback = function(args)
@ -369,7 +366,9 @@ return {
debug = false,
github = {
output = function(ctx)
return '/tmp/' .. vim.fn.fnamemodify(ctx.file, ':t:r') .. '.html'
return '/tmp/'
.. vim.fn.fnamemodify(ctx.file, ':t:r')
.. '.html'
end,
},
typst = { open = { 'sioyek', '--new-instance' } },

View file

@ -1,5 +1,5 @@
return {
'barrettruth/fzf-lua',
'ibhagwan/fzf-lua',
after = function()
local fzf = require('fzf-lua')
local has_nonicons = pcall(require, 'nonicons')
@ -94,6 +94,7 @@ return {
fzf_reload.reload()
end
end,
cmd = 'FzfLua',
keys = {
{
'<c-t>',

View file

@ -46,8 +46,9 @@ vim.o.number = true
vim.o.relativenumber = true
vim.o.signcolumn = 'no'
vim.o.statuscolumn = '%s%C %=%{v:relnum?v:relnum:v:lnum} '
vim.o.statusline = " %{len(expand('%'))?expand('%:~').' ':''}%h%m%r%=%c:%l/%L %{&ft!=''?&ft:&bt} "
vim.o.statuscolumn = "%{%v:virtnum?'':'%s%C %=%{v:relnum?v:relnum:v:lnum} '%}"
vim.o.statusline =
" %{len(expand('%'))?expand('%:~').' ':''}%h%m%r%=%c:%l/%L %{&ft!=''?&ft:&bt} "
vim.opt.path:append('**')