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

Expand Snippet shows on the command line #70

Open
medwatt opened this issue Mar 13, 2022 · 6 comments
Open

Expand Snippet shows on the command line #70

medwatt opened this issue Mar 13, 2022 · 6 comments
Labels
mappings Anything related to the recommended mappings

Comments

@medwatt
Copy link

medwatt commented Mar 13, 2022

I came across this which is basically the same question as this one. Unfortunately, it seems that the issue still exists. Have a look at the video recording below.

local p1, cmp = pcall(require, "cmp")
local p2, cmp_ultisnips_mappings = pcall(require, "cmp_nvim_ultisnips.mappings")

cmp.setup({

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

    sources = {
        { name = "ultisnips" },
        { name = "nvim_lua" },
        { name = "nvim_lsp" },
        { name = "buffer", keyword_length = 5},
        { name = "path" },
    },

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

        ["<Tab>"] = cmp.mapping(
            function(fallback) cmp_ultisnips_mappings.expand_or_jump_forwards(fallback) end,
            {"i", "s"}),

        ["<S-Tab>"] = cmp.mapping(
          function(fallback) cmp_ultisnips_mappings.jump_backwards(fallback) end,
            {"i", "s"}),
    },

})
2022-03-13.05-26-06.mp4
@smjonas smjonas added the mappings Anything related to the recommended mappings label Mar 13, 2022
@smjonas
Copy link
Collaborator

smjonas commented Mar 13, 2022

Thanks for the report, could you share the definition for the frac snippet? If you are already at the last tabstop when pressing Tab, I don't think that this can be fixed since it then calls fallback() which is handled by nvim-cmp.

@medwatt
Copy link
Author

medwatt commented Mar 13, 2022

Thanks for the report, could you share the definition for the frac snippet? If you are already at the last tabstop when pressing Tab, I don't think that this can be fixed since it then calls fallback() which is handled by nvim-cmp.

context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet

@jasonkena
Copy link

@medwatt how did you manage to get the snippet to auto-expand with context "math()"? Adding the context is preventing me from expanding the snippet.

@smjonas
Copy link
Collaborator

smjonas commented Mar 19, 2022

@jasonkena Until now, custom context snippets were not handled correctly. Now that I had time to add proper support for them, could you quickly test this feature? That would be awesome, I want to be sure I didn't break things! :) They should now only be shown when the custom context function returns True. Here is the PR: #72 (you can use my fork https://github.com/smjonas/cmp-nvim-ultisnips on the custom_context_snippets branch.

@jasonkena
Copy link

@smjonas unfortunately, it does not seem to work. On the main branch, I can at least see the snippet in the menu (still being unable to expand it), but using your fork, I can't. Any ideas?

@smjonas
Copy link
Collaborator

smjonas commented Mar 20, 2022

Yeah sorry, this was a bit of a rushed attempt to implement this... I did test this with 2 custom snippets only and it seemed to work. I'll work on the feature when I have time. Thanks for testing though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mappings Anything related to the recommended mappings
Projects
None yet
Development

No branches or pull requests

3 participants