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

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

Closed
raisin-loaf opened this issue Jul 5, 2024 · 3 comments · Fixed by #647
Closed

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

raisin-loaf opened this issue Jul 5, 2024 · 3 comments · Fixed by #647
Labels
bug Something isn't working

Comments

@raisin-loaf
Copy link

raisin-loaf commented Jul 5, 2024

🐛 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
@raisin-loaf raisin-loaf added the bug Something isn't working label Jul 5, 2024
@raisin-loaf raisin-loaf changed the title Anchor Completion Limited To First 500 Lines Of A File Anchor completion limited to first 500 lines of a file Jul 5, 2024
@epwalsh
Copy link
Owner

epwalsh commented Jul 11, 2024

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

@epwalsh
Copy link
Owner

epwalsh commented Jul 11, 2024

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

@raisin-loaf
Copy link
Author

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. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants