add multiple cmp themes https://github.com/NvChad/base46/issues/109
This commit is contained in:
parent
8f92334c57
commit
4f789d3406
4 changed files with 54 additions and 12 deletions
1
init.lua
1
init.lua
|
@ -26,7 +26,6 @@ if fn.empty(fn.glob(install_path)) > 0 then
|
|||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "PackerComplete",
|
||||
callback = function()
|
||||
require("base46").compile()
|
||||
require("base46").load_all_highlights()
|
||||
|
||||
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
|
||||
|
|
|
@ -10,14 +10,27 @@ M.options = {
|
|||
}
|
||||
|
||||
M.ui = {
|
||||
------------------------------- base46 -------------------------------------
|
||||
-- hl = highlights
|
||||
hl_add = {},
|
||||
hl_override = {},
|
||||
|
||||
changed_themes = {},
|
||||
theme_toggle = { "onedark", "one_light" },
|
||||
theme = "onedark", -- default theme
|
||||
|
||||
transparency = false,
|
||||
|
||||
-- cmp themeing
|
||||
cmp = {
|
||||
icons = true,
|
||||
lspkind_text = true,
|
||||
style = "default", -- default/flat_light/flat_dark/atom/atom_colored
|
||||
border_color = "grey_fg", -- only applicable for "default" style, use color names from base30 variables
|
||||
selected_item_bg = "colored", -- colored / simple
|
||||
},
|
||||
|
||||
------------------------------- nvchad_ui modules -----------------------------
|
||||
statusline = {
|
||||
separator_style = "default", -- default/round/block/arrow
|
||||
overriden_modules = nil,
|
||||
|
@ -58,7 +71,7 @@ M.ui = {
|
|||
|
||||
M.plugins = {}
|
||||
|
||||
-- check core.mappings for table structure
|
||||
-- these are default mappings, check core.mappings for table structure
|
||||
M.mappings = require "core.mappings"
|
||||
|
||||
return M
|
||||
|
|
|
@ -29,5 +29,5 @@ autocmd("VimEnter", {
|
|||
local new_cmd = vim.api.nvim_create_user_command
|
||||
|
||||
new_cmd("CompileNvTheme", function()
|
||||
require("base46").compile()
|
||||
require("base46").load_all_highlights()
|
||||
end, {})
|
||||
|
|
|
@ -8,6 +8,35 @@ loadfile(vim.g.base46_cache .. "cmp")()
|
|||
|
||||
vim.o.completeopt = "menu,menuone,noselect"
|
||||
|
||||
local cmp_ui = require("core.utils").load_config().ui.cmp
|
||||
local cmp_style = cmp_ui.style
|
||||
|
||||
local field_arrangement = {
|
||||
atom = { "kind", "abbr", "menu" },
|
||||
atom_colored = { "kind", "abbr", "menu" },
|
||||
}
|
||||
|
||||
local formatting_style = {
|
||||
-- default fields order i.e completion word + item.kind + item.kind icons
|
||||
fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" },
|
||||
|
||||
format = function(_, item)
|
||||
local icons = require("nvchad_ui.icons").lspkind
|
||||
local icon = (cmp_ui.icons and icons[item.kind]) or ""
|
||||
|
||||
if cmp_style == "atom" or cmp_style == "atom_colored" then
|
||||
icon = " " .. icon .. " "
|
||||
item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or ""
|
||||
item.kind = icon
|
||||
else
|
||||
icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon
|
||||
item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "")
|
||||
end
|
||||
|
||||
return item
|
||||
end,
|
||||
}
|
||||
|
||||
local function border(hl_name)
|
||||
return {
|
||||
{ "╭", hl_name },
|
||||
|
@ -33,11 +62,12 @@ end
|
|||
local options = {
|
||||
window = {
|
||||
completion = {
|
||||
border = border "CmpBorder",
|
||||
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
||||
side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0,
|
||||
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel",
|
||||
},
|
||||
documentation = {
|
||||
border = border "CmpDocBorder",
|
||||
winhighlight = "Normal:CmpDoc",
|
||||
},
|
||||
},
|
||||
snippet = {
|
||||
|
@ -45,13 +75,9 @@ local options = {
|
|||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
formatting = {
|
||||
format = function(_, vim_item)
|
||||
local icons = require("nvchad_ui.icons").lspkind
|
||||
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
|
||||
formatting = formatting_style,
|
||||
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
|
@ -97,6 +123,10 @@ local options = {
|
|||
},
|
||||
}
|
||||
|
||||
if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then
|
||||
options.window.completion.border = border "CmpBorder"
|
||||
end
|
||||
|
||||
-- check for any override
|
||||
options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")
|
||||
|
||||
|
|
Loading…
Reference in a new issue