Skip to content

Commit e32ab0a

Browse files
cscope: cstag: add new config opts
- keymap => control if "<C-]>" is mapped to ":Cstag" - tag_cmd => tag command can be changed to "tag", "tjump", etc fix #82
1 parent 5a5060a commit e32ab0a

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@ _cscope_maps_ comes with following defaults:
130130
},
131131
-- cstag related defaults
132132
tag = {
133-
enable = true, -- "true" or "false"
133+
-- bind ":Cstag" to "<C-]>"
134+
keymap = true, -- "true" or "false"
134135
-- order of operation to run for ":Cstag"
135-
order = { "cs", "tag_picker", "tag" }, -- any combination of these 3
136+
order = { "cs", "tag_picker", "tag" }, -- any combination of these 3 (ops can be excluded)
137+
-- cmd to use for "tag" op in above table
138+
tag_cmd = "tjump",
136139
},
137140
},
138141

lua/cscope/init.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ M.opts = {
3838
change_cwd = false,
3939
},
4040
tag = {
41-
enable = true,
41+
keymap = true,
4242
order = { "cs", "tag_picker", "tag" },
43+
tag_cmd = "tjump",
4344
},
4445
}
4546

@@ -353,10 +354,11 @@ M.cstag = function(symbol)
353354
return
354355
end
355356
elseif tag == "tag" then
356-
if pcall(vim.cmd.tjump, symbol) then
357+
local ok, msg = pcall(vim.cmd, { cmd = M.opts.tag.tag_cmd, args = { symbol } })
358+
if ok then
357359
return
358360
end
359-
log.warn("Vim(tag):E426: tag not found: " .. symbol)
361+
log.warn(msg)
360362
end
361363
end
362364
end
@@ -543,13 +545,14 @@ M.user_command = function()
543545
complete = M.cmd_cmp,
544546
})
545547

546-
-- Create the :Cstag user command and bind it to "C-]"
547-
if M.opts.tag.enable == true then
548-
vim.api.nvim_create_user_command("Cstag", function(opts)
549-
M.cstag(unpack(opts.fargs))
550-
end, {
551-
nargs = "*",
552-
})
548+
-- Create the :Cstag user command
549+
vim.api.nvim_create_user_command("Cstag", function(opts)
550+
M.cstag(unpack(opts.fargs))
551+
end, {
552+
nargs = "*",
553+
})
554+
-- Bind :Cstag to "<C-]>"
555+
if M.opts.tag.keymap == true then
553556
vim.keymap.set({ "n", "v" }, "<C-]>", "<cmd>Cstag<cr>", { desc = "cstag" })
554557
end
555558
end

0 commit comments

Comments
 (0)