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

completion from cmp suggestion #54

Closed
disidrosi opened this issue Nov 23, 2022 · 6 comments · Fixed by #55
Closed

completion from cmp suggestion #54

disidrosi opened this issue Nov 23, 2022 · 6 comments · Fixed by #55
Labels
bug Something isn't working

Comments

@disidrosi
Copy link

🐛 Describe the bug

Thank you so much for the great plugin, I've been waiting for something like this since months.
I seem to have a problem with completion using cmp suggestions. When triggered with [[, cmp correctly returns the list of notes in my vault, but when I hit enter to select one I get the following error:

E5108: Error executing lua ...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:347: attempt to index local 'replace_range' (a nil value)
stack traceback:
        ...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:347: in function 'callback'
        .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/cache.lua:38: in function 'get_replace_range'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:428: in function <...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:419>
        ...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:45>

Every other cmp functionality works correctly, so the error seems to be specific to obsidian.nvim, but I'm not sure.

Here's my configuration for obsidian.nvim:

require('obsidian').setup {
  dir = '~/Documents/Notes',
  completion = {
    nvim_cmp = true, -- if using nvim-cmp, otherwise set to false
  },
  disable_frontmatter = true, -- Do not format note
}

And for completeness, here's also my cmp configuration:

-- nvim-cmp setup
local cmp = require 'cmp'
local luasnip = require 'luasnip'

cmp.setup {
  snippet = {
    expand = function(args)
      luasnip.lsp_expand(args.body)
    end,
  },
  mapping = cmp.mapping.preset.insert {
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
  },
  confirm_opts = {
    behavior = cmp.ConfirmBehavior.Replace,
    select = false,
  },
  sources = cmp.config.sources({
    { name = 'nvim_lsp' },
    { name = 'luasnip' }, -- For luasnip users.
  }, {
    { name = 'omni' },
    { name = 'buffer' },
  }),
}

Versions

Nvim version:

NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.1/share/nvim"

Nvim headless: 1.6.1

@disidrosi disidrosi added the bug Something isn't working label Nov 23, 2022
@epwalsh
Copy link
Owner

epwalsh commented Nov 23, 2022

Thanks @disidrosi, I wonder if nvim-cmp has changed something recently that broke the obsidian completion. I'll dig into this.

@epwalsh
Copy link
Owner

epwalsh commented Nov 23, 2022

Well I just upgraded nvim-cmp to the latest commit and I wasn't able to reproduce. Do you have the latest commit too?

@disidrosi
Copy link
Author

Thanks for the help. Yes, I'm using Packer and everything is up to date.

epwalsh added a commit that referenced this issue Nov 23, 2022
@epwalsh
Copy link
Owner

epwalsh commented Nov 23, 2022

Can you try using this branch? #55

@disidrosi
Copy link
Author

Can you try using this branch? #55

This indeed fixed the error!

@epwalsh
Copy link
Owner

epwalsh commented Nov 23, 2022

Yay!

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