Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMP Styling issues when setting background to transparent #76

Closed
oiiiiiiii opened this issue Aug 19, 2024 · 8 comments
Closed

CMP Styling issues when setting background to transparent #76

oiiiiiiii opened this issue Aug 19, 2024 · 8 comments

Comments

@oiiiiiiii
Copy link

When I set transparent = true in the setup, the styling for cmp breaks (see screenshot).
image
The background is only set transparent for the content, the border still uses the nord colors.

@gbprod
Copy link
Owner

gbprod commented Sep 2, 2024

Interesting, can you share your nvim-cmp settings ?

@oiiiiiiii
Copy link
Author

oiiiiiiii commented Sep 10, 2024

Sorry for the late reply. I included it via lsp-zero. Here is my entire lsp-zero setup (using lazy) minus the keybindings, just in case this makes any difference that I included it via lsp-zero (which I believe it should not).

return {
    'VonHeikemen/lsp-zero.nvim', branch = 'v4.x',
    dependencies = {
        {'williamboman/mason.nvim'},
        {'williamboman/mason-lspconfig.nvim'},
        {'neovim/nvim-lspconfig'},
        {'L3MON4D3/LuaSnip'},
        {'hrsh7th/nvim-cmp'},
        {'hrsh7th/cmp-nvim-lsp'},
        {'hrsh7th/cmp-buffer'},
        {'hrsh7th/cmp-path'},
        {'saadparwaiz1/cmp_luasnip'},
        {'rafamadriz/friendly-snippets'},
    },
    config = function()
        local lsp_zero = require('lsp-zero')

        local lsp_attach = function(client, bufnr)
            local opts = {buffer = bufnr}
            -- some keybindings
        end

        lsp_zero.extend_lspconfig({
            sign_text = true,
            lsp_attach = lsp_attach,
            float_border = 'rounded',
            capabilities = require('cmp_nvim_lsp').default_capabilities()
        })

        require('mason').setup({})
        require('mason-lspconfig').setup({
            ensure_installed = { "rust_analyzer", "lua_ls", "gopls"},
            handlers = {
                function(server_name)
                    require('lspconfig')[server_name].setup({})
                end,
            }
        })

        local cmp = require('cmp')
        local cmp_action = lsp_zero.cmp_action()

        -- this is the function that loads the extra snippets
        -- from rafamadriz/friendly-snippets
        require('luasnip.loaders.from_vscode').lazy_load()

        cmp.setup({
            sources = {
                {name = 'path'},
                {name = 'nvim_lsp'},
                {name = 'luasnip', keyword_length = 2},
                {name = 'buffer', keyword_length = 3},
            },
            window = {
                completion = cmp.config.window.bordered(),
                documentation = cmp.config.window.bordered(),
            },
            snippet = {
                expand = function(args)
                    vim.snippet.expand(args.body)
                end,
            },
            mapping = cmp.mapping.preset.insert({
                -- keybindings
            }),
            -- note: if you are going to use lsp-kind (another plugin)
            -- replace the line below with the function from lsp-kind
            formatting = lsp_zero.cmp_format({details = true}),
        })
    end
}

But does it work with your setup when you set the background to transparent? If so, I will try to set it up myself and see if it works then. I just thought maybe this is a general issue.

@gbprod
Copy link
Owner

gbprod commented Sep 27, 2024

Can you try using this:

        window = {
          documentation = cmp.config.window.bordered({
            winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
          }),
         completion = cmp.config.window.bordered({
            winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
          }),
    }

@oiiiiiiii
Copy link
Author

Still the same, unfortunately :/

@gbprod
Copy link
Owner

gbprod commented Oct 4, 2024

Can you give me the result of :hi FloatBorder and :hi NormalBorder ?

@oiiiiiiii
Copy link
Author

Sorry for the late reply:

:hi FloatBorder
FloatBorder    xxx guifg=#4c566a guibg=#2e3440

:hi NormalBorder throws an error though (E411: Highlight group not found: NormalBorder)

@gbprod
Copy link
Owner

gbprod commented Oct 10, 2024

Hi!

First, can you tell me what are you using for terminal emulator ?

Then, can you try those settings for nord :

  {
    "gbprod/nord.nvim",
    lazy = false,
    priority = 1000,
    config = function()
      require("nord").setup({
        transparent = true,
        on_highlights = function(highlights, colors)
          highlights["FloatBorder"] = { fg = colors.polar_night.brightest, bg = colors.none }
        end,
      })
      vim.cmd.colorscheme("nord")
    end,
  }

@oiiiiiiii
Copy link
Author

I am using kitty. Setting highlights["FloatBorder"] = { fg = colors.polar_night.brightest, bg = colors.none } did the trick though, thanks a lot! :)

@gbprod gbprod closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants