feat(config): naive implementation
feat(config): get command for a run from config
This commit is contained in:
parent
ebb3894b3b
commit
bcb8f09311
9 changed files with 37 additions and 10 deletions
19
lua/gopher/config.lua
Normal file
19
lua/gopher/config.lua
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue