Skip to content

Commit 9882ce0

Browse files
committedMar 16, 2025
refactor(Commands): Merge all commands into one :Obsidian command
1 parent 5eea5d2 commit 9882ce0

File tree

9 files changed

+402
-139
lines changed

9 files changed

+402
-139
lines changed
 

‎CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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

‎README.md

+35-33
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ A **community fork** of the Neovim plugin for writing and navigating [Obsidian](
77

88
Built for people who love the concept of Obsidian -- a simple, markdown-based notes app -- but love Neovim too much to stand typing characters into anything else.
99

10-
If you're new to Obsidian we highly recommend watching [this excellent YouTube video](https://youtu.be/5ht8NYkU9wQ?si=8nbnNsRVnw0xfX2S) for a great overview.
10+
If you're new to Obsidian we highly recommend watching [this excellent YouTube video](https://youtu.be/5ht8NYkU9wQ) for a great overview.
1111

1212
_Keep in mind this plugin is not meant to replace Obsidian, but to complement it._ The Obsidian app is very powerful in its own way; it comes with a mobile app and has a lot of functionality that's not feasible to implement in Neovim, such as the graph explorer view. That said, this plugin stands on its own as well. You don't necessarily need to use it alongside the Obsidian app.
1313

1414
## About the fork
15+
1516
The original project has not been actively maintained for quite a while and with the ever-changing Neovim ecosystem, new widely used tools such as [blink.cmp](https://github.com/Saghen/blink.cmp) or [snacks.picker](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) were not supported.
1617
With bugs, issues and pull requests piling up, people from the community decided to fork and maintain the project.
1718
The fork aims to stay close to the original, but fix bugs, include and merge useful improvements, and ensure long term robustness.
@@ -47,54 +48,54 @@ The fork aims to stay close to the original, but fix bugs, include and merge use
4748

4849
### Commands
4950

50-
- `:ObsidianOpen [QUERY]` to open a note in the Obsidian app.
51+
- `:Obsidian open [QUERY]` to open a note in the Obsidian app.
5152
This command has one optional argument: a query used to resolve the note to open by ID, path, or alias. If not given, the note corresponding to the current buffer is opened.
5253

53-
- `:ObsidianNew [TITLE]` to create a new note.
54+
- `:Obsidian new [TITLE]` to create a new note.
5455
This command has one optional argument: the title of the new note.
5556

56-
- `:ObsidianQuickSwitch` to quickly switch to (or open) another note in your vault, searching by its name using [ripgrep](https://github.com/BurntSushi/ripgrep) with your preferred picker (see [plugin dependencies](#plugin-dependencies) below).
57+
- `:Obsidian quickswitch` to quickly switch to (or open) another note in your vault, searching by its name using [ripgrep](https://github.com/BurntSushi/ripgrep) with your preferred picker (see [plugin dependencies](#plugin-dependencies) below).
5758

58-
- `:ObsidianFollowLink [vsplit|hsplit]` to follow a note reference under the cursor, optionally opening it in a vertical or horizontal split.
59+
- `:Obsidian followlink [vsplit|hsplit]` to follow a note reference under the cursor, optionally opening it in a vertical or horizontal split.
5960

60-
- `:ObsidianBacklinks` for getting a picker list of references to the current buffer.
61+
- `:Obsidian backlinks` for getting a picker list of references to the current buffer.
6162

62-
- `:ObsidianTags [TAG ...]` for getting a picker list of all occurrences of the given tags.
63+
- `:Obsidian tags [TAG ...]` for getting a picker list of all occurrences of the given tags.
6364

64-
- `:ObsidianToday [OFFSET]` to open/create a new daily note. This command also takes an optional offset in days, e.g. use `:ObsidianToday -1` to go to yesterday's note. Unlike `:ObsidianYesterday` and `:ObsidianTomorrow` this command does not differentiate between weekdays and weekends.
65+
- `:Obsidian today [OFFSET]` to open/create a new daily note. This command also takes an optional offset in days, e.g. use `:Obsidian today -1` to go to yesterday's note. Unlike `:Obsidian yesterday` and `:Obsidian tomorrow` this command does not differentiate between weekdays and weekends.
6566

66-
- `:ObsidianYesterday` to open/create the daily note for the previous working day.
67+
- `:Obsidian yesterday` to open/create the daily note for the previous working day.
6768

68-
- `:ObsidianTomorrow` to open/create the daily note for the next working day.
69+
- `:Obsidian tomorrow` to open/create the daily note for the next working day.
6970

70-
- `:ObsidianDailies [OFFSET ...]` to open a picker list of daily notes. For example, `:ObsidianDailies -2 1` to list daily notes from 2 days ago until tomorrow.
71+
- `:Obsidian dailies [OFFSET ...]` to open a picker list of daily notes. For example, `:Obsidian dailies -2 1` to list daily notes from 2 days ago until tomorrow.
7172

72-
- `:ObsidianTemplate [NAME]` to insert a template from the templates folder, selecting from a list using your preferred picker. See ["using templates"](#using-templates) for more information.
73+
- `:Obsidian template [NAME]` to insert a template from the templates folder, selecting from a list using your preferred picker. See ["using templates"](#using-templates) for more information.
7374

74-
- `:ObsidianSearch [QUERY]` to search for (or create) notes in your vault using `ripgrep` with your preferred picker.
75+
- `:Obsidian search [QUERY]` to search for (or create) notes in your vault using `ripgrep` with your preferred picker.
7576

76-
- `:ObsidianLink [QUERY]` to link an inline visual selection of text to a note.
77+
- `:Obsidian link [QUERY]` to link an inline visual selection of text to a note.
7778
This command has one optional argument: a query that will be used to resolve the note by ID, path, or alias. If not given, the selected text will be used as the query.
7879

79-
- `:ObsidianLinkNew [TITLE]` to create a new note and link it to an inline visual selection of text.
80+
- `:Obsidian linknew [TITLE]` to create a new note and link it to an inline visual selection of text.
8081
This command has one optional argument: the title of the new note. If not given, the selected text will be used as the title.
8182

82-
- `:ObsidianLinks` to collect all links within the current buffer into a picker window.
83+
- `:Obsidian links` to collect all links within the current buffer into a picker window.
8384

84-
- `:ObsidianExtractNote [TITLE]` to extract the visually selected text into a new note and link to it.
85+
- `:Obsidian extractnote [TITLE]` to extract the visually selected text into a new note and link to it.
8586

86-
- `:ObsidianWorkspace [NAME]` to switch to another workspace.
87+
- `:Obsidian workspace [NAME]` to switch to another workspace.
8788

88-
- `:ObsidianPasteImg [IMGNAME]` to paste an image from the clipboard into the note at the cursor position by saving it to the vault and adding a markdown image link. You can configure the default folder to save images to with the `attachments.img_folder` option.
89+
- `:Obsidian pasteimg [IMGNAME]` to paste an image from the clipboard into the note at the cursor position by saving it to the vault and adding a markdown image link. You can configure the default folder to save images to with the `attachments.img_folder` option.
8990

90-
- `:ObsidianRename [NEWNAME] [--dry-run]` to rename the note of the current buffer or reference under the cursor, updating all backlinks across the vault. Since this command is still relatively new and could potentially write a lot of changes to your vault, I highly recommend committing the current state of your vault (if you're using version control) before running it, or doing a dry-run first by appending "--dry-run" to the command, e.g. `:ObsidianRename new-id --dry-run`.
91+
- `:Obsidian rename [NEWNAME] [--dry-run]` to rename the note of the current buffer or reference under the cursor, updating all backlinks across the vault. Since this command is still relatively new and could potentially write a lot of changes to your vault, I highly recommend committing the current state of your vault (if you're using version control) before running it, or doing a dry-run first by appending "--dry-run" to the command, e.g. `:Obsidian rename new-id --dry-run`.
9192

92-
- `:ObsidianToggleCheckbox` to cycle through checkbox options.
93+
- `:Obsidian togglecheckbox` to cycle through checkbox options.
9394

94-
- `:ObsidianNewFromTemplate [TITLE]` to create a new note from a template in the templates folder. Selecting from a list using your preferred picker.
95+
- `:Obsidian newfromtemplate [TITLE]` to create a new note from a template in the templates folder. Selecting from a list using your preferred picker.
9596
This command has one optional argument: the title of the new note.
9697

97-
- `:ObsidianTOC` to load the table of contents of the current note into a picker list.
98+
- `:Obsidian toc` to load the table of contents of the current note into a picker list.
9899

99100
### Demo
100101

@@ -110,11 +111,11 @@ The fork aims to stay close to the original, but fix bugs, include and merge use
110111

111112
Specific operating systems also require additional dependencies in order to use all of obsidian.nvim's functionality:
112113

113-
- **Windows WSL** users need [`wsl-open`](https://gitlab.com/4U6U57/wsl-open) for the `:ObsidianOpen` command.
114-
- **MacOS** users need [`pngpaste`](https://github.com/jcsalterego/pngpaste) (`brew install pngpaste`) for the `:ObsidianPasteImg` command.
115-
- **Linux** users need xclip (X11) or wl-clipboard (Wayland) for the `:ObsidianPasteImg` command.
114+
- **Windows WSL** users need [`wsl-open`](https://gitlab.com/4U6U57/wsl-open) for the `:Obsidian open` command.
115+
- **MacOS** users need [`pngpaste`](https://github.com/jcsalterego/pngpaste) (`brew install pngpaste`) for the `:Obsidian pasteimg` command.
116+
- **Linux** users need xclip (X11) or wl-clipboard (Wayland) for the `:Obsidian pasteimg` command.
116117

117-
Search functionality (e.g. via the `:ObsidianSearch` and `:ObsidianQuickSwitch` commands) also requires a picker such [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) (see [plugin dependencies](#plugin-dependencies) below).
118+
Search functionality (e.g. via the `:Obsidian search` and `:Obsidian quickswitch` commands) also requires a picker such [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) (see [plugin dependencies](#plugin-dependencies) below).
118119

119120
### Install and configure
120121

@@ -419,7 +420,7 @@ This is a complete list of all of the options that can be passed to `require("ob
419420
substitutions = {},
420421
},
421422

422-
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
423+
-- Optional, by default when you use `:Obsidian followlink` on a link to an external
423424
-- URL it will be ignored but you can customize this behavior here.
424425
---@param url string
425426
follow_url_func = function(url)
@@ -430,7 +431,7 @@ This is a complete list of all of the options that can be passed to `require("ob
430431
-- vim.ui.open(url) -- need Neovim 0.10.0+
431432
end,
432433

433-
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an image
434+
-- Optional, by default when you use `:Obsidian followlink` on a link to an image
434435
-- file it will be ignored but you can customize this behavior here.
435436
---@param img string
436437
follow_img_func = function(img)
@@ -443,7 +444,7 @@ This is a complete list of all of the options that can be passed to `require("ob
443444
-- https://github.com/Vinzent03/obsidian-advanced-uri
444445
use_advanced_uri = false,
445446

446-
-- Optional, set to true to force ':ObsidianOpen' to bring the app to the foreground.
447+
-- Optional, set to true to force ':Obsidian open' to bring the app to the foreground.
447448
open_app_foreground = false,
448449

449450
picker = {
@@ -467,7 +468,7 @@ This is a complete list of all of the options that can be passed to `require("ob
467468

468469
-- Optional, sort search results by "path", "modified", "accessed", or "created".
469470
-- The recommend value is "modified" and `true` for `sort_reversed`, which means, for example,
470-
-- that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time
471+
-- that `:Obsidian quickswitch` will show the notes sorted by latest modified time
471472
sort_by = "modified",
472473
sort_reversed = true,
473474

@@ -554,12 +555,12 @@ This is a complete list of all of the options that can be passed to `require("ob
554555

555556
-- Specify how to handle attachments.
556557
attachments = {
557-
-- The default folder to place images in via `:ObsidianPasteImg`.
558+
-- The default folder to place images in via `:Obsidian pasteimg`.
558559
-- If this is a relative path it will be interpreted as relative to the vault root.
559560
-- You can always override this per image by passing a full path to the command instead of just a filename.
560561
img_folder = "assets/imgs", -- This is the default
561562

562-
-- Optional, customize the default name or prefix when pasting images via `:ObsidianPasteImg`.
563+
-- Optional, customize the default name or prefix when pasting images via `:Obsidian pasteimg`.
563564
---@return string
564565
img_name_func = function()
565566
-- Prefix image names with timestamp.
@@ -807,4 +808,5 @@ And keep in mind that to reset a configuration option to `nil` you'll have to us
807808
Please read the [CONTRIBUTING](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/.github/CONTRIBUTING.md) guide before submitting a pull request.
808809

809810
## Acknowledgement
811+
810812
We would like to thank [epwalsh](https://github.com/epwalsh) for creating this beautiful plugin. If you're feeling especially generous, [he still appreciates some coffee funds! ❤️](https://www.buymeacoffee.com/epwalsh).

0 commit comments

Comments
 (0)