Skip to content

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

Closed
@raisin-loaf

Description

@raisin-loaf

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions