Coder Social home page Coder Social logo

cmp-omni's Introduction

cmp-omni's People

Contributors

hrsh7th avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cmp-omni's Issues

Support replacement offest

One thing many legacy omnicomplete functions do is return a position for the start of the completion as well as an array of possible items. I've taken a few stabs at wiring up a legacy omni complete function to cmp without much luck. I got pretty close by setting keyword_patterm = [[.*]] and stuffing everything that the complete function can touch into vim's iskeyword setting, but it's still clunky.

According to this comment the textEdit property might offer a solution, but I have no idea where to start.

It seems to me like this plugin should offer a way to shim the two so that omni complete functions can be a dropin source even if they return results that don't start at the beginning of the current keyword (which seems to be cmp's assumption).

Vimtex support isn't complete

When I go in a .tex file, I want omni completion so I can use vimtex omni suggestions to my advantage. When I type \a for example, the suggestions are correct and I get this:

image

However with some letters, some completion is missing. For example if I type \b I get:
image

Which is missing a LOT of omni completions. For example \beta, or \backslash. If I type <c-x><c-o> with \b I get:
image
And I dont get any of that with nvim-cmp
I have noticed the same problem with \s, \e, and a lot of other letters. For example \p does include all the options from the omni completion, but this varies from time to time.

This is my init.vim:

call plug#begin()
Plug 'lervag/vimtex' 
Plug 'hrsh7th/nvim-cmp'
Plug 'SirVer/ultisnips'

"nvim-cmp sources
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-omni'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'

call plug#end()
lua <<EOF
  -- Setup nvim-cmp.
  local cmp = require'cmp'

  cmp.setup({

    snippet = {
      expand = function(args)
        vim.fn["UltiSnips#Anon"](args.body) 
      end,
    },

    mapping = {
         ['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
         ['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
    },

    sources = cmp.config.sources({
      { name = 'ultisnips' }, 
      { name = 'omni' }, 
      { name = 'buffer' },
    })

  })

  -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline('/', {
    sources = {
      { name = 'buffer' }
    }
  })

  cmp.setup.cmdline(':', {
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    })
  })

EOF ```

Open cmp.complete() after snippet expansion

First, I'm not sure if this is best suited for this module or the ultisnips module I am using.

Expected Behavior
When a snippet expands into some text that would normally trigger the completion window to open, the completion window should open.

Example
I am mainly working with tex documents. I have a snippet which automatically triggers when I type cite which expands to ~\cite{|} with the cursor marked with the pipe character. Without the snippet, if I type ~\cite{ the completion window appears with citation entries populated by the associated bibtex file (note: I am using the configuration from here).

This is how it has worked for me in the past when I used, e.g., deoplete.

Completion is auto selected when omni source is used

Sorry about my bad description. More about this issue, please have a look at the screen recording. When I type a character, then a completion is selected immediately, and also there are two popup.

2022-11-22.17.15.48.mov

Minimal init.lua to Reproduce this issue:

require("packer").startup({
  {
    "wbthomason/packer.nvim",
    "hrsh7th/nvim-cmp",
    "hrsh7th/cmp-nvim-lsp",
    "hrsh7th/cmp-omni",
    "neovim/nvim-lspconfig",
  },
})

local cmp = require("cmp")
local cmp_lsp = require("cmp_nvim_lsp")
local lspconfig = require("lspconfig")
lspconfig.sumneko_lua.setup {
  cmd = { "lua-language-server" },
  settings = {
    Lua = {
      telemetry = { enable = false },
    },
  },
  capabilities = cmp_lsp.default_capabilities(),
}
cmp.setup {
  sources = cmp.config.sources({
    { name = "nvim_lsp" },
  }, {
    { name = "omni" },
  })
}

Add other omnifunc items to completion menu

The omnifunc can provide a number of items for displaying in the completion-menu, as seen here: https://neovim.io/doc/user/insert.html#complete-items
Adding these entries shouldnt be too hard, see lervag/vimtex#2215 (comment), but it doesn't really look good. I suggest adding a new key to the items table, e.g. called menu.
This could be passed in the nvim-cmp/lua/cmp/source.lua file somewhere here: https://github.com/hrsh7th/nvim-cmp/blob/092fb66b6ddb4b12b9b542d105d7af40e4fbd9f2/lua/cmp/source.lua#L309.
I am willing to help if you think this is a good idea @hrsh7th.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.