hrsh7th / cmp-nvim-lsp

nvim-cmp source for neovim builtin LSP client
MIT License
1.31k stars 52 forks source link

Disable JSX snippets #71

Closed NikitaRevenco closed 5 months ago

NikitaRevenco commented 5 months ago

Is it possible to disable this feature where it suggests the <tag></tag> whenever I enter "tag" or any other word?

image

image

Config:

{
        -- !cmp
        "hrsh7th/nvim-cmp",
        event = "InsertEnter",
        dependencies = {
            "hrsh7th/cmp-buffer", -- source for text in buffer
            "hrsh7th/cmp-path", -- source for file system paths
            {
                "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",
                opts = { updateevents = "TextChanged,TextChangedI" },
                keys = {},
            },
            "saadparwaiz1/cmp_luasnip", -- for autocompletion
            "rafamadriz/friendly-snippets", -- useful snippets
            "onsails/lspkind.nvim", -- vs-code like pictograms
            { "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
        },
        config = function()
            local cmp = require("cmp")

            -- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
            require("luasnip.loaders.from_vscode").lazy_load()

            cmp.setup({
                performance = {
                    max_view_entries = 3,
                },
                completion = {
                    completeopt = "menu,menuone,preview,noselect",
                },
                -- snippet = { -- configure how nvim-cmp interacts with snippet engine
                --  expand = function(args)
                --      require("luasnip").lsp_expand(args.body)
                --  end,
                -- },

                mapping = cmp.mapping.preset.insert({
                    -- ["<C-b>"] = cmp.mapping.scroll_docs(-4),
                    -- ["<C-f>"] = cmp.mapping.scroll_docs(4),
                    [keymaps.cmp_abort] = cmp.mapping.abort(),
                    [keymaps.cmp_confirm] = cmp.mapping.confirm({ select = true }),
                }),

                -- sources for autocompletion
                sources = cmp.config.sources({
                    { name = "nvim_lsp" }, -- language-specific completion
                    { name = "luasnip" }, -- snippets
                    { name = "buffer" }, -- text within current buffer
                    { name = "path" }, -- file system paths
                }),

                -- configure lspkind for vs-code like pictograms in completion menu
                formatting = {
                    format = function(entry, item)
                        -- Apply the original lspkind formatting
                        item = require("lspkind").cmp_format({
                            maxwidth = 50, -- specifies the maximum width of the text part
                            ellipsis_char = "...", -- specifies the characters added when the text part is truncated
                        })(entry, item)

                        -- Then apply the Tailwind CSS colorizer formatting
                        return require("tailwindcss-colorizer-cmp").formatter(entry, item)
                    end,
                },
            })
        end,
    }
NikitaRevenco commented 5 months ago

Update, fixed this

image

Here are the changes I need to make:

                    {
                        name = "nvim_lsp",
                    },

Replaced to:

                    {
                        name = "nvim_lsp",
                        entry_filter = function(entry, ctx)
                            return require("cmp").lsp.CompletionItemKind.Snippet ~= entry:get_kind()
                        end,
                    },