| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- -- return {
- -- { "hrsh7th/nvim-cmp", enabled = true },
- -- {
- -- "saghen/blink.cmp",
- -- lazy = false, -- lazy loading handled internally
- -- -- optional: provides snippets for the snippet source
- -- dependencies = "rafamadriz/friendly-snippets",
- --
- -- -- use a release tag to download pre-built binaries
- -- version = "v0.*",
- -- -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
- -- -- build = 'cargo build --release',
- -- -- On musl libc based systems you need to add this flag
- -- -- build = 'RUSTFLAGS="-C target-feature=-crt-static" cargo build --release',
- --
- -- opts = {
- -- highlight = {
- -- -- sets the fallback highlight groups to nvim-cmp's highlight groups
- -- -- useful for when your theme doesn't support blink.cmp
- -- -- will be removed in a future release, assuming themes add support
- -- use_nvim_cmp_as_default = true,
- -- },
- -- keymap = {
- --
- -- }
- -- -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
- -- -- adjusts spacing to ensure icons are aligned
- -- nerd_font_variant = "normal",
- --
- -- -- experimental auto-brackets support
- -- accept = { auto_brackets = { enabled = true } },
- --
- -- -- experimental signature help support
- -- trigger = { signature_help = { enabled = true } }
- -- },
- -- },
- -- { "hrsh7th/cmp-nvim-lsp", lazy = false },
- -- }
- return {
- { "hrsh7th/cmp-nvim-lsp" },
- {
- "L3MON4D3/LuaSnip",
- -- follow latest release.
- version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
- -- install jsregexp (optional!).
- build = "make install_jsregexp",
- dependencies = { "saadparwaiz1/cmp_luasnip", "rafamadriz/friendly-snippets" },
- },
- {
- "hrsh7th/nvim-cmp",
- dependencies = {
- "hrsh7th/cmp-buffer",
- "f3fora/cmp-spell",
- "hrsh7th/cmp-path",
- "hrsh7th/cmp-emoji",
- "R-nvim/cmp-r",
- "hrsh7th/cmp-nvim-lsp-signature-help",
- "onsails/lspkind.nvim",
- },
- config = function()
- local cmp = require("cmp")
- local luasnip = require("luasnip")
- local lspkind = require("lspkind")
- -- gray
- vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { bg = "NONE", strikethrough = true, fg = "#808080" })
- -- blue
- vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { bg = "NONE", fg = "#569CD6" })
- vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { link = "CmpIntemAbbrMatch" })
- -- light blue
- vim.api.nvim_set_hl(0, "CmpItemKindVariable", { bg = "NONE", fg = "#9CDCFE" })
- vim.api.nvim_set_hl(0, "CmpItemKindInterface", { link = "CmpItemKindVariable" })
- vim.api.nvim_set_hl(0, "CmpItemKindText", { link = "CmpItemKindVariable" })
- -- pink
- vim.api.nvim_set_hl(0, "CmpItemKindFunction", { bg = "NONE", fg = "#C586C0" })
- vim.api.nvim_set_hl(0, "CmpItemKindMethod", { link = "CmpItemKindFunction" })
- -- front
- vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { bg = "NONE", fg = "#D4D4D4" })
- vim.api.nvim_set_hl(0, "CmpItemKindProperty", { link = "CmpItemKindKeyword" })
- vim.api.nvim_set_hl(0, "CmpItemKindUnit", { link = "CmpItemKindKeyword" })
- require("luasnip.loaders.from_vscode").lazy_load()
- cmp.setup({
- snippet = {
- -- REQUIRED - you must specify a snippet engine
- expand = function(args)
- -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
- require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
- -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
- -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
- -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
- end,
- },
- view = {
- entries = "custom", -- can be "custom", "wildmenu" or "native"
- },
- window = {
- documentation = {
- -- max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)),
- -- max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))),
- border = { "", "", "", " ", "", "", "", " " },
- winhighlight = "Normal:Pmenu",
- winblend = vim.o.pumblend,
- },
- -- completion = cmp.config.window.bordered(),
- -- documentation = cmp.config.window.bordered(),
- },
- formatting = {
- format = lspkind.cmp_format(),
- },
- mapping = cmp.mapping.preset.insert({
- ["<C-b>"] = cmp.mapping.scroll_docs(-4),
- ["<C-f>"] = cmp.mapping.scroll_docs(4),
- ["<C-Space>"] = cmp.mapping.complete(),
- ["<C-e>"] = cmp.mapping.abort(),
- ["<CR>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- if luasnip.expandable() then
- luasnip.expand()
- else
- cmp.confirm({
- select = true,
- })
- end
- else
- fallback()
- end
- end),
- ["<Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_next_item()
- elseif luasnip.locally_jumpable(1) then
- luasnip.jump(1)
- else
- fallback()
- end
- end, { "i", "s" }),
- ["<S-Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_prev_item()
- elseif luasnip.locally_jumpable(-1) then
- luasnip.jump(-1)
- else
- fallback()
- end
- end, { "i", "s" }),
- }),
- sources = cmp.config.sources({
- { name = "nvim_lsp" },
- { name = "buffer" },
- { name = "luasnip" }, -- For luasnip users.
- { name = "emoji" },
- { name = "crates" }, -- cf rust
- { name = "cmp_r" },
- { name = "nvim_lsp_signature_help" },
- {
- name = "spell",
- option = {
- keep_all_entries = false,
- enable_in_context = function()
- return true
- end,
- preselect_correct_word = true,
- },
- },
- {
- name = "path",
- option = {
- -- Options go into this table
- },
- },
- -- { name = 'ultisnips' }, -- For ultisnips users.
- -- { name = 'snippy' }, -- For snippy users.
- }, {
- { name = "buffer" },
- }),
- })
- --
- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
- cmp.setup.cmdline({ "/", "?" }, {
- mapping = cmp.mapping.preset.cmdline(),
- sources = {
- { name = "buffer" },
- },
- })
- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
- -- cmp.setup.cmdline(":", {
- -- mapping = cmp.mapping.preset.cmdline(),
- -- sources = cmp.config.sources({
- -- { name = "path" },
- -- }, {
- -- { name = "cmdline" },
- -- }),
- -- matching = { disallow_symbol_nonprefix_matching = false },
- -- })
- end,
- },
- }
|