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

cmp-omni listed under unavailable source names #1943

Closed
2 tasks done
niklashaa opened this issue May 24, 2024 · 8 comments
Closed
2 tasks done

cmp-omni listed under unavailable source names #1943

niklashaa opened this issue May 24, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@niklashaa
Copy link

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-omni'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ["<C-y>"] = cmp.mapping.confirm({ select = true }),
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
    {
      name = 'omni',
      option = {
        disable_omnifuncs = { 'v:lua.vim.lsp.omnifunc' }
      }
    }
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

Description

neovim version 0.10.0.

Adding cmp-omni results in omni listed under unavailable source names.
:CmpStatus outputs the following:

# ready source names
- buffer

# unavailable source names
- omni

# unknown source names
- nvim_lsp

Only modifications to minimal config are:

  1. Plug 'hrsh7th/cmp-omni'
  2. { name = 'omni' } under sources.

Steps to reproduce

Run nvim with the above config, then run :CmpStatus.

Expected behavior

omni is listed under "ready source names"

Actual behavior

omni is listed under "unavailable source names"

Additional context

I am wondering what the word "unavailable" actually means.
When it comes to sources the status I found were

  1. ready (Ready to use source)
  2. unused (installed source but maybe wrong file type, or not added to sources)?
  3. unavailable?
  4. unknown (Added to sources but not installed correctly)?

It would be really helpful to have some section in the documentation where those terms are described with potential debugging steps.

@niklashaa niklashaa added the bug Something isn't working label May 24, 2024
@Shougo
Copy link

Shougo commented May 25, 2024

cmp-omni is installed?

@niklashaa
Copy link
Author

Plug 'hrsh7th/cmp-omni' should install cmp-omni, right?
Is there something else that I should check to see if installation happened?

@Shougo
Copy link

Shougo commented May 25, 2024

I think it is installed under s:plug_dir.

NOTE: Why you use /tmp directory for plugins? It is removed when you reboot the machine.

@niklashaa
Copy link
Author

niklashaa commented May 25, 2024

I have pretty much copied the suggested vimrc from this link and added the two mentioned lines.

I think it should be installing all plugins everytime I start up vim with this config.

@Shougo
Copy link

Shougo commented May 26, 2024

if !filereadable(s:plug_dir .. '/plug.vim')

It must be:

if !filereadable(s:plug_dir .. '/autoload/plug.vim')

@Shougo
Copy link

Shougo commented May 26, 2024

I am wondering what the word "unavailable" actually means.

I have read the source code.

It means: the source does not work in current buffer.

Adding cmp-omni results in omni listed under unavailable source names.

Because omnifunc option is not set in current buffer.

@Shougo
Copy link

Shougo commented May 26, 2024

Please read the documentation.

*CmpStatus*
  Describes statuses and states of sources.
  Sometimes `unknown` will be printed - this is expected.
  For example, `cmp-nvim-lsp` registers itself on InsertEnter autocommand
  so the status will be shown as `unknown` when running the command.

I have read the code. The source is only registered when LSP server is configured on the buffer with InsertEnter autocmd.

So it is the feature. The issue should be closed.

@niklashaa
Copy link
Author

Thank you for your help @Shougo.
You are right, omnifunc is actually working even though it's shown as unavailable in CmpStatus.

Just for reference.
This is the final vimrc that I was testing with:

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

filetype plugin on
set omnifunc=syntaxcomplete#Complete

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/autoload/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-omni'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ["<C-y>"] = cmp.mapping.confirm({ select = true }),
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
    {
      name = 'omni',
      option = {
        disable_omnifuncs = { 'v:lua.vim.lsp.omnifunc' }
      }
    }
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

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

No branches or pull requests

2 participants