Purpose

Obsidian is great, but it doesn't offer the first-class Neovim experience that some of us just can't seem to do without. obsidian.nvim does a good job of letting us enjoy the best of both worlds by enabling users to navigate the obsidian vault inside Neovim. The main motivation for that plugin was to improve the neovim experience with Obsidian vaults, while still viewing the rendered notes in the Obsidian app.

This plugin takes that concept one step further by mirroring navigation events in Neovim in the Obsidian app. If you open a note in Neovim the Obsidian App will show the same note automatically. If you navigate to another one or navigates to another Neovim buffer, the Obsidian app will show the corresponding note.

This is accomplished by leveraging the Local REST API plugin for Obsidian.

Demo

demo

Installation

  1. Make sure you have curl installed on your system and available on your PATH.

  2. Install and enable the Local REST API community plugin in Obsidian. The default configuration of obsidian-sync.nvim will try to connect to the non-encrypted server variant so remember to enable that in the Local REST API settings if you want to use it.

  3. Set the environment variable OBSIDIAN_REST_API_KEY to the API key found in the Local REST API settings within Obsidian, for example:

export OBSIDIAN_REST_API_KEY=<your api key, without the brackets>
  1. Install obsidian-sync.nvim, here are examples for some popular package managers:
Lazy
{
  "oflisback/obsidian-sync.nvim",
  config = function() require("obsidian-sync").setup() end,
  lazy = false
}
Packer
require('packer').startup(function()
    use {
      'oflisback/obsidian-sync.nvim',
      config = function() require('obsidian-sync').setup() end
    }
end)
vim-plug
Plug 'oflisback/obsidian-sync.nvim'

Configuration

If no config parameter is provided to the setup function this default configuration will be used:

{
  obsidian_server_address = "http://localhost:27123"
}

Pass a config table as parameter to the setup function to provide an alternative server address, for example to use with lazy:

{
  "oflisback/obsidian-sync.nvim",
  config = function() require("obsidian-sync").setup({
    obsidian_server_address = "https://localhost:27124"
  }) end,
  lazy = false
}

Contributing

Contributions, bug reports and suggestions are very welcome.

If you have a suggestion that would make the project better, please fork the repo and create a pull request.

Future

  • Detect if a file is located inside an Obsidian vault or not.
  • Scroll to corresponding line on Neovim navigation events. If the user views line n in Neovim, scroll to line n also in Obsidian.