Skip to content

Commit 42837bd

Browse files
vpatel95Ved Patel
andauthored
cscope: add snacks.nvim picker (#73)
Co-authored-by: Ved Patel <vedpatel@cisco.com>
1 parent 6a1b488 commit 42837bd

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Heavily inspired by emacs' [xcscope.el](https://github.com/dkogan/xcscope.el).
2525
- Supports `cscope` and `gtags-cscope`. Use `cscope.exec` option to specify executable.
2626
- Keymaps can be disabled using `disable_maps` option.
2727
- `:CsPrompt <op>` can be used to invoke cscope prompt.
28-
- Display results in quickfix, **telescope**, **fzf-lua** or **mini.pick**.
28+
- Display results in quickfix, **telescope**, **fzf-lua**, **mini.pick** or **snacks.nvim**.
2929
- Has [which-key.nvim](https://github.com/folke/which-key.nvim) and [mini.clue](https://github.com/echasnovski/mini.clue) hints.
3030
- See [this section](#vim-gutentags) for `vim-gutentags`.
3131

@@ -74,6 +74,7 @@ Following example uses [lazy.nvim](https://github.com/folke/lazy.nvim)
7474
"nvim-telescope/telescope.nvim", -- optional [for picker="telescope"]
7575
"ibhagwan/fzf-lua", -- optional [for picker="fzf-lua"]
7676
"echasnovski/mini.pick", -- optional [for picker="mini-pick"]
77+
"folke/snacks.nvim", -- optional [for picker="snacks"]
7778
},
7879
opts = {
7980
-- USE EMPTY FOR DEFAULT OPTIONS
@@ -108,7 +109,7 @@ _cscope_maps_ comes with following defaults:
108109
-- cscope executable
109110
exec = "cscope", -- "cscope" or "gtags-cscope"
110111
-- choose your fav picker
111-
picker = "quickfix", -- "quickfix", "telescope", "fzf-lua" or "mini-pick"
112+
picker = "quickfix", -- "quickfix", "telescope", "fzf-lua", "mini-pick" or "snacks"
112113
-- size of quickfix window
113114
qf_window_size = 5, -- any positive integer
114115
-- position of quickfix window

lua/cscope/pickers/snacks.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local M = {}
2+
3+
local prepare = function(items)
4+
local res = {}
5+
for i, item in ipairs(items) do
6+
table.insert(res, {
7+
file = item["filename"],
8+
score = i,
9+
text = item["text"],
10+
line = item["text"],
11+
pos = { tonumber(item["lnum"]), 0 },
12+
})
13+
end
14+
15+
return res
16+
end
17+
18+
M.run = function(opts)
19+
Snacks.picker({
20+
items = prepare(opts.cscope.parsed_output),
21+
title = opts.cscope.prompt_title,
22+
})
23+
end
24+
25+
return M

0 commit comments

Comments
 (0)