Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ~/.config/nvim/lua/plugins/obsidian.lua
- -- Setup for obsidian.nvim
- require("obsidian").setup({
- workspaces = {
- {
- name = "cmcscrpt",
- path = "~/Documents/cmcjrny/cmcscrpt",
- },
- {
- name = "storybible",
- path = "~/Documents/cmcjrny/storybible",
- },
- {
- name = "notes",
- path = "~/Documents/cmcjrny/notes",
- },
- },
- daily_notes = {
- folder = "notes/dailies",
- date_format = "%Y-%m-%d",
- alias_format = "%B %-d, %Y",
- default_tags = { "daily-notes" },
- template = nil -- Add template path here if using one
- },
- completion = {
- nvim_cmp = true,
- min_chars = 2,
- },
- log_level = vim.log.levels.INFO, -- Adjust as needed
- -- Optional: Configure additional plugin dependencies
- dependencies = {
- "nvim-lua/plenary.nvim",
- "nvim-treesitter/nvim-treesitter",
- "nvim-telescope/telescope.nvim", -- Enables search and quick-switch functionality
- },
- })
- -- Function to create a new character file from template
- local function create_character_template()
- -- Set paths for the template and folders for each character type
- local template_path = vim.fn.expand("~/Documents/cmcjrny/storybible/templates/CharacterTemplate.md")
- local folders = {
- main = vim.fn.expand("~/Documents/cmcjrny/storybible/chrctrs/main/"),
- minor = vim.fn.expand("~/Documents/cmcjrny/storybible/chrctrs/minor/"),
- secondary = vim.fn.expand("~/Documents/cmcjrny/storybible/chrctrs/secondary/"),
- }
- -- Prompt for the character type
- vim.ui.select({ "main", "minor", "secondary" }, { prompt = "Choose character type:" }, function(folder)
- if folder then
- local target_dir = folders[folder]
- -- Prompt for the new character's filename
- vim.ui.input({ prompt = "Enter character name: " }, function(input)
- if input then
- -- Formulate the target path
- local target_path = target_dir .. input .. ".md"
- -- Check if target directory exists; create it if it doesn't
- vim.fn.mkdir(target_dir, "p")
- -- Copy the template file to the new path
- local result = vim.fn.system({ "cp", template_path, target_path })
- -- Check for errors in the copy command
- if vim.v.shell_error ~= 0 then
- vim.notify("Error copying template: " .. result, vim.log.levels.ERROR)
- else
- -- Open the new character file in Neovim and save it
- vim.cmd("edit " .. target_path)
- vim.cmd("write")
- end
- end
- end)
- end
- end)
- end
- -- Keybinding to create character file with <leader>ct
- vim.keymap.set("n", "<leader>ct", create_character_template, { noremap = true, silent = true })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement