-
-
Notifications
You must be signed in to change notification settings - Fork 240
Neorgcmd Module
github-actions[bot] edited this page Feb 4, 2022
·
465 revisions
This module deals with handling everything related to the :Neorg command.
- This module is already present in the
core.defaultsmetamodule. You can load the module with:In your Neorg setup.["core.defaults"] = {},
- To manually load the module, place this code in your Neorg setup:
Consult the configuration section to see how you can configure
["core.neorgcmd"] = { config = { -- Note that this table is optional and doesn't need to be provided -- Configuration here } }
core.neorgcmdto your liking.
No public configuration
This segment will detail all of the functions core.neorgcmd exposes. All of these functions reside in the public table.
set_completion_callbackfunction_callbackadd_commands_from_tableadd_commands_from_filesyncadd_commands
-- 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()
module.required["core.neorgcmd"].add_commands_from_table({
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
},
},
},
},
})
end
-- Afterwards, you want to subscribe to the corresponding event:
module.events.subscribed = {
["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:
require("neorg").setup({
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! https://github.com/vhyrro/neorg/wiki/Neorg-CommandThis module supports at least version 0.0.10. The current Neorg version is 0.0.10.
This module does not import any other files.
This module does not require any other modules to operate.
-
core.norg.dirman- This module is be responsible for managing directories full of .norg files. -
core.norg.journal- Easily create files for a journal. -
core.norg.news- Handles the displaying of Neorg news and other forms of media in a popup. -
core.neorgcmd.commands.return- Return to last location before entering Neorg. -
core.norg.qol.toc- Generates a Table of Content from the Neorg file. -
core.neorgcmd.commands.module.list- List loaded modules. -
core.neorgcmd.commands.module.load- Load a new module dynamically. -
core.keybinds- Module for managing keybindings with Neorg mode support.
core.autocommandscore.clipboardcore.clipboard.code-blockscore.completioncore.concealercore.defaultscore.dirmancore.dirman.utilscore.esupports.hopcore.esupports.indentcore.esupports.metagencore.exportcore.export.htmlcore.export.markdowncore.fscore.highlightscore.integrations.coq_nvimcore.integrations.nvim-cmpcore.integrations.nvim-compecore.integrations.treesittercore.iterocore.journalcore.keybindscore.latex.renderercore.looking-glasscore.neorgcmdcore.neorgcmd.commands.returncore.pivotcore.presentercore.promocore.qol.toccore.qol.todo_itemscore.queries.nativecore.scannercore.storagecore.summarycore.syntaxcore.tanglecore.tempuscore.text-objectscore.todo-introspectorcore.uicore.ui.calendar