bug: haunt.nvim creates bookmark entries in multiple json files, opens only one file? #75

Closed
opened 2026-04-20 04:19:34 -05:00 by rubin55 · 3 comments
rubin55 commented 2026-04-20 04:19:34 -05:00 (Migrated from github.com)

Did you check docs and existing issues?

  • I have read all the haunt.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of haunt.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.12.1

Operating system/version

Arch Linux

Describe the bug

Haunt seems to create double entries in multiple json files:

My ~/.haunt directory:

# pwd
/home/rubin/.haunt
# ls -l
total 8
-rw-r--r-- 1 rubin rubin 777 Apr 20 11:09 34545a7a603d.json
-rw-r--r-- 1 rubin rubin 376 Apr 20 10:56 6b26a8cd99c7.json

34545a7a603d.json:

{
  "version": 1,
  "bookmarks": [
    {
      "annotation_extmark_id": 2,
      "note": "Neovim configuration file",
      "line": 1,
      "file": "/home/rubin/Source/Rubin/dotfiles/.config/nvim/init.lua",
      "extmark_id": 1,
      "id": "b3736781086a1a9e"
    },
    {
      "annotation_extmark_id": 2,
      "note": "Wallet development notes",
      "line": 1,
      "file": "/home/rubin/Documents/Rubin/Notes/projects/wallet.md",
      "extmark_id": 1,
      "id": "dbb2440233a2fc98"
    },
    {
      "annotation_extmark_id": 2,
      "note": "Client id constructor for x509_hash",
      "line": 288,
      "file": "/home/rubin/Source/ICTU/wallet/wallet_core/lib/openid4vc/src/openid4vp.rs",
      "extmark_id": 1,
      "id": "ee89a514053c26b2"
    },
    {
      "annotation_extmark_id": 2,
      "note": "Client identifier x509_hash todo",
      "line": 1,
      "file": "/home/rubin/Documents/Rubin/Notes/scratch/client_id_analysis/todo.md",
      "extmark_id": 1,
      "id": "eee192436c5169e6"
    }
  ]
}

6b26a8cd99c7.json:

{
  "version": 1,
  "bookmarks": [
    {
      "annotation_extmark_id": 2,
      "note": "Neovim configuration file",
      "line": 1,
      "file": "/home/rubin/Source/Rubin/dotfiles/.config/nvim/init.lua",
      "extmark_id": 1,
      "id": "b3736781086a1a9e"
    },
    {
      "annotation_extmark_id": 2,
      "note": "Wallet development notes",
      "line": 1,
      "file": "/home/rubin/Documents/Rubin/Notes/projects/wallet.md",
      "extmark_id": 1,
      "id": "dbb2440233a2fc98"
    }
  ]
}

Steps To Reproduce

  1. Configure haunt.nvim, use static bookmarks location ~/.haunt
  2. Make a few bookmarks
  3. Observe double entries in separate files?

Expected Behavior

I expect bookmarks to exist in one .json file, or multiple (one per file?) but not the same entries in multiple files.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "TheNoeTrevino/haunt.nvim", opts = {} },
    -- add any other plugins here
  },
})

-- Haunt configuration.
local haunt = require('haunt')
local haunt_api = require('haunt.api')
local haunt_picker = require('haunt.picker')

haunt.setup({
  picker = 'fzf'
})

haunt_api.change_data_dir(vim.fn.expand('~/.haunt/'))

vim.keymap.set('n', 'ma', function() haunt_api.annotate() end, { desc = 'Add bookmark' })
vim.keymap.set('n', 'md', function() haunt_api.delete() end, { desc = 'Delete bookmark' })
vim.keymap.set('n', 'mC', function() haunt_api.clear_all() end, { desc = 'Delete all bookmarks' })
vim.keymap.set('n', 'mp', function() haunt_api.prev() end, { desc = 'Previous bookmark' })
vim.keymap.set('n', 'mn', function() haunt_api.next() end, { desc = 'Next bookmark' })
vim.keymap.set('n', 'mt', function() haunt_api.toggle_annotation() end, { desc = 'Toggle bookmark inline annotation message' })
vim.keymap.set('n', 'mT', function() haunt_api.toggle_all_lines() end, { desc = 'Toggle all bookmark inline annotation messages' })
vim.keymap.set('n', 'mQ', function() haunt_api.to_quickfix({ current_buffer = true }) end, { desc = 'Send bookmarks to Quickfix (buffer)' })
vim.keymap.set('n', 'mq', function() haunt_api.to_quickfix() end, { desc = 'Send bookmarks to Quickfix (all)' })
vim.keymap.set('n', 'my', function() haunt_api.yank_locations({ current_buffer = true }) end, { desc = 'Send bookmarks to Clipboard (buffer)' })
vim.keymap.set('n', 'mY', function() haunt_api.yank_locations() end, { desc = 'Send bookmarks to Clipboard (all)' })
vim.keymap.set('n', '<Leader>m', function() haunt_picker.show({ prompt = 'Bookmarks> ' }) end, { desc = 'Show bookmark picker' })
### Did you check docs and existing issues? - [x] I have read all the haunt.nvim docs - [x] I have updated the plugin to the latest version before submitting this issue - [x] I have searched the existing issues of haunt.nvim - [x] I have searched the existing issues of plugins related to this issue ### Neovim version (nvim -v) 0.12.1 ### Operating system/version Arch Linux ### Describe the bug Haunt seems to create double entries in multiple json files: My `~/.haunt` directory: ```bash # pwd /home/rubin/.haunt # ls -l total 8 -rw-r--r-- 1 rubin rubin 777 Apr 20 11:09 34545a7a603d.json -rw-r--r-- 1 rubin rubin 376 Apr 20 10:56 6b26a8cd99c7.json ``` 34545a7a603d.json: ```json { "version": 1, "bookmarks": [ { "annotation_extmark_id": 2, "note": "Neovim configuration file", "line": 1, "file": "/home/rubin/Source/Rubin/dotfiles/.config/nvim/init.lua", "extmark_id": 1, "id": "b3736781086a1a9e" }, { "annotation_extmark_id": 2, "note": "Wallet development notes", "line": 1, "file": "/home/rubin/Documents/Rubin/Notes/projects/wallet.md", "extmark_id": 1, "id": "dbb2440233a2fc98" }, { "annotation_extmark_id": 2, "note": "Client id constructor for x509_hash", "line": 288, "file": "/home/rubin/Source/ICTU/wallet/wallet_core/lib/openid4vc/src/openid4vp.rs", "extmark_id": 1, "id": "ee89a514053c26b2" }, { "annotation_extmark_id": 2, "note": "Client identifier x509_hash todo", "line": 1, "file": "/home/rubin/Documents/Rubin/Notes/scratch/client_id_analysis/todo.md", "extmark_id": 1, "id": "eee192436c5169e6" } ] } ``` 6b26a8cd99c7.json: ``` { "version": 1, "bookmarks": [ { "annotation_extmark_id": 2, "note": "Neovim configuration file", "line": 1, "file": "/home/rubin/Source/Rubin/dotfiles/.config/nvim/init.lua", "extmark_id": 1, "id": "b3736781086a1a9e" }, { "annotation_extmark_id": 2, "note": "Wallet development notes", "line": 1, "file": "/home/rubin/Documents/Rubin/Notes/projects/wallet.md", "extmark_id": 1, "id": "dbb2440233a2fc98" } ] } ``` ### Steps To Reproduce 1. Configure haunt.nvim, use static bookmarks location `~/.haunt` 2. Make a few bookmarks 3. Observe double entries in separate files? ### Expected Behavior I expect bookmarks to exist in one .json file, or multiple (one per file?) but not the same entries in multiple files. ### Repro ```lua vim.env.LAZY_STDPATH = ".repro" load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))() require("lazy.minit").repro({ spec = { { "TheNoeTrevino/haunt.nvim", opts = {} }, -- add any other plugins here }, }) -- Haunt configuration. local haunt = require('haunt') local haunt_api = require('haunt.api') local haunt_picker = require('haunt.picker') haunt.setup({ picker = 'fzf' }) haunt_api.change_data_dir(vim.fn.expand('~/.haunt/')) vim.keymap.set('n', 'ma', function() haunt_api.annotate() end, { desc = 'Add bookmark' }) vim.keymap.set('n', 'md', function() haunt_api.delete() end, { desc = 'Delete bookmark' }) vim.keymap.set('n', 'mC', function() haunt_api.clear_all() end, { desc = 'Delete all bookmarks' }) vim.keymap.set('n', 'mp', function() haunt_api.prev() end, { desc = 'Previous bookmark' }) vim.keymap.set('n', 'mn', function() haunt_api.next() end, { desc = 'Next bookmark' }) vim.keymap.set('n', 'mt', function() haunt_api.toggle_annotation() end, { desc = 'Toggle bookmark inline annotation message' }) vim.keymap.set('n', 'mT', function() haunt_api.toggle_all_lines() end, { desc = 'Toggle all bookmark inline annotation messages' }) vim.keymap.set('n', 'mQ', function() haunt_api.to_quickfix({ current_buffer = true }) end, { desc = 'Send bookmarks to Quickfix (buffer)' }) vim.keymap.set('n', 'mq', function() haunt_api.to_quickfix() end, { desc = 'Send bookmarks to Quickfix (all)' }) vim.keymap.set('n', 'my', function() haunt_api.yank_locations({ current_buffer = true }) end, { desc = 'Send bookmarks to Clipboard (buffer)' }) vim.keymap.set('n', 'mY', function() haunt_api.yank_locations() end, { desc = 'Send bookmarks to Clipboard (all)' }) vim.keymap.set('n', '<Leader>m', function() haunt_picker.show({ prompt = 'Bookmarks> ' }) end, { desc = 'Show bookmark picker' }) ```
rubin55 commented 2026-04-20 04:23:00 -05:00 (Migrated from github.com)

Actually, this is worse than originally documented: When nvim closes, and/or restarts, then listing your bookmarks, lists the bookmarks from just one of these files. I just restarted with the above, and only two bookmarks show up, instead of all four.

Actually, this is worse than originally documented: When `nvim` closes, and/or restarts, then listing your bookmarks, lists the bookmarks from just one of these files. I just restarted with the above, and only two bookmarks show up, instead of all four.
Owner

Okay, I have pinpointed the issue. It happens when either you switch branches, or :cd into a different directory. Basically any context change. The in memory bookmarks don't 'know' that the context has changed, and will save to that new context.

I have to think about how I am going to want to solve this. The directory switch fix is going to be simple, but I need to think about how git branch changes are going to be picked up. I don't know if I am going to want to check if the branch has changed on every single save. I will revisit this soon!

Okay, I have pinpointed the issue. It happens when either you switch branches, or `:cd` into a different directory. Basically any context change. The in memory bookmarks don't 'know' that the context has changed, and will save to that new context. I have to think about how I am going to want to solve this. The directory switch fix is going to be simple, but I need to think about how git branch changes are going to be picked up. I don't know if I am going to want to check if the branch has changed on every single save. I will revisit this soon!
Owner

Fixed by: 6d9cf9b

Fixed by: 6d9cf9b
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
noe.trevino/haunt.nvim#75
No description provided.