[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang
1---@toc_entry Commands 2---@tag gopher.nvim-commands 3---@text 4--- If don't want to automatically register plugins' commands, 5--- you can set `vim.g.gopher_register_commands` to `false`, before loading the plugin. 6 7if vim.g.gopher_register_commands == false then 8 return 9end 10 11---@param name string 12---@param fn fun(args: table) 13---@param nargs? number|"*"|"?" 14---@private 15local function cmd(name, fn, nargs) 16 nargs = nargs or 0 17 vim.api.nvim_create_user_command(name, fn, { nargs = nargs }) 18end 19 20cmd("GopherLog", function() 21 vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile()) 22end) 23 24cmd("GoIfErr", function() 25 require("gopher").iferr() 26end) 27 28cmd("GoCmt", function() 29 require("gopher").comment() 30end) 31 32cmd("GoImpl", function(args) 33 require("gopher").impl(unpack(args.fargs)) 34end, "*") 35 36-- :GoInstall 37cmd("GoInstallDeps", function() 38 require("gopher").install_deps() 39end) 40 41cmd("GoInstallDepsSync", function() 42 require("gopher").install_deps { sync = true } 43end) 44 45-- :GoTag 46cmd("GoTagAdd", function(opts) 47 require("gopher").tags.add(unpack(opts.fargs)) 48end, "*") 49 50cmd("GoTagRm", function(opts) 51 require("gopher").tags.rm(unpack(opts.fargs)) 52end, "*") 53 54cmd("GoTagClear", function() 55 require("gopher").tags.clear() 56end) 57 58-- :GoTest 59cmd("GoTestAdd", function() 60 require("gopher").test.add() 61end) 62 63cmd("GoTestsAll", function() 64 require("gopher").test.all() 65end) 66 67cmd("GoTestsExp", function() 68 require("gopher").test.exported() 69end) 70 71-- :Go 72cmd("GoMod", function(opts) 73 require("gopher").mod(opts.fargs) 74end, "*") 75 76cmd("GoGet", function(opts) 77 vim.print(opts) 78 require("gopher").get(opts.fargs) 79end, "*") 80 81cmd("GoWork", function(opts) 82 require("gopher").get(opts.fargs) 83end, "*") 84 85cmd("GoGenerate", function(opts) 86 require("gopher").generate(opts.fargs or "") 87end, "?")