feat: Allow subcommands in :Neogen (#36)

This commit is contained in:
danymat
2022-01-11 10:27:56 +01:00
parent a740d15235
commit fd780bfbe6

View File

@@ -16,9 +16,8 @@ require("neogen.granulators.default")
require("neogen.generators.default") require("neogen.generators.default")
neogen.generate = function(opts) neogen.generate = function(opts)
opts = opts or { opts = opts or {}
type = "func", opts.type = (opts.type == nil or opts.type == "") and "func" or opts.type -- Default type
}
local parser = vim.treesitter.get_parser(0, vim.bo.filetype) local parser = vim.treesitter.get_parser(0, vim.bo.filetype)
local tstree = parser:parse()[1] local tstree = parser:parse()[1]
@@ -133,7 +132,7 @@ function neogen.jumpable(reverse)
end end
function neogen.generate_command() function neogen.generate_command()
vim.api.nvim_command('command! -range -bar Neogen lua require("neogen").generate()') vim.api.nvim_command('command! -nargs=? -range -bar Neogen lua require("neogen").generate({ type = <q-args>})')
end end
neogen.setup = function(opts) neogen.setup = function(opts)