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