Skip to content

Commit

Permalink
cscope: mini.pick support (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhananjaylatkar authored Jul 16, 2024
1 parent 01ecd06 commit ebb3941
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Heavily inspired by emacs' [xcscope.el](https://github.com/dkogan/xcscope.el).
- Supports `cscope` and `gtags-cscope`. Use `cscope.exec` option to specify executable.
- `:Cstag <symbol>` does `tags` search if no results are found in `cscope`.
- For `nvim < 0.9`, legacy cscope will be used. It will support keymaps. It won't have all the niceties of lua port.
- Opens results in quickfix, **telescope**, or **fzf-lua**.
- Display results in quickfix, **telescope**, **fzf-lua** or **mini.pick**.
- Has [which-key.nvim](https://github.com/folke/which-key.nvim) hints.
- See [this section](#vim-gutentags) for `vim-gutentags`.

Expand Down Expand Up @@ -61,7 +61,8 @@ Following example uses [lazy.nvim](https://github.com/folke/lazy.nvim)
"folke/which-key.nvim", -- optional [for whichkey hints]
"nvim-telescope/telescope.nvim", -- optional [for picker="telescope"]
"ibhagwan/fzf-lua", -- optional [for picker="fzf-lua"]
"nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope or fzf]
"echasnovski/mini.pick" -- optional [for picker="mini-pick"]
"nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope, fzf or mini.pick]
},
opts = {
-- USE EMPTY FOR DEFAULT OPTIONS
Expand Down Expand Up @@ -94,7 +95,7 @@ _cscope_maps_ comes with following defaults:
-- cscope executable
exec = "cscope", -- "cscope" or "gtags-cscope"
-- choose your fav picker
picker = "quickfix", -- "telescope", "fzf-lua" or "quickfix"
picker = "quickfix", -- "quickfix", "telescope", "fzf-lua" or "mini-pick"
-- size of quickfix window
qf_window_size = 5, -- any positive integer
-- position of quickfix window
Expand Down
9 changes: 5 additions & 4 deletions doc/cscope_maps.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*cscope_maps.txt* For Neovim >= v0.10.0 Last change: 2024 July 06
*cscope_maps.txt* For Neovim >= v0.10.0 Last change: 2024 July 16

==============================================================================
Table of Contents *cscope_maps-table-of-contents*
Expand Down Expand Up @@ -35,7 +35,7 @@ CSCOPE ~
- Supports `cscope` and `gtags-cscope`. Use `cscope.exec` option to specify executable.
- `:Cstag <symbol>` does `tags` search if no results are found in `cscope`.
- For `nvim < 0.9`, legacy cscope will be used. It will support keymaps. It won’t have all the niceties of lua port.
- Opens results in quickfix, **telescope**, or **fzf-lua**.
- Display results in quickfix, **telescope**, **fzf-lua** or **mini.pick**.
- Has which-key.nvim <https://github.com/folke/which-key.nvim> hints.
- See |cscope_maps-this-section| for `vim-gutentags`.

Expand Down Expand Up @@ -80,7 +80,8 @@ lazy.nvim <https://github.com/folke/lazy.nvim>
"folke/which-key.nvim", -- optional [for whichkey hints]
"nvim-telescope/telescope.nvim", -- optional [for picker="telescope"]
"ibhagwan/fzf-lua", -- optional [for picker="fzf-lua"]
"nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope or fzf]
"echasnovski/mini.pick" -- optional [for picker="mini-pick"]
"nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope, fzf or mini.pick]
},
opts = {
-- USE EMPTY FOR DEFAULT OPTIONS
Expand Down Expand Up @@ -115,7 +116,7 @@ _cscope_maps_ comes with following defaults:
-- cscope executable
exec = "cscope", -- "cscope" or "gtags-cscope"
-- choose your fav picker
picker = "quickfix", -- "telescope", "fzf-lua" or "quickfix"
picker = "quickfix", -- "quickfix", "telescope", "fzf-lua" or "mini-pick"
-- size of quickfix window
qf_window_size = 5, -- any positive integer
-- position of quickfix window
Expand Down
27 changes: 27 additions & 0 deletions lua/cscope/pickers/mini-pick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local M = {}

M.run = function(opts)
opts = opts or {}
local entries = {}

for _, item in ipairs(opts.cscope.parsed_output) do
local entry = {
path = item.filename,
lnum = tonumber(item.lnum),
text = string.format("%s:%s:%s", item.filename, item.lnum, item.text),
}
table.insert(entries, entry)
end

MiniPick.start({
source = {
items = entries,
name = opts.cscope.prompt_title,
show = function(buf_id, items, query)
MiniPick.default_show(buf_id, items, query, { show_icons = true })
end,
},
})
end

return M

0 comments on commit ebb3941

Please sign in to comment.