Skip to content

Commit ab6cf65

Browse files
committed
refactor: use telescope/fzf-lua to replace glance.nvim
1 parent 2ba4d59 commit ab6cf65

5 files changed

Lines changed: 36 additions & 117 deletions

File tree

lua/keymap/completion.lua

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local bind = require("keymap.bind")
22
local map_cr = bind.map_cr
33
local map_callback = bind.map_callback
4+
require("keymap.helpers")
45

56
local mappings = {
67
fmt = {
@@ -26,14 +27,7 @@ function M.lsp(buf)
2627
:with_buffer(buf)
2728
:with_desc("lsp: Toggle outline"),
2829
["n|gto"] = map_callback(function()
29-
if require("core.settings").search_backend == "fzf" then
30-
local prompt_position = require("telescope.config").values.layout_config.horizontal.prompt_position
31-
require("fzf-lua").lsp_document_symbols({
32-
fzf_opts = { ["--layout"] = prompt_position == "top" and "reverse" or "default" },
33-
})
34-
else
35-
require("telescope.builtin").lsp_document_symbols()
36-
end
30+
_picker("lsp_document_symbols")
3731
end)
3832
:with_silent()
3933
:with_buffer(buf)
@@ -67,13 +61,25 @@ function M.lsp(buf)
6761
:with_silent()
6862
:with_buffer(buf)
6963
:with_desc("lsp: Code action for cursor"),
70-
["n|gd"] = map_cr("Glance definitions"):with_silent():with_buffer(buf):with_desc("lsp: Preview definition"),
71-
["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"),
72-
["n|gh"] = map_cr("Glance references"):with_silent():with_buffer(buf):with_desc("lsp: Show reference"),
73-
["n|gm"] = map_cr("Glance implementations")
64+
["n|gd"] = map_cr("Lspsaga peek_definition")
7465
:with_silent()
7566
:with_buffer(buf)
76-
:with_desc("lsp: Show implementation"),
67+
:with_desc("lsp: Preview definition"),
68+
["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"),
69+
["n|gh"] = map_callback(function()
70+
_picker("lsp_references")
71+
end)
72+
:with_noremap()
73+
:with_nowait()
74+
:with_silent()
75+
:with_desc("lsp: show finder"),
76+
["n|gm"] = map_callback(function()
77+
_picker("lsp_implementations")
78+
end)
79+
:with_noremap()
80+
:with_nowait()
81+
:with_silent()
82+
:with_desc("lsp: show implementations"),
7783
["n|gci"] = map_cr("Lspsaga incoming_calls")
7884
:with_silent()
7985
:with_buffer(buf)

lua/keymap/helpers.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
_G._command_panel = function()
2-
require("telescope.builtin").keymaps({
3-
lhs_filter = function(lhs)
4-
return not string.find(lhs, "Þ")
5-
end,
6-
})
7-
end
8-
91
_G._flash_esc_or_noh = function()
102
local flash_active, state = pcall(function()
113
return require("flash.plugins.char").state
@@ -110,3 +102,15 @@ _G._select_chat_model = function()
110102
})
111103
:find()
112104
end
105+
106+
_G._picker = function(method, tele_opts)
107+
local prompt_position = require("telescope.config").values.layout_config.horizontal.prompt_position
108+
local fzf_opts = { ["--layout"] = prompt_position == "top" and "reverse" or "default" }
109+
if require("core.settings").search_backend == "fzf" then
110+
require("fzf-lua")[method]({
111+
fzf_opts = fzf_opts,
112+
})
113+
else
114+
require("telescope.builtin")[method](tele_opts)
115+
end
116+
end

lua/keymap/tool.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,11 @@ local mappings = {
100100

101101
-- Plugin: telescope
102102
["n|<C-p>"] = map_callback(function()
103-
if require("core.settings").search_backend == "fzf" then
104-
local prompt_position = require("telescope.config").values.layout_config.horizontal.prompt_position
105-
require("fzf-lua").keymaps({
106-
fzf_opts = { ["--layout"] = prompt_position == "top" and "reverse" or "default" },
107-
})
108-
else
109-
_command_panel()
110-
end
103+
_picker("keymaps", {
104+
lhs_filter = function(lhs)
105+
return not string.find(lhs, "Þ")
106+
end,
107+
})
111108
end)
112109
:with_noremap()
113110
:with_silent()

lua/modules/configs/completion/glance.lua

Lines changed: 0 additions & 83 deletions
This file was deleted.

lua/modules/plugins/completion.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ completion["nvimdev/lspsaga.nvim"] = {
2020
config = require("completion.lspsaga"),
2121
dependencies = "nvim-tree/nvim-web-devicons",
2222
}
23-
completion["DNLHC/glance.nvim"] = {
24-
lazy = true,
25-
event = "LspAttach",
26-
config = require("completion.glance"),
27-
}
2823
completion["rachartier/tiny-inline-diagnostic.nvim"] = {
2924
lazy = false,
3025
config = require("completion.tiny-inline-diagnostic"),

0 commit comments

Comments
 (0)