coq_nvim icon indicating copy to clipboard operation
coq_nvim copied to clipboard

Feature Request: UltiSnips integration

Open joshua-afk opened this issue 3 years ago • 11 comments

Hello! I hope that there will be more love and respect for this awesome project!

I know that we can add custom snippets already but I just want to know if there are plans on adding support with UltiSnips. I know I am not the only one who uses that plugin and I have invested a shit ton of time to configure it.

Sorry for my bad English. Drink more water and keep safe!

joshua-afk avatar Sep 22 '21 14:09 joshua-afk

Is this not duplicate of #211?

joiharalds avatar Sep 22 '21 14:09 joiharalds

now that coq has lua plugins, this might be possible?

i will need to look into it however

ms-jpq avatar Sep 22 '21 14:09 ms-jpq

Thank you so much!

joshua-afk avatar Sep 22 '21 15:09 joshua-afk

Is this not duplicate of #211?

I think it is.

However, the solution to the issue is the built-in custom snippet. I am hoping that we can integrate ultisnips to coq.

joshua-afk avatar Sep 22 '21 15:09 joshua-afk

Here's my two cents:

I also had a bunch of UltiSnips snippets that I'd love to have retained, but to my knowledge, UltiSnips doesn't work well with neovim itself, let alone coq. The author of UltiSnips has stated repeatedly that neovim support is "best-effort", and will continue to close all neovim-only bug reports until a maintainer that wants to step up and take control of the neovim side is found.

And, I can also personally attest that UltiSnips doesn't work well with neovim.

To me, this means that supporting UltiSnips via a "lua plugin" (which I take to mean a custom source), would be a bad idea.

Of course the other option is to extend the current snippet parser to the entirety of UltiSnips syntax, which would involve code interpolation, which I believe @ms-jpq is not in favor of supporting.

dnaaun avatar Sep 23 '21 06:09 dnaaun

Thank you so much for clarifying this!

I've also read that thread from UltiSnips but didn't pay much attention. 😅 I am actually starting to migrate my snippets to coq now. I think my problem is solved since I also liked coq custom snippet.

Should I close this Issue or leave it alone for future reference? Since @ms-jpq might actually support it in the future.

joshua-afk avatar Sep 24 '21 20:09 joshua-afk

@davidatbu you have a good point there.

However, I also want to note there (for @ms-jpq) that Ultisnips has the advantage of using Python evaluation in its snippets. As such, most of my snippets written and used in Ultisnips will fail to compile under Coq.

Thanks again for your work @ms-jpq !

krillin666 avatar Oct 06 '21 16:10 krillin666

Is it possible to add ultisnip as a source and will trigger it when select?

And is it possible to unbound default map? Currently could only disable all default maps.

hiberabyss avatar Nov 01 '21 06:11 hiberabyss

With following steps could make coq_vim support ultisnip completion:

  1. Save following content as lua/coq_3p/ultisnip/init.lua:
-- Very simple case
-- Offers suggestions of `vim.lsp.protocol.CompletionItemKind`

return function(spec)
  return function(args, callback)
    local items = {}
    
    -- label      :: display label
    -- insertText :: string | null, default to `label` if null
    -- kind       :: int ∈ `vim.lsp.protocol.CompletionItemKind`
    -- detail     :: doc popup

    for key, val in pairs(vim.fn['UltiSnips#SnippetsInCurrentScope']()) do
      local item = {
        label = tostring(key),
        insertText = key,
        detail = tostring(val)
      }
      table.insert(items, item)
    end

    callback {
      items = items
    }
  end
end
  1. Enable the custom source with following configuration:
require("coq_3p") {
  { src = "ultisnip", short_name = "US" },
}

hiberabyss avatar Nov 01 '21 13:11 hiberabyss

Would also like this to be integrated. The current snippets are not really helpful sadly :(

Will try your solution tomorrow @hiberabyss

tonekk avatar Dec 27 '21 21:12 tonekk

@hiberabyss Thanks for sharing the codes. However, it is not working with my configs.

I have already installed ultisnips and vim-snippets. Any thing I should add to the coq_nvim conifg? Thanks!

ccshao avatar Jul 25 '23 05:07 ccshao