refactor(comment): dont use unnecessary function

This commit is contained in:
Oleksandr Smirnov 2025-09-04 14:17:58 +03:00
parent 7e8c6f41aa
commit 9b213ec81e
No known key found for this signature in database

View file

@ -9,30 +9,23 @@ local ts = require "gopher._utils.ts"
local log = require "gopher._utils.log" local log = require "gopher._utils.log"
local comment = {} local comment = {}
---@param name string
---@return string
---@dochide
local function template(name)
return "// " .. name .. " "
end
---@param bufnr integer ---@param bufnr integer
---@return string ---@return string
---@dochide ---@dochide
local function generate(bufnr) local function generate(bufnr)
local s_ok, s_res = pcall(ts.get_struct_under_cursor, bufnr) local s_ok, s_res = pcall(ts.get_struct_under_cursor, bufnr)
if s_ok then if s_ok then
return template(s_res.name) return "// " .. s_res.name .. " "
end end
local f_ok, f_res = pcall(ts.get_func_under_cursor, bufnr) local f_ok, f_res = pcall(ts.get_func_under_cursor, bufnr)
if f_ok then if f_ok then
return template(f_res.name) return "// " .. f_res.name .. " "
end end
local i_ok, i_res = pcall(ts.get_interface_under_cursor, bufnr) local i_ok, i_res = pcall(ts.get_interface_under_cursor, bufnr)
if i_ok then if i_ok then
return template(i_res.name) return "// " .. i_res.name .. " "
end end
local p_ok, p_res = pcall(ts.get_package_under_cursor, bufnr) local p_ok, p_res = pcall(ts.get_package_under_cursor, bufnr)