From a954102fa10be40ef89e30bc68934b803e9b14ee Mon Sep 17 00:00:00 2001 From: n451 <2020200706@ruc.edu.cn> Date: Tue, 4 Mar 2025 20:23:49 +0800 Subject: [PATCH 1/3] doc: add instruction for rocks.nvim, warning for packer.nvim doc: remove some verbose description in plugin dependencies --- README.md | 64 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 9c5e3fb41..35e8cfc44 100644 --- a/README.md +++ b/README.md @@ -120,10 +120,12 @@ Here are some examples using different plugin managers. The full set of [plugin #### Using [`lazy.nvim`](https://github.com/folke/lazy.nvim) +
Click for install snippet + ```lua return { "obsidian-nvim/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit + version = "*", -- recommended, use latest release instead of latest commit lazy = true, ft = "markdown", -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: @@ -157,12 +159,28 @@ return { } ``` +
+ +#### Using [`rocks.nvim`](https://github.com/nvim-neorocks/rocks.nvim) + +
Click for install snippet + +```vim +:Rocks install obsidian +``` + +
+ #### Using [`packer.nvim`](https://github.com/wbthomason/packer.nvim) +It is not recommended because packer.nvim is currently unmaintained + +
Click for install snippet + ```lua -use({ +use { "obsidian-nvim/obsidian.nvim", - tag = "*", -- recommended, use latest release instead of latest commit + tag = "*", -- recommended, use latest release instead of latest commit requires = { -- Required. "nvim-lua/plenary.nvim", @@ -170,7 +188,7 @@ use({ -- see below for full list of optional dependencies 👇 }, config = function() - require("obsidian").setup({ + require("obsidian").setup { workspaces = { { name = "personal", @@ -183,31 +201,34 @@ use({ }, -- see below for full list of options 👇 - }) + } end, -}) +} ``` +
+ ### Plugin dependencies The only **required** plugin dependency is [plenary.nvim](https://github.com/nvim-lua/plenary.nvim), but there are a number of optional dependencies that enhance the obsidian.nvim experience. **Completion:** -- **[recommended]** [hrsh7th/nvim-cmp](https://github.com/hrsh7th/nvim-cmp): for completion of note references. -- [blink.cmp](https://github.com/Saghen/blink.cmp) (new): for completion of note references. +- **[recommended]** [hrsh7th/nvim-cmp](https://github.com/hrsh7th/nvim-cmp) +- [blink.cmp](https://github.com/Saghen/blink.cmp) (new) **Pickers:** -- **[recommended]** [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim): for search and quick-switch functionality. -- [Mini.Pick](https://github.com/echasnovski/mini.pick) from the mini.nvim library: an alternative to telescope for search and quick-switch functionality. -- [ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua): another alternative to telescope for search and quick-switch functionality. -- [Snacks.Picker](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) from the snacks.nvim library: an alternative to mini and telescope for search and quick-switch functionality. +- **[recommended]** [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) +- [ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua) +- [Mini.Pick](https://github.com/echasnovski/mini.pick) from the mini.nvim library +- [Snacks.Picker](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md) from the snacks.nvim library **Syntax highlighting:** -- **[recommended]** [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): for base markdown syntax highlighting. See [syntax highlighting](#syntax-highlighting) for more details. -- [preservim/vim-markdown](https://github.com/preservim/vim-markdown): an alternative to nvim-treesitter for syntax highlighting (see [syntax highlighting](#syntax-highlighting) for more details), plus other cool features. +- **[recommended]** [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): for base markdown syntax highlighting. +- [preservim/vim-markdown](https://github.com/preservim/vim-markdown) +- See [syntax highlighting](#syntax-highlighting) for more details. **Miscellaneous:** @@ -217,7 +238,7 @@ If you choose to use any of these you should include them in the "dependencies" ### Configuration options -This is a complete list of all of the options that can be passed to `require("obsidian").setup()`. The settings below are *not necessarily the defaults, but represent reasonable default settings*. Please read each option carefully and customize it to your needs: +This is a complete list of all of the options that can be passed to `require("obsidian").setup()`. The settings below are _not necessarily the defaults, but represent reasonable default settings_. Please read each option carefully and customize it to your needs: ```lua { @@ -564,7 +585,7 @@ config = { name = "personal", path = "~/vaults/personal", }, - } + }, } ``` @@ -591,13 +612,12 @@ config = { -- ... }, }, - } + }, } ``` obsidian.nvim also supports "dynamic" workspaces. These are simply workspaces where the `path` is set to a Lua function (that returns a path) instead of a hard-coded path. This can be useful in several scenarios, such as when you want a workspace whose `path` is always set to the parent directory of the current buffer: - ```lua config = { workspaces = { @@ -607,7 +627,7 @@ config = { return assert(vim.fs.dirname(vim.api.nvim_buf_get_name(0))) end, }, - } + }, } ``` @@ -627,12 +647,12 @@ Note that in order to trigger completion for tags _within YAML frontmatter_ you If you're using [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/README.md) you're configuration should include both "markdown" and "markdown_inline" sources: ```lua -require("nvim-treesitter.configs").setup({ +require("nvim-treesitter.configs").setup { ensure_installed = { "markdown", "markdown_inline", ... }, highlight = { enable = true, }, -}) +} ``` If you use `vim-markdown` you'll probably want to disable its frontmatter syntax highlighting (`vim.g.vim_markdown_frontmatter = 1`) which I've found doesn't work very well. @@ -734,7 +754,7 @@ templates = { ### Usage outside of a workspace or vault -It's possible to configure obsidian.nvim to work on individual markdown files outside of a regular workspace / Obsidian vault by configuring a "dynamic" workspace. To do so you just need to add a special workspace with a function for the `path` field (instead of a string), which should return a *parent* directory of the current buffer. This tells obsidian.nvim to use that directory as the workspace `path` and `root` (vault root) when the buffer is not located inside another fixed workspace. +It's possible to configure obsidian.nvim to work on individual markdown files outside of a regular workspace / Obsidian vault by configuring a "dynamic" workspace. To do so you just need to add a special workspace with a function for the `path` field (instead of a string), which should return a _parent_ directory of the current buffer. This tells obsidian.nvim to use that directory as the workspace `path` and `root` (vault root) when the buffer is not located inside another fixed workspace. For example, to extend the configuration above this way: From b5a15a394d0c2f54555a5b047091a60f3628d9fd Mon Sep 17 00:00:00 2001 From: n451 <2020200706@ruc.edu.cn> Date: Tue, 4 Mar 2025 20:43:29 +0800 Subject: [PATCH 2/3] fix: offload markdown rendering to render-markdown/markview --- README.md | 11 ++++++++--- lua/obsidian/client.lua | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 35e8cfc44..5b612e118 100644 --- a/README.md +++ b/README.md @@ -226,9 +226,14 @@ The only **required** plugin dependency is [plenary.nvim](https://github.com/nvi **Syntax highlighting:** -- **[recommended]** [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): for base markdown syntax highlighting. -- [preservim/vim-markdown](https://github.com/preservim/vim-markdown) -- See [syntax highlighting](#syntax-highlighting) for more details. +See [syntax highlighting](#syntax-highlighting) for more details. + +- For base syntax highlighting: + - **[recommended]** [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) + - [preservim/vim-markdown](https://github.com/preservim/vim-markdown) +- For additional syntax features: + - [render-markdown.nvim](https://github.com/MeanderingProgrammer/render-markdown.nvim) + - [markview.nvim](https://github.com/OXY2DEV/markview.nvim) **Miscellaneous:** diff --git a/lua/obsidian/client.lua b/lua/obsidian/client.lua index 00c09c77f..c6492bdc2 100644 --- a/lua/obsidian/client.lua +++ b/lua/obsidian/client.lua @@ -125,7 +125,8 @@ Client.set_workspace = function(self, workspace, opts) self.callback_manager = CallbackManager.new(self, self.opts.callbacks) -- Setup UI add-ons. - if self.opts.ui.enable then + local has_no_renderer = not (util.get_plugin_info "render-markdown.nvim" or util.get_plugin_info "markview.nvim") + if has_no_renderer and self.opts.ui.enable then require("obsidian.ui").setup(self.current_workspace, self.opts.ui) end From 39ff5a03a657d26f48737cafd9913a54e9853814 Mon Sep 17 00:00:00 2001 From: n451 <2020200706@ruc.edu.cn> Date: Tue, 4 Mar 2025 20:50:53 +0800 Subject: [PATCH 3/3] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f2a20617..0b7a9af84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Renamed `opts.image_name_func` to `opts.attachments.img_name_func`. +- Default to not activate ui render when `render-markdown.nvim` or `markview.nvim` is present ### Fixed