[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang
1local config = {} 2 3---@tag gopher.nvim-config.ConfigGoTagTransform 4---@text Possible values for |gopher.Config|.gotag.transform: 5--- 6---@dochide 7---@alias gopher.ConfigGoTagTransform 8---| "snakecase" "GopherUser" -> "gopher_user" 9---| "camelcase" "GopherUser" -> "gopherUser" 10---| "lispcase" "GopherUser" -> "gopher-user" 11---| "pascalcase" "GopherUser" -> "GopherUser" 12---| "titlecase" "GopherUser" -> "Gopher User" 13---| "keep" keeps the original field name 14 15---@toc_entry Config 16---@tag gopher.nvim-config 17---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section) 18---@class gopher.Config 19local default_config = { 20 -- log level, you might consider using DEBUG or TRACE for debugging the plugin 21 ---@type number 22 log_level = vim.log.levels.INFO, 23 24 -- timeout for running internal commands 25 ---@type number 26 timeout = 2000, 27 28 --- timeout for running installer commands(e.g :GoDepsInstall, :GoDepsInstallSync) 29 installer_timeout = 999999, 30 31 -- user specified paths to binaries 32 ---@class gopher.ConfigCommand 33 commands = { 34 go = "go", 35 gomodifytags = "gomodifytags", 36 gotests = "gotests", 37 impl = "impl", 38 iferr = "iferr", 39 }, 40 ---@class gopher.ConfigGotests 41 gotests = { 42 -- gotests doesn't have template named "default" so this plugin uses "default" to set the default template 43 template = "default", 44 -- path to a directory containing custom test code templates 45 ---@type string|nil 46 template_dir = nil, 47 -- switch table tests from using slice to map (with test name for the key) 48 named = false, 49 }, 50 ---@class gopher.ConfigGoTag 51 gotag = { 52 ---@type gopher.ConfigGoTagTransform 53 transform = "snakecase", 54 55 -- default tags to add to struct fields 56 default_tag = "json", 57 }, 58 iferr = { 59 -- choose a custom error message 60 ---@type string|nil 61 message = nil, 62 }, 63} 64--minidoc_afterlines_end 65 66---@type gopher.Config 67---@dochide 68local _config = default_config 69 70-- I am kinda secret so don't tell anyone about me even dont use me 71-- 72-- if you don't believe me that i am secret see 73-- the line below it says @private 74---@private 75_config.___plugin_name = "gopher.nvim" ---@diagnostic disable-line: inject-field 76 77---@param user_config? gopher.Config 78---@dochide 79function config.setup(user_config) 80 vim.validate("user_config", user_config, "table", true) 81 82 _config = vim.tbl_deep_extend("force", vim.deepcopy(default_config), user_config or {}) 83 84 vim.validate("log_level", _config.log_level, "number") 85 vim.validate("timeout", _config.timeout, "number") 86 vim.validate("installer_timeout", _config.timeout, "number") 87 vim.validate("commands", _config.commands, "table") 88 vim.validate("commands.go", _config.commands.go, "string") 89 vim.validate("commands.gomodifytags", _config.commands.gomodifytags, "string") 90 vim.validate("commands.gotests", _config.commands.gotests, "string") 91 vim.validate("commands.impl", _config.commands.impl, "string") 92 vim.validate("commands.iferr", _config.commands.iferr, "string") 93 vim.validate("gotests", _config.gotests, "table") 94 vim.validate("gotests.template", _config.gotests.template, "string") 95 vim.validate("gotests.template_dir", _config.gotests.template_dir, "string", true) 96 vim.validate("gotests.named", _config.gotests.named, "boolean") 97 vim.validate("gotag", _config.gotag, "table") 98 vim.validate("gotag.transform", _config.gotag.transform, "string") 99 vim.validate("gotag.default_tag", _config.gotag.default_tag, "string") 100 vim.validate("iferr", _config.iferr, "table") 101 vim.validate("iferr.message", _config.iferr.message, "string", true) 102end 103 104setmetatable(config, { 105 __index = function(_, key) 106 return _config[key] 107 end, 108}) 109 110---@dochide 111---@return gopher.Config 112return config --[[ @as gopher.Config ]]