nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

Missing items in autocomplete

Open BingCoke opened this issue 2 years ago • 2 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config


cmp.setup({
	snippet = {
		expand = function(args)
			require("luasnip").lsp_expand(args.body)
		end,
	},
	mapping = cmp.mapping.preset.insert({
		["<c-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
		["<c-j>"] = cmp.mapping.select_next_item(), -- next suggestion

		["<C-u>"] = cmp.mapping.scroll_docs(-4),
		["<C-d>"] = cmp.mapping.scroll_docs(4),

		["<A-Space>"] = cmp.mapping.complete(), -- show completion suggestions

		["<C-e>"] = cmp.mapping.abort(), -- close completion window
		["<Tab>"] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }),

		["<c-l>"] = cmp.mapping(function(fallback)
			if luasnip.jumpable(1) then
				luasnip.jump(1)
			else
				fallback()
			end
		end, { "i", "s" }),

		["<c-h>"] = cmp.mapping(function(fallback)
			if luasnip.jumpable(-1) then
				luasnip.jump(-1)
			end
		end, { "i", "s" }),
	}),
	preselect = cmp.PreselectMode.None,
	sources = cmp.config.sources({
		{ name = "nvim_lsp" },
		{ name = "luasnip" },
		{ name = "path" },
	}, {
		{ name = "buffer" },
	}),
	window = {
		completion = cmp.config.window.bordered(),
		documentation = {
			border = border("CmpDocBorder"),
			winhighlight = "Normal:CmpDoc",
			max_width = 20,
		},
	},
})


typescript config

	require("typescript-tools").setup({
		on_attach = function(cli, buf)
			on_attach(cli, buf)
		end,
		capabilities = default_capabilities,
		--handlers = { ... },
		settings = {
			-- spawn additional tsserver instance to calculate diagnostics on it
			separate_diagnostic_server = true,
			-- "change"|"insert_leave" determine when the client asks the server about diagnostic
			publish_diagnostic_on = "insert_leave",
			-- array of strings("fix_all"|"add_missing_imports"|"remove_unused")
			-- specify commands exposed as code_actions
			expose_as_code_action = {},
			tsserver_plugins = {
				-- for TypeScript v4.9+
				--"@styled/typescript-styled-plugin",
				-- or for older TypeScript versions
				--"typescript-styled-plugin",
				"typescript-plugin-css-modules",
			},
			tsserver_file_preferences = {
				includeInlayParameterNameHints = "all",
				includeCompletionsForModuleExports = true,
				quotePreference = "single",
			},
		},
	})

Description

Here is auto complete suggestions. image when i fire "< a - space>" to use cmp.mapping.complete()

Here is result image

Steps to reproduce

I use it in nestjs project with typescript.

  1. npm i -g @nestjs/cli && nest new app to build project
  2. delete these lines in app.service.ts
import { Injectable } from '@nestjs/common';

@Injectable()
  1. input "@Inj" to auto import Injectable.But get nothing.
  2. fire < a - space > will get juggestion list has injectable complete item.

Expected behavior

get consistent result suggestion list

Actual behavior

canot get Injectable from auto complete suggetion list.

Additional context

It seems that the problem is not only here, I use rust,And get same problem. auto complete CopyQ JbIxpy map complete CopyQ jaFmaW

and some suggestion list is ok. I can get consistent result suggestion list image

BingCoke avatar Sep 06 '23 08:09 BingCoke

something interesting, image I will get all item above of '@Injectable' but miss item above of class AppService image

In vscode everything is ok. image

BingCoke avatar Sep 19 '23 00:09 BingCoke

image The author of typescript-tools there is no problem in lsp, so it cloud be a something wrong in cmp?

BingCoke avatar Oct 05 '23 14:10 BingCoke