Closed hajonnes closed 1 year ago
Hey @hajonnes, it looks like you call require("obsidian").setup(...)
twice. You should only call that once. The 2nd time is overwriting the settings from the first.
Ok, Thanks @epwalsh ,
If I might make a suggestion. For me and others that does not know lua and does not know how to merge a three calls to one. I think it would be really great to have an example of merging in the .md file. How to merge all, or some of the functionality you present. Delete is easier that adding. Also one could see the structure of how to merge calls.
Thanks for a good plugin.
With some help I succeded to merge the three calls into one:
lua <<EOF
require("obsidian").setup({
dir = "~/Documents/obsidianVault",
-- adds all new notes to fleeting notes.
notes_subdir = "fleetingNotes",
-- to use advanced uri plugin in obsidan
use_advanced_uri = true,
note_id_func = function(title)
-- Create note IDs in a Zettelkasten format with a timestamp and a suffix.
local suffix = ""
if title ~= nil then
-- If title is given, transform it into valid file name.
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
-- If title is nil, just add 4 random uppercase letters to the suffix.
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
end
end
return tostring(os.time()) .. "-" .. suffix
end
})
vim.keymap.set(
"n",
"gf",
function()
if require('obsidian').util.cursor_on_markdown_link() then
return "<cmd>ObsidianFollowLink<CR>"
else
return "gf"
end
end,
{ noremap = false, expr = true}
)
EOF
No problem, I added a note in 5f48a8b.
📚 The doc issue
Hi, I do not know lua and I'm just beginning with obsidian, but love editing in vim. Now to your descriprion of settings. I did: vim-plug plugin list: ............................................................ " obsidian nvim " ............................................................ " https://github.com/epwalsh/obsidian.nvim " (required) Plug 'nvim-lua/plenary.nvim'
" (optional) for completion: Plug 'hrsh7th/nvim-cmp'
" (optional) for :ObsidianSearch and :ObsidianQuickSwitch commands unless you use telescope: Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim'
" (optional) another alternative for the :ObsidianSearch and :ObsidianQuickSwitch commands: " Plug 'ibhagwan/fzf-lua'
" (optional) for :ObsidianSearch and :ObsidianQuickSwitch commands if you prefer this over fzf.vim: " Plug 'nvim-telescope/telescope.nvim'
" (optional) recommended for syntax highlighting, folding, etc if you're not using nvim-treesitter: " already installed: " Plug 'preservim/vim-markdown' " Plug 'godlygeek/tabular' " needed by 'preservim/vim-markdown'
" (required) Plug 'epwalsh/obsidian.nvim' ..................................................................................................................................... Settings for the plugin:
I when I saw a functionality that might be good I just copied it the example text. You do not say how to execute it in a init.vim file. but I googled it and came up with the above. So now I wonder is it correct? If I use :ObsidianNew hello I get e.g. 1679401871-LOBC.md not 1679401871-hello.md, what did I do wrong? I want the new files to be written to obsidanVault/fleetingNotes. that does not work either. what is wrong there?
from the discription of the plugin: " If you want to customize how the file names / unique IDs for new notes are created, set the configuration option note_id_func to your own function that takes an optional string (the title of the note) as input and returns a string representing a unique ID or file name / path (relative to your vault directory)."
Perhaps I did not understand what you mean and I should have done someting to get the name of the note passed to the function?
well seeing the result it is hard to understand for a newbie what's up. Thanks for your work! :)
Suggest a potential alternative/fix
No response