Skip to content

Commit 4ab368c

Browse files
authored
feat!(node): Autogen names can be snake_cased (default: false)
1 parent 1ccc4e4 commit 4ab368c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lua/neorg/modules/external/roam/module.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.config.public = {
1818
fuzzy_backlinks = false,
1919
roam_base_directory = "",
2020
node_name_randomiser = false,
21+
node_name_snake_case = false,
2122
}
2223

2324
module.load = function()
@@ -324,8 +325,13 @@ module.public = {
324325
-- Map <C-n> to create a new node with the given title in the default note vault
325326
map("i", "<C-n>", function()
326327
local prompt = module.private.telescope_modules.state.get_current_line()
327-
local title_token = module.config.public.node_name_randomiser and name_tokeniser(prompt)
328-
or prompt
328+
local title_token = prompt
329+
if module.config.public.node_name_randomiser then
330+
title_token = name_tokeniser(prompt)
331+
elseif module.config.public.node_name_snake_case then
332+
title_token = title_token:lower()
333+
title_token = title_token:gsub(" ", "_")
334+
end
329335
module.private.telescope_modules.actions.close(prompt_bufnr)
330336

331337
-- Ensure the vault directory exists
@@ -416,8 +422,13 @@ module.public = {
416422
function(_, opt)
417423
-- Input query is in opt.__call_opts.query
418424
local prompt = opt.__call_opts.query
419-
local title_token = module.config.public.node_name_randomiser and name_tokeniser(prompt)
420-
or prompt
425+
local title_token = prompt
426+
if module.config.public.node_name_randomiser then
427+
title_token = name_tokeniser(prompt)
428+
elseif module.config.public.node_name_snake_case then
429+
title_token = title_token:lower()
430+
title_token = title_token:gsub(" ", "_")
431+
end
421432

422433
-- Ensure the vault directory exists
423434
local vault_dir = base_directory

0 commit comments

Comments
 (0)