diff --git a/lua/gopher/config.lua b/lua/gopher/config.lua new file mode 100644 index 0000000..e9ef346 --- /dev/null +++ b/lua/gopher/config.lua @@ -0,0 +1,19 @@ +local M = { + config = { + ---set custom commands for tools + commands = { + go = "go", + gomodifytags = "gomodifytags", + gotests = "gotests", + impl = "impl", + }, + }, +} + +---PLugin setup function +---@param opts table user options +function M.setup(opts) + M.config = vim.tbl_deep_extend("force", M.config, opts) +end + +return M diff --git a/lua/gopher/gogenerate.lua b/lua/gopher/gogenerate.lua index ddf756d..93f78da 100644 --- a/lua/gopher/gogenerate.lua +++ b/lua/gopher/gogenerate.lua @@ -1,4 +1,5 @@ local Job = require "plenary.job" +local c = require("gopher.config").config.commands local u = require "gopher._utils" ---run "go generate" @@ -12,7 +13,7 @@ return function(...) Job :new({ - command = "go", + command = c.go, args = cmd_args, on_exit = function(_, retval) if retval ~= 0 then diff --git a/lua/gopher/goget.lua b/lua/gopher/goget.lua index a14f796..8d79626 100644 --- a/lua/gopher/goget.lua +++ b/lua/gopher/goget.lua @@ -1,4 +1,5 @@ local Job = require "plenary.job" +local c = require("gopher.config").config.commands local u = require "gopher._utils" ---run "go get" @@ -19,7 +20,7 @@ return function(...) Job :new({ - command = "go", + command = c.go, args = cmd_args, on_exit = function(_, retval) if retval ~= 0 then diff --git a/lua/gopher/gomod.lua b/lua/gopher/gomod.lua index e451868..61f19a2 100644 --- a/lua/gopher/gomod.lua +++ b/lua/gopher/gomod.lua @@ -1,4 +1,5 @@ local Job = require "plenary.job" +local c = require("gopher.config").config.commands local u = require "gopher._utils" ---run "go mod" @@ -13,7 +14,7 @@ return function(...) Job :new({ - command = "go", + command = c.go, args = cmd_args, on_exit = function(_, retval) if retval ~= 0 then diff --git a/lua/gopher/gotests.lua b/lua/gopher/gotests.lua index d7cd47c..0ae98b0 100644 --- a/lua/gopher/gotests.lua +++ b/lua/gopher/gotests.lua @@ -1,5 +1,6 @@ local Job = require "plenary.job" local ts_utils = require "gopher._utils.ts" +local c = require("gopher.config").config.commands local u = require "gopher._utils" local M = {} @@ -7,7 +8,7 @@ local M = {} local function run(cmd_args) Job :new({ - command = "gotests", + command = c.gotests, args = cmd_args, on_exit = function(_, retval) if retval ~= 0 then diff --git a/lua/gopher/health.lua b/lua/gopher/health.lua index 30ab04f..d628ddc 100644 --- a/lua/gopher/health.lua +++ b/lua/gopher/health.lua @@ -1,4 +1,5 @@ local utils = require "gopher._utils" +local c = require("gopher.config").config.commands local M = { _required = { plugins = { @@ -6,10 +7,10 @@ local M = { { lib = "nvim-treesitter" }, }, binarys = { - { bin = "go", help = "required for GoMod, GoGet, GoGenerate command" }, - { bin = "gomodifytags", help = "required for modify struct tags" }, - { bin = "impl", help = "required for interface implementing" }, - { bin = "gotests", help = "required for test(s) generation" }, + { bin = c.go, help = "required for GoMod, GoGet, GoGenerate command" }, + { bin = c.gomodifytags, help = "required for modify struct tags" }, + { bin = c.impl, help = "required for interface implementing" }, + { bin = c.gotests, help = "required for test(s) generation" }, }, }, } diff --git a/lua/gopher/impl.lua b/lua/gopher/impl.lua index 363dc5f..1c504ee 100644 --- a/lua/gopher/impl.lua +++ b/lua/gopher/impl.lua @@ -1,5 +1,6 @@ local Job = require "plenary.job" local ts_utils = require "gopher._utils.ts" +local c = require("gopher.config").config.commands local u = require "gopher._utils" ---@return string @@ -55,7 +56,7 @@ return function(...) local res_data Job :new({ - command = "impl", + command = c.impl, args = cmd_args, on_exit = function(data, retval) if retval ~= 0 then diff --git a/lua/gopher/init.lua b/lua/gopher/init.lua index 72acfdd..bd2591d 100644 --- a/lua/gopher/init.lua +++ b/lua/gopher/init.lua @@ -12,5 +12,6 @@ gopher.generate = require "gopher.gogenerate" gopher.test_add = gotests.one_test gopher.test_exported = gotests.all_exported_tests gopher.tests_all = gotests.all_tests +gopher.setup = require("gopher.config").setup return gopher diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index f82a641..27cfe39 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -1,6 +1,7 @@ local Job = require "plenary.job" local ts_utils = require "gopher._utils.ts" local u = require "gopher._utils" +local c = require("gopher.config").config.commands local M = {} local function modify(...) @@ -42,7 +43,7 @@ local function modify(...) local res_data Job :new({ - command = "gomodifytags", + command = c.gomodifytags, args = cmd_args, on_exit = function(data, retval) if retval ~= 0 then