feat: move all lua api into api module

This commit is contained in:
Smirnov Oleksandr 2022-10-07 16:41:40 +03:00
parent d65884b182
commit 294902970d
3 changed files with 41 additions and 29 deletions

26
lua/gopher/api.lua Normal file
View file

@ -0,0 +1,26 @@
local API = {}
local tags = require "gopher.struct_tags"
local tests = require "gopher.gotests"
local cmd = require "gopher._utils.commands"
API.install_deps = require "gopher.installer"
API.tags_add = tags.add
API.tags_rm = tags.remove
API.impl = require "gopher.impl"
API.iferr = require "gopher.iferr"
API.comment = require "gopher.comment"
API.test_add = tests.func_test
API.test_exported = tests.all_exported_tests
API.tests_all = tests.all_tests
API.get = function(...)
cmd("get", ...)
end
API.mod = function(...)
cmd("mod", ...)
end
API.generate = function(...)
cmd("generate", ...)
end
return API

View file

@ -1,19 +1,5 @@
local tags = require "gopher.struct_tags"
local gotests = require "gopher.gotests"
local gopher = {}
local GOPHER = {}
gopher.install_deps = require "gopher.installer"
gopher.tags_add = tags.add
gopher.tags_rm = tags.remove
gopher.mod = require "gopher.gomod"
gopher.get = require "gopher.goget"
gopher.impl = require "gopher.impl"
gopher.generate = require "gopher.gogenerate"
gopher.iferr = require "gopher.iferr"
gopher.comment = require "gopher.comment"
gopher.test_add = gotests.func_test
gopher.test_exported = gotests.all_exported_tests
gopher.tests_all = gotests.all_tests
gopher.setup = require("gopher.config").setup
GOPHER.setup = require("gopher.config").setup
return gopher
return GOPHER

View file

@ -1,12 +1,12 @@
command! -nargs=* GoTagAdd :lua require"gopher".tags_add(<f-args>)
command! -nargs=* GoTagRm :lua require"gopher".tags_rm(<f-args>)
command! -nargs=* GoTestAdd :lua require"gopher".test_add(<f-args>)
command! -nargs=* GoTestsAll :lua require"gopher".tests_all(<f-args>)
command! -nargs=* GoTestsExp :lua require"gopher".test_exported(<f-args>)
command! -nargs=* GoMod :lua require"gopher".mod(<f-args>)
command! -nargs=* GoGet :lua require"gopher".get(<f-args>)
command! -nargs=* GoImpl :lua require"gopher".impl(<f-args>)
command! -nargs=* GoGenerate :lua require"gopher".generate(<f-args>)
command! GoCmt :lua require"gopher".comment()
command! GoIfErr :lua require"gopher".iferr()
command! GoInstallDeps :lua require"gopher".install_deps()
command! -nargs=* GoTagAdd :lua require"gopher.api".tags_add(<f-args>)
command! -nargs=* GoTagRm :lua require"gopher.api".tags_rm(<f-args>)
command! -nargs=* GoTestAdd :lua require"gopher.api".test_add(<f-args>)
command! -nargs=* GoTestsAll :lua require"gopher.api".tests_all(<f-args>)
command! -nargs=* GoTestsExp :lua require"gopher.api".test_exported(<f-args>)
command! -nargs=* GoMod :lua require"gopher.api".mod(<f-args>)
command! -nargs=* GoGet :lua require"gopher.api".get(<f-args>)
command! -nargs=* GoImpl :lua require"gopher.api".impl(<f-args>)
command! -nargs=* GoGenerate :lua require"gopher.api".generate(<f-args>)
command! GoCmt :lua require"gopher.api".comment()
command! GoIfErr :lua require"gopher.api".iferr()
command! GoInstallDeps :lua require"gopher.api".install_deps()