quangnguyen30192 / cmp-nvim-ultisnips

nvim-cmp source for ultisnips
Apache License 2.0
145 stars 19 forks source link

Add support for LSP snippets #15

Closed anstadnik closed 3 years ago

anstadnik commented 3 years ago

Some LSPs can create snippets for functions, methods etc. One of such LSP is ccls. For example, when I enter the following cpp code:

#include <iostream>

void int_and_char(int i, char c) {
  std::cout << i << c << std::endl;
}

int main(void)
{
  int_and_char
  return 0;
}

, and I put the cursor at the end of the first line in the main function, the LSP would suggest me a snippet for function int_and_char, but it is not being expanded.

anstadnik commented 3 years ago

I've seen #13, and tried to remove ray-x/lsp_signature.nvim. Didn't help

vsedov commented 3 years ago

Hmm, for this, try clang as it works on clang -

local clangd_flags = {
    "--background-index",
    "--cross-file-rename",
    "--clang-tidy-checks=clang-diagnostic-*,clang-analyzer-*,-*,bugprone*,modernize*,performance*,-modernize-pass-by-value,-modernize-use-auto,-modernize-use-using,-modernize-use-trailing-return-type",
}

lspconfig.clangd.setup({
    cmd = { "clangd", unpack(clangd_flags) },
    on_attach = enhance_attach,
    capabilities = capabilities,
})

as it expands and jumps over etc, see if that works :)

anstadnik commented 3 years ago

Eventually I've created my mappings based on this, and now everything works like a charm