110 lines
2.8 KiB
Lua
110 lines
2.8 KiB
Lua
---@toc_entry Configuration
|
|
---@tag gopher.nvim-config
|
|
---@text config it is the place where you can configure the plugin.
|
|
--- also this is optional is you're ok with default settings.
|
|
--- You can look at default options |gopher.nvim-config-defaults|
|
|
|
|
---@type gopher.Config
|
|
---@private
|
|
local config = {}
|
|
|
|
---@tag gopher.nvim-config.ConfigGoTagTransform
|
|
---@text Possible values for |gopher.Config|.gotag.transform:
|
|
---
|
|
---@private
|
|
---@alias gopher.ConfigGoTagTransform
|
|
---| "snakecase" "GopherUser" -> "gopher_user"
|
|
---| "camelcase" "GopherUser" -> "gopherUser"
|
|
---| "lispcase" "GopherUser" -> "gopher-user"
|
|
---| "pascalcase" "GopherUser" -> "GopherUser"
|
|
---| "titlecase" "GopherUser" -> "Gopher User"
|
|
---| "keep" keeps the original field name
|
|
|
|
--minidoc_replace_start {
|
|
|
|
---@tag gopher.nvim-config-defaults
|
|
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
|
---
|
|
---@class gopher.Config
|
|
local default_config = {
|
|
--minidoc_replace_end
|
|
|
|
-- log level, you might consider using DEBUG or TRACE for debugging the plugin
|
|
---@type number
|
|
log_level = vim.log.levels.INFO,
|
|
|
|
-- timeout for running commands
|
|
---@type number
|
|
timeout = 2000,
|
|
|
|
--- whether to setup plugin commands or not
|
|
---@type boolean
|
|
setup_commands = true,
|
|
|
|
-- user specified paths to binaries
|
|
---@class gopher.ConfigCommand
|
|
commands = {
|
|
go = "go",
|
|
gomodifytags = "gomodifytags",
|
|
gotests = "gotests",
|
|
impl = "impl",
|
|
iferr = "iferr",
|
|
},
|
|
---@class gopher.ConfigGotests
|
|
gotests = {
|
|
-- gotests doesn't have template named "default" so this plugin uses "default" to set the default template
|
|
template = "default",
|
|
-- path to a directory containing custom test code templates
|
|
---@type string|nil
|
|
template_dir = nil,
|
|
-- switch table tests from using slice to map (with test name for the key)
|
|
named = false,
|
|
},
|
|
---@class gopher.ConfigGoTag
|
|
gotag = {
|
|
---@type gopher.ConfigGoTagTransform
|
|
transform = "snakecase",
|
|
|
|
-- default tags to add to struct fields
|
|
default_tag = "json",
|
|
},
|
|
iferr = {
|
|
-- choose a custom error message
|
|
---@type string|nil
|
|
message = nil,
|
|
},
|
|
}
|
|
--minidoc_afterlines_end
|
|
|
|
---@type gopher.Config
|
|
---@private
|
|
local _config = default_config
|
|
|
|
-- I am kinda secret so don't tell anyone about me even dont use me
|
|
--
|
|
-- if you don't believe me that i am secret see
|
|
-- the line below it says @private
|
|
---@private
|
|
_config.___plugin_name = "gopher.nvim" ---@diagnostic disable-line: inject-field
|
|
|
|
---@param user_config? gopher.Config
|
|
---@private
|
|
function config.setup(user_config)
|
|
_config = vim.tbl_deep_extend("force", default_config, user_config or {})
|
|
end
|
|
|
|
---@return boolean
|
|
---@private
|
|
function config.should_setup_commands()
|
|
return config.setup_commands
|
|
end
|
|
|
|
setmetatable(config, {
|
|
__index = function(_, key)
|
|
return _config[key]
|
|
end,
|
|
})
|
|
|
|
---@return gopher.Config
|
|
---@private
|
|
return config
|