nvim: improve cscope conn

This commit is contained in:
Mathieu Maret 2024-07-18 22:47:39 +02:00
parent ae3b39e1ee
commit 49e5d43111

View File

@ -57,6 +57,9 @@ require("lazy").setup({
}, },
{ -- Useful plugin to show you pending keybinds. { -- Useful plugin to show you pending keybinds.
"folke/which-key.nvim", "folke/which-key.nvim",
dependencies = {
"echasnovski/mini.icons",
},
event = "VimEnter", -- Sets the loading event to 'VimEnter' event = "VimEnter", -- Sets the loading event to 'VimEnter'
init = function() init = function()
vim.o.timeout = true vim.o.timeout = true
@ -64,21 +67,15 @@ require("lazy").setup({
end, end,
config = function() -- This is the function that runs, AFTER loading config = function() -- This is the function that runs, AFTER loading
require("which-key").setup() require("which-key").setup()
require("which-key").add({
-- Document existing key chains { "<leader>c", group = "[C]ode" },
require("which-key").register({ { "<leader>d", group = "[D]ocument" },
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" }, { "<leader>r", group = "[R]ename" },
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" }, { "<leader>s", group = "[S]earch" },
["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" }, { "<leader>w", group = "[W]orkspace" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" }, { "<leader>t", group = "[T]oggle" },
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" }, { "<leader>h", group = "Git [H]unk", mode = { "n", "v" } },
["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
["<leader>h"] = { name = "Git [H]unk", _ = "which_key_ignore" },
}) })
-- visual mode
require("which-key").register({
["<leader>h"] = { "Git [H]unk" },
}, { mode = "v" })
end, end,
}, },
@ -99,7 +96,7 @@ require("lazy").setup({
"liuchengxu/vista.vim", "liuchengxu/vista.vim",
"mhinz/vim-startify", "mhinz/vim-startify",
"https://git.mathux.org/mathieu/taglist.git", "https://git.mathux.org/mathieu/taglist.git",
"lfilho/cosco.vim", "MattesGroeger/vim-bookmarks",
{ {
"dhananjaylatkar/cscope_maps.nvim", "dhananjaylatkar/cscope_maps.nvim",
dependencies = { dependencies = {
@ -108,9 +105,9 @@ require("lazy").setup({
"ibhagwan/fzf-lua", -- optional [for picker="fzf-lua"] "ibhagwan/fzf-lua", -- optional [for picker="fzf-lua"]
"nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope or fzf] "nvim-tree/nvim-web-devicons", -- optional [for devicons in telescope or fzf]
}, },
branch = "feat/db_relpath",
opts = { opts = {
skip_input_prompt = true, skip_input_prompt = true,
prefix = "<leader>,",
cscope = { cscope = {
skip_picker_for_single_result = true, skip_picker_for_single_result = true,
picker = "telescope", picker = "telescope",
@ -134,6 +131,7 @@ require("lazy").setup({
ensure_installed = { ensure_installed = {
"c", "c",
"cpp", "cpp",
"devicetree",
"lua", "lua",
"vim", "vim",
"vimdoc", "vimdoc",
@ -682,7 +680,6 @@ else
vim.cmd("colorscheme kanagawa-wave") vim.cmd("colorscheme kanagawa-wave")
end end
vim.opt.runtimepath:append("~/.vim/bundle/Vundle.vim/")
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
local builtin = require("telescope.builtin") local builtin = require("telescope.builtin")
@ -696,3 +693,10 @@ vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iag
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" }) vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" }) vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
-- Ctags are much better to find definition than cscope
vim.keymap.set(
"n",
"<leader>cg",
[[<cmd>exe "tag" expand("<cword>")<cr>]],
{ desc = "Find this global definition with tags" }
)