olimorris / onedarkpro.nvim

🎨 Atom's iconic One Dark theme. Cacheable, fully customisable, Tree-sitter and LSP semantic token support. Comes with variants
MIT License
773 stars 40 forks source link

nvim-cmp hlgroup. (and telescope title) #49

Closed Lalit64 closed 2 years ago

Lalit64 commented 2 years ago

Hey @olimorris, I can't seem to find the hlgroup for nvim-cmp selected item. I have tried PmenuSel but it doesn't seem to work. This also applies to telescope or any popup menu/float. I get this very light color. ↓

Screenshot 2022-06-05 at 16 05 39 Screenshot 2022-06-05 at 16 07 29

I also only noticed now that the Telescope title is very light. Any way to fix these ?

olimorris commented 2 years ago

Hmmmm. That is odd. Telescope should look like the pic in the Readme. Could you share your config and run :hi TelescopeResultsTitle and share the output.

Lalit64 commented 2 years ago

Config is at https://gitHub.com/lalit64/HydroVim ignore the readme it's under construction. I just need to push the latest changes. Can I talk to you and push the changes tomorrow I am the SAST time zone and it's pretty late for me now. I have school tomorrow so I have to go to bed.

olimorris commented 2 years ago

No problem. I'm on holiday at the moment on Pacific Time so will check later on for any updates

Lalit64 commented 2 years ago

No problem. I'm on holiday at the moment on Pacific Time so will check later on for any updates

I have pushed the changes. Check them out. Also my iTerm2 background color is #232832;

olimorris commented 2 years ago

Can't see anything obvious...

Can you run :hi TelescopeResultsTitle and let me know the output?

EDIT: Actually, I think it may be because you've overriden the bg colour. You may need to specify a custom TeleacopeResultsTitle and TelescopePromptTitle

Lalit64 commented 2 years ago
Screenshot 2022-06-07 at 08 08 20

How about the cmp. Output for :hi TelescopeResultsTitle is above

olimorris commented 2 years ago

Something is overriding onedarkpro's default telescope theme. If you view the Telescope plugin theme file here, you should see that it shouldn't link to any highlight group. I advise that you check your config and see what's causing it.

olimorris commented 2 years ago

Regarding cmp, it should be the Pmenu highlights that affect it. Have you tried PmenuSbar?

Lalit64 commented 2 years ago

@olimorris Should I be targeting the PmenuSbar bg or fg?

Edit: Neither of these work.

olimorris commented 2 years ago

Can you run the :hi command for all Pmenu groups and confirm if the hex codes match the colors when you use cmp?

The theme only applies icon highlights to cmp. You could try changing Pmenu fg and bg highlight groups to #FF0000 and seeing if that is visible in your setup. If not, something is probably overwriting them.

Edit: Now I have access to my Mac...

Assuming you've not changed the default cmp config, you can see it sets Pmenu and PmenuSel in the default config here.

Lalit64 commented 2 years ago

I do have a custom CMP config but that shouldn't change anything.

Take a look at it below.

local has_words_before = function()
    local line, col = unpack(vim.api.nvim_win_get_cursor(0))
    return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end

local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").load()
local cmp = require("cmp")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket"

local kind_icons = {
    Text = "",
    Method = "",
    Function = "οž”",
    Constructor = "ο₯",
    Field = "ο° ",
    Variable = "ο”ͺ",
    Class = "ο –",
    Interface = "",
    Module = "ο’‡",
    Property = "ο‚­",
    Unit = "",
    Value = "",
    Enum = "",
    Keyword = "",
    Snippet = "",
    Color = "ο£—",
    File = "",
    Reference = "",
    Folder = "",
    EnumMember = "",
    Constant = "ο£Ύ",
    Struct = "Χ€ΦΌ",
    Event = "",
    Operator = "οš”",
    TypeParameter = "οžƒ",
}

local mapping = {
    ["<C-d>"] = cmp.mapping.scroll_docs(-4),
    ["<C-f>"] = cmp.mapping.scroll_docs(4),
    ["<C-e>"] = cmp.mapping({
        i = cmp.mapping.abort(),
        c = cmp.mapping.close(),
    }),
    ["<CR>"] = cmp.mapping({
        i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
        c = function(fallback)
            if cmp.visible() then
                cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
            else
                fallback()
            end
        end,
    }),
    ["<Tab>"] = cmp.mapping(function(fallback)
        if cmp.visible() then
            cmp.select_next_item()
        elseif luasnip.expand_or_jumpable() then
            luasnip.expand_or_jump()
        elseif has_words_before() then
            cmp.complete()
        else
            fallback()
        end
    end, { "i", "s" }),
    ["<S-Tab>"] = 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" }),
    ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
    ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), { "i", "c" }),
    ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), { "i", "c" }),
}

cmp.setup({
    completion = { comp232832leteopt = "menu,menuone,noinsert" },
    snippet = {
        expand = function(args)
            luasnip.lsp_expand(args.body)
        end,
    },
    mapping = mapping,
    sources = {
        { name = "nvim_lsp" },
        { name = "buffer", keyword_length = 2 },
        { name = "luasnip" },
        { name = "path", max_item_count = 10 },
    },
    formatting = {
        format = function(entry, vim_item)
            -- Kind icons
            vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind)
            -- Source
            -- vim_item.menu = ({
            --     buffer = "[Buffer]",
            --     nvim_lsp = "[LSP]",
            --     luasnip = "[LuaSnip]",
            --     path = "[Path]",
            -- })[entry.source.name]
            return vim_item
        end,
    },
    window = {
        completion = cmp.config.window.bordered(),
        documentation = cmp.config.window.bordered()
    },
})

Edit: I re-wrote my config to make it neater and more readable but I still seems to have the same issues. I made sure to read every line and I can't seem to find the issue

Edit 2: It's still at the same repository. No README though.

olimorris commented 2 years ago

I can't really help you beyond this unfortunately. To close this out Is recommend the below approach:

Alternatively, create a minimal config of just onedarkpro and cmp and see if that solves it.

Lalit64 commented 2 years ago

I have made a minimal config and it seems to be working now. I'm not sure what the issue is in my config.

Edit: I have found the issue πŸ˜‘! It seems to be nvim-cmp when using

completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered()

Edit 2: Opened an issue in nvim-cmp repository.

dvalnn commented 6 months ago

I have made a minimal config and it seems to be working now. I'm not sure what the issue is in my config.

Edit: I have found the issue πŸ˜‘! It seems to be nvim-cmp when using

completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered()

Edit 2: Opened an issue in nvim-cmp repository.

Hi! I have run into the same problem when using those same window options. Has your issue been resolved yet upstream? Could you post a link to the solution/ongoing discussion?