Skip to content

Commit 6372d33

Browse files
committed
refactor(Commands): Merge all commands into one :Obsidian command
1 parent 5eea5d2 commit 6372d33

File tree

9 files changed

+460
-196
lines changed

9 files changed

+460
-196
lines changed

CHANGELOG.md

+64-61
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) with respect to the public API, which currently includes the installation steps, dependencies, configuration, keymappings, commands, and other plugin functionality. At the moment this does *not* include the Lua `Client` API, although in the future it will once that API stabilizes.
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) with respect to the public API, which currently includes the installation steps, dependencies, configuration, keymappings, commands, and other plugin functionality. At the moment this does _not_ include the Lua `Client` API, although in the future it will once that API stabilizes.
77

88
## Unreleased
99

1010
### Added
1111

1212
- Added `opts.follow_img_func` option for customizing how to handle image paths.
1313
- Added better handling for undefined template fields, which will now be prompted for.
14-
- Added support for the [`snacks.picker`](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) picker
14+
- Added support for the [`snacks.picker`](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) picker.
1515
- Added support for the [`blink.cmp`](https://github.com/Saghen/blink.cmp) completion plugin.
16+
- Added `opts.legacy_commands` option which enables the old commands.
1617

1718
### Changed
1819

1920
- Renamed `opts.image_name_func` to `opts.attachments.img_name_func`.
20-
- Default to not activate ui render when `render-markdown.nvim` or `markview.nvim` is present
21+
- Default to not activate ui render when `render-markdown.nvim` or `markview.nvim` is present.
22+
- Moved all commands into one `:Obsidian` command.
2123

2224
### Fixed
2325

@@ -196,11 +198,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
196198
There's a lot of new features and improvements here that I'm really excited about 🥳 They've improved my workflow a ton and I hope they do for you too. To highlight the 3 biggest additions:
197199

198200
1. 🔗 Full support for header anchor links and block links! That means both for following links and completion of links. Various forms of anchor/block links are support. Here are a few examples:
199-
- Typical Obsidian-style wiki links, e.g. `[[My note#Heading 1]]`, `[[My note#Heading 1#Sub heading]]`, `[[My note#^block-123]]`.
200-
- Wiki links with a label, e.g. `[[my-note#heading-1|Heading 1 in My Note]]`.
201-
- Markdown links, e.g. `[Heading 1 in My Note](my-note.md#heading-1)`.
202201

203-
We also support links to headers within the same note, like for a table of contents, e.g. `[[#Heading 1]]`, `[[#heading-1|Heading]]`, `[[#^block-1]]`.
202+
- Typical Obsidian-style wiki links, e.g. `[[My note#Heading 1]]`, `[[My note#Heading 1#Sub heading]]`, `[[My note#^block-123]]`.
203+
- Wiki links with a label, e.g. `[[my-note#heading-1|Heading 1 in My Note]]`.
204+
- Markdown links, e.g. `[Heading 1 in My Note](my-note.md#heading-1)`.
205+
206+
We also support links to headers within the same note, like for a table of contents, e.g. `[[#Heading 1]]`, `[[#heading-1|Heading]]`, `[[#^block-1]]`.
204207

205208
2. 📲 A basic callback system to let you easily customize obisidian.nvim's behavior even more. There are currently 4 events: `post_setup`, `enter_note`, `pre_write_note`, and `post_set_workspace`. You can define a function for each of these in your config.
206209
3. 🔭 Improved picker integrations (especially for telescope), particular for the `:ObsidianTags` command. See <https://github.com/epwalsh/obsidian.nvim/discussions/450> for a demo.
@@ -211,44 +214,44 @@ Full changelog below 👇
211214

212215
- Added a configurable callback system to further customize obsidian.nvim's behavior. Callbacks are defined through the `callbacks` field in the config:
213216

214-
```lua
215-
callbacks = {
216-
-- Runs at the end of `require("obsidian").setup()`.
217-
---@param client obsidian.Client
218-
post_setup = function(client) end,
219-
220-
-- Runs anytime you enter the buffer for a note.
221-
---@param client obsidian.Client
222-
---@param note obsidian.Note
223-
enter_note = function(client, note) end,
224-
225-
-- Runs anytime you leave the buffer for a note.
226-
---@param client obsidian.Client
227-
---@param note obsidian.Note
228-
leave_note = function(client, note) end,
229-
230-
-- Runs right before writing the buffer for a note.
231-
---@param client obsidian.Client
232-
---@param note obsidian.Note
233-
pre_write_note = function(client, note) end,
234-
235-
-- Runs anytime the workspace is set/changed.
236-
---@param client obsidian.Client
237-
---@param workspace obsidian.Workspace
238-
post_set_workspace = function(client, workspace) end,
239-
}
240-
```
217+
```lua
218+
callbacks = {
219+
-- Runs at the end of `require("obsidian").setup()`.
220+
---@param client obsidian.Client
221+
post_setup = function(client) end,
222+
223+
-- Runs anytime you enter the buffer for a note.
224+
---@param client obsidian.Client
225+
---@param note obsidian.Note
226+
enter_note = function(client, note) end,
227+
228+
-- Runs anytime you leave the buffer for a note.
229+
---@param client obsidian.Client
230+
---@param note obsidian.Note
231+
leave_note = function(client, note) end,
232+
233+
-- Runs right before writing the buffer for a note.
234+
---@param client obsidian.Client
235+
---@param note obsidian.Note
236+
pre_write_note = function(client, note) end,
237+
238+
-- Runs anytime the workspace is set/changed.
239+
---@param client obsidian.Client
240+
---@param workspace obsidian.Workspace
241+
post_set_workspace = function(client, workspace) end,
242+
}
243+
```
241244

242245
- Added configuration option `note_path_func(spec): obsidian.Path` for customizing how file names for new notes are generated. This takes a single argument, a table that looks like `{ id: string, dir: obsidian.Path, title: string|? }`, and returns an `obsidian.Path` object. The default behavior is equivalent to this:
243246

244-
```lua
245-
---@param spec { id: string, dir: obsidian.Path, title: string|? }
246-
---@return string|obsidian.Path The full path to the new note.
247-
note_path_func = function(spec)
248-
local path = spec.dir / tostring(spec.id)
249-
return path:with_suffix(".md")
250-
end
251-
```
247+
```lua
248+
---@param spec { id: string, dir: obsidian.Path, title: string|? }
249+
---@return string|obsidian.Path The full path to the new note.
250+
note_path_func = function(spec)
251+
local path = spec.dir / tostring(spec.id)
252+
return path:with_suffix(".md")
253+
end
254+
```
252255

253256
- Added config option `picker.tag_mappings`, analogous to `picker.note_mappings`.
254257
- Added `log` field to `obsidian.Client` for easier access to the logger.
@@ -498,7 +501,7 @@ Minor internal improvements.
498501

499502
### Added
500503

501-
- Added extmarks that conceal "-", "*", or "+" with "" by default. This can turned off by setting `.ui.bullets` to `nil` in your config.
504+
- Added extmarks that conceal "-", "\*", or "+" with "•" by default. This can turned off by setting `.ui.bullets` to `nil` in your config.
502505

503506
### Fixed
504507

@@ -554,26 +557,26 @@ Minor internal improvements.
554557
- Added Lua API methods `Client:set_workspace(workspace: obsidian.Workspace)` and `Client:switch_workspace(workspace: string|obsidian.Workspace)`.
555558
- Added the ability to override settings per workspace by providing the `overrides` field in a workspace definition. For example:
556559

557-
```lua
558-
require("obsidian").setup({
559-
workspaces = {
560-
{
561-
name = "personal",
562-
path = "~/vaults/personal",
563-
},
564-
{
565-
name = "work",
566-
path = "~/vaults/work",
567-
-- Optional, override certain settings.
568-
overrides = {
569-
notes_subdir = "notes",
570-
},
560+
```lua
561+
require("obsidian").setup({
562+
workspaces = {
563+
{
564+
name = "personal",
565+
path = "~/vaults/personal",
566+
},
567+
{
568+
name = "work",
569+
path = "~/vaults/work",
570+
-- Optional, override certain settings.
571+
overrides = {
572+
notes_subdir = "notes",
571573
},
572574
},
575+
},
573576

574-
-- ... other options ...
575-
})
576-
```
577+
-- ... other options ...
578+
})
579+
```
577580

578581
### Fixed
579582

@@ -905,7 +908,7 @@ Major internal refactoring to bring performance improvements through async execu
905908
### Added
906909

907910
- Added support for [fzf-lua](https://github.com/ibhagwan/fzf-lua) as one of the possible fallbacks for the `:ObsidianQuickSwitch` command.
908-
- Added `:ObsidianQuickSwitch` to fuzzy-find a note by name in telescope/fzf *a la* <C-O> in Obsidian.
911+
- Added `:ObsidianQuickSwitch` to fuzzy-find a note by name in telescope/fzf _a la_ <C-O> in Obsidian.
909912
- Added support for [fzf-lua](https://github.com/ibhagwan/fzf-lua) as one of the possible fallbacks for the `:ObsidianSearch` command.
910913
- Added `:ObsidianFollowLink` and companion function `util.cursor_on_markdown_link`
911914
- Added `:ObsidianLink` and `:ObsidianLinkNew` commands.

0 commit comments

Comments
 (0)