Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add instruction for rocks.nvim, warning for packer.nvim #14

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
69 changes: 47 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<details><summary>Click for install snippet</summary>

```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:
Expand Down Expand Up @@ -157,20 +159,36 @@ return {
}
```

</details>

#### Using [`rocks.nvim`](https://github.com/nvim-neorocks/rocks.nvim)

<details><summary>Click for install snippet</summary>

```vim
:Rocks install obsidian
```

</details>

#### Using [`packer.nvim`](https://github.com/wbthomason/packer.nvim)

It is not recommended because packer.nvim is currently unmaintained

<details><summary>Click for install snippet</summary>

```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",

-- see below for full list of optional dependencies 👇
},
config = function()
require("obsidian").setup({
require("obsidian").setup {
workspaces = {
{
name = "personal",
Expand All @@ -183,31 +201,39 @@ use({
},

-- see below for full list of options 👇
})
}
end,
})
}
```

</details>

### 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.
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:**

Expand All @@ -217,7 +243,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
{
Expand Down Expand Up @@ -564,7 +590,7 @@ config = {
name = "personal",
path = "~/vaults/personal",
},
}
},
}
```

Expand All @@ -591,13 +617,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 = {
Expand All @@ -607,7 +632,7 @@ config = {
return assert(vim.fs.dirname(vim.api.nvim_buf_get_name(0)))
end,
},
}
},
}
```

Expand All @@ -627,12 +652,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.
Expand Down Expand Up @@ -734,7 +759,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:

Expand Down
3 changes: 2 additions & 1 deletion lua/obsidian/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this mean that even if a user tries to explicitly enable this plugin's ui, they wouldn't be able to do it if they have one of the other markdown rendering plugins? Maybe this could be the default behavior, but the user could enable it if they prefer. Or is there a reason to not allow them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because for now the two renderers are all automatically attaching to markdown buffers, and we have no way to shut them down when users want the builtin renderer. Thus causing conflict and bad user experience. People get very confused by this in the issue i mentioned. (me as well)

We could upstream stuff to the renderers like a buffer local varible to turn them off, but i think since our goal is to finally phase the builtin module out, it would make sense to just use the builtin as the last resort.

require("obsidian.ui").setup(self.current_workspace, self.opts.ui)
end

Expand Down