Closed Caylub closed 2 years ago
Interesting, seems to work for me, could be something with your cmp config.
Thanks for the detailed report, I'll have a look and see whats up
Ok here's my config, should fix the issue for you, I should probably add this to the wiki
Thanks for the reply! Would you mind sending me your neovim config?
Expected Behavior
Typing
.
after a variable should resolve methods from LSP into my autocomplete plugin.Current Behavior
LSP works as expected when declaring imports, without delays or any other strange behavior.
When attempting to use the LSP to populate the autocomplete in other contexts, for instance in the case of trying to populate the autocomplete menu with resolved methods of a type, it doesn't work.
Ex:
let x: str = "SomeString".
doesn't show anything in the autocomplete menu.Possible Solution
I'm not sure what's going on since it works as expected in one context and not at all in the other.
Steps to Reproduce
0.8.0-dev+151-gd30621064
, install simrat39/rust-tools.nvimcargo new ...
main.rs
local snip_status_ok, luasnip = pcall(require, "luasnip") if not snip_status_ok then return end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function() local col = vim.fn.col "." - 1 return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" end
local kind_icons = { Text = "", Method = "m", Function = "", Constructor = "", Field = "", Variable = "", Class = "", Interface = "", Module = "", Property = "", Unit = "", Value = "", Enum = "", Keyword = "", Snippet = "", Color = "", File = "", Reference = "", Folder = "", EnumMember = "", Constant = "", Struct = "", Event = "", Operator = "", TypeParameter = "", }
cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) -- For"] = cmp.mapping.select_prev_item(),
[""] = cmp.mapping.select_next_item(),
[""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
[""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
[""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
[""] = cmp.config.disable,
[""] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
[""] = cmp.mapping.confirm { select = true },
[""] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
[""] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
nvim_lsp = "[LS]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = {
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
},
},
view = {
ghost_text = false,
native_menu = false,
},
}
luasnip
users. end, }, mapping = { ["