epwalsh / obsidian.nvim

Obsidian 🀝 Neovim
Apache License 2.0
4.06k stars 186 forks source link

Anchor completion limited to first 500 lines of a file #644

Closed raisin-loaf closed 3 months ago

raisin-loaf commented 3 months ago

πŸ› Describe the bug

I have a few large notes, some > 2000 lines. I noticed that when attempting to link to these files not all the anchors appeared in the completion menu. After experimenting, it appeared anchors past 500 lines were unavailable. I found the search_max_lines option in the docs but wasn't confident cause the default is 1000. I set it to 2000 but didn't see a change.

I then searched the codebase and found a DEFAULT_MAX_LINES local variable set to 500. After upping this to 2000 the anchors I was missing appeared in the completion menu.

I'm no Lua dev, but it looks like DEFAULT_MAX_LINES is optionally overriden by opts.max_lines, although I'm guessing this isn't happening for whichever invocation of Note.from_lines is used for completion. Is it possible to expose an option for this use case? How would I go about trying to do that? πŸ™‚

Config

  {
    'epwalsh/obsidian.nvim',
    dependencies = { 'nvim-lua/plenary.nvim' },
    event = {
      -- only for Obsidian vault buffers
      'BufReadPre ' .. vim.fn.expand '~' .. '/notes/**.md'
    },
    opts = {
      workspaces = {
        {
          name = 'notes',
          path = '~/notes',

          overrides = {
            disable_frontmatter = true
          }
        }
      },
      ui = {
        enable = false
      },
      wiki_link_func = "use_alias_only"
    }
  },

Environment

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.8.1 (e170641143704068233ba1d301e75684b67fc07c)
Status:
  β€’ buffer directory: nil
  β€’ working directory: [redacted]
Workspaces:
  βœ“ active workspace: Workspace(name='notes', path='[redacted]', root='[redacted]')
Dependencies:
  βœ“ plenary.nvim: a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683
  βœ“ nvim-cmp: a110e12d0b58eefcf5b771f533fc2cf3050680ac
Integrations:
  βœ“ picker: nil
  βœ“ completion: enabled (nvim-cmp) βœ— refs, βœ— tags, βœ— new
    all sources:
      β€’ nvim_lsp
Tools:
  βœ“ rg: ripgrep 13.0.0
Environment:
  β€’ operating system: Wsl
Config:
  β€’ notes_subdir: nil
epwalsh commented 3 months ago

Hey @raisin-loaf, I believe #647 should fix this.

epwalsh commented 3 months ago

Let me know if you still have issues. It's possible I missed another call where this option needs to get propagated.

raisin-loaf commented 3 months ago

Let me know if you still have issues. It's possible I missed another call where this option needs to get propagated.

This looks to have fixed it, thanks so much for the speedy response, and for a terrific plugin in general. πŸ‘