feat(struct_tags): add range support (#117)

* feat(struct_tags): add range support

* refactor: use `start`, and `end_` naming for ranges
This commit is contained in:
Oleksandr Smirnov 2025-08-29 19:46:45 +03:00 committed by GitHub
parent ca1d4fda88
commit d46461d232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 129 additions and 26 deletions

View file

@ -11,10 +11,13 @@ end
---@param name string
---@param fn fun(args: table)
---@param nargs? number|"*"|"?"
---@param range? boolean
---@private
local function cmd(name, fn, nargs)
nargs = nargs or 0
vim.api.nvim_create_user_command(name, fn, { nargs = nargs })
local function cmd(name, fn, nargs, range)
vim.api.nvim_create_user_command(name, fn, {
nargs = nargs or 0,
range = range or false,
})
end
cmd("GopherLog", function()
@ -44,12 +47,24 @@ end)
-- :GoTag
cmd("GoTagAdd", function(opts)
require("gopher").tags.add(unpack(opts.fargs))
end, "*")
require("gopher").tags.add {
tags = opts.fargs,
range = (opts.count ~= -1) and {
start = opts.line1,
end_ = opts.line2,
} or nil,
}
end, "*", true)
cmd("GoTagRm", function(opts)
require("gopher").tags.rm(unpack(opts.fargs))
end, "*")
require("gopher").tags.rm {
tags = opts.fargs,
range = (opts.count ~= -1) and {
start = opts.line1,
end_ = opts.line2,
} or nil,
}
end, "*", true)
cmd("GoTagClear", function()
require("gopher").tags.clear()