mirror of
https://github.com/obsidian-nvim/obsidian.nvim.git
synced 2026-11-17 03:00:32 +00:00
Page:
Autocmds
Pages
Actions
Attachment
Audio recorder
Autocmds
Bookmarks
Breaking Changes
Cache
Checkbox
Commands
Completion
Daily Notes
Editing this wiki
Extensions
File
Folding
Footer
Frontmatter
Home
Images
Integrations
Keymaps
LSP Progress
LSP
Link
Navigation
Note
Open
Recipes
Resolvers
Scripting
Search
Startup Guide
Statusline
Sync
Tag
Template
Unique Note
Workspace
No results
11
Autocmds
github-actions edited this page 2026-07-25 11:38:35 +00:00
Table of contents
Conventions
Autocmd events provide by this plugin follows following conventions:
- Corresponds to Vim autocmd if reasonable, like
BufWritePostin a vault will triggerObsidianNoteWritePost.
Events
| name | triggered by | data |
|---|---|---|
ObsidianNoteCreate |
Note.create |
{ note, opts } |
ObsidianNoteEnter |
BufEnter |
|
ObsidianNoteLeave |
BufLeave |
|
ObsidianNoteWritePost |
BufWritePost |
|
ObsidianNoteWritePre |
BufWritePre |
|
ObsidianWorkspaceSet |
When you enter or switch workspace | workspace object |
ObsidianSyncChanged |
When obsidian sync changes status | |
ObsidianAttachmentAdded |
After adding an attachment | { path, ctx } |
How to use
vim.api.create_autocmd("User", {
pattern = "ObsidianNoteEnter",
callback = function(ev)
local note = require("obsidian.note").from_buffer(ev.buf)
--- anything you want to do
end,
})
Example
Format code blocks
vim.api.nvim_create_autocmd("User", {
pattern = "ObsidianNoteWritePost",
callback = function(ev)
require("conform").format {
bufnr = ev.buf,
formatters = { "prettier", "injected" },
}
end,
})
Turn off spell based on frontmatter
vim.api.nvim_create_autocmd("User", {
pattern = "ObsidianNoteEnter",
callback = function(ev)
local note = require("obsidian.note").from_buffer(ev.buf)
if note and note.metadata and note.metadata.spell == false then
vim.wo.spell = false
end
end,
})
🌟 obsidian.nvim
Topics
- Actions
- Autocmds
- Commands
- Folding
- Extensions
- Images
- Integrations
- Keymaps
- Navigation
- Scripting
- Startup-Guide
- Recipes
- LSP
- LSP-Progress