Neorgcmd Module - nvim-neorg/neorg Wiki

Neorgcmd module for Neorg.


This module deals with handling everything related to the :Neorg command.



How to Apply


No public configuration

Developer Usage

Public API

This segment will detail all of the functions core.neorgcmd exposes. All of these functions reside in the public table.


Adding a Neorg command

-- In your module.setup(), make sure to require core.neorgcmd (requires = { "core.neorgcmd" })
-- Afterwards in a function of your choice that gets called *after* core.neorgcmd gets intialized e.g. load():

module.load = function()
        definitions = { -- Used for completion
            my_command = { -- Define a command called my_command
                my_subcommand = {}, -- Define a subcommand called my_subcommand
        data = { -- Metadata about our commands, should follow the same structure as the definitions table
            my_command = {
                min_args = 1, -- Tells neorgcmd that we want at least one argument for this command
                max_args = 1, -- Tells neorgcmd we want no more than one argument
                args = 1, -- Setting this variable instead would be the equivalent of min_args = 1 and max_args = 1

                subcommands = { -- Defines subcommands

                    -- Repeat the definition cycle again
                    my_subcommand = {
                        args = 0, -- We don't want any arguments
                        name = "my.command", -- The identifying name of this command

                        -- We do not define a subcommands table here because we don't have any more subcommands
                        -- Creating an empty subcommands table will cause errors so don't bother
-- Afterwards, you want to subscribe to the corresponding event: = {
    ["core.neorgcmd"] = {
        ["my.command"] = true, -- Has the same name as our "name" variable had in the "data" table

-- There's also another way to define your own custom commands that's a lot more automated. Such automation can be achieved
-- by putting your code in a special directory. That directory is in core.neorgcmd.commands. Creating your modules in this directory
-- will allow users to easily enable you as a "command module" without much hassle.

-- To enable a command in the commands/ directory, do this:

    load = {
        ["core.neorgcmd"] = {
            config = {
                load = {
                    "some.neorgcmd", -- The name of a valid command

-- And that's it! You're good to go.
-- Want to find out more? Read the wiki entry!

Extra Info


This module supports at least version 0.0.9. The current Neorg version is 0.0.9.


This module does not import any other files.


This module does not require any other modules to operate.

Required by