add multiple cmp themes https://github.com/NvChad/base46/issues/109
This commit is contained in:
parent
8f92334c57
commit
4f789d3406
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", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "PackerComplete",
|
pattern = "PackerComplete",
|
||||||
callback = function()
|
callback = function()
|
||||||
require("base46").compile()
|
|
||||||
require("base46").load_all_highlights()
|
require("base46").load_all_highlights()
|
||||||
|
|
||||||
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
|
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
|
||||||
|
|
|
@ -10,14 +10,27 @@ M.options = {
|
||||||
}
|
}
|
||||||
|
|
||||||
M.ui = {
|
M.ui = {
|
||||||
|
------------------------------- base46 -------------------------------------
|
||||||
-- hl = highlights
|
-- hl = highlights
|
||||||
hl_add = {},
|
hl_add = {},
|
||||||
hl_override = {},
|
hl_override = {},
|
||||||
|
|
||||||
changed_themes = {},
|
changed_themes = {},
|
||||||
theme_toggle = { "onedark", "one_light" },
|
theme_toggle = { "onedark", "one_light" },
|
||||||
theme = "onedark", -- default theme
|
theme = "onedark", -- default theme
|
||||||
|
|
||||||
transparency = false,
|
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 = {
|
statusline = {
|
||||||
separator_style = "default", -- default/round/block/arrow
|
separator_style = "default", -- default/round/block/arrow
|
||||||
overriden_modules = nil,
|
overriden_modules = nil,
|
||||||
|
@ -58,7 +71,7 @@ M.ui = {
|
||||||
|
|
||||||
M.plugins = {}
|
M.plugins = {}
|
||||||
|
|
||||||
-- check core.mappings for table structure
|
-- these are default mappings, check core.mappings for table structure
|
||||||
M.mappings = require "core.mappings"
|
M.mappings = require "core.mappings"
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -29,5 +29,5 @@ autocmd("VimEnter", {
|
||||||
local new_cmd = vim.api.nvim_create_user_command
|
local new_cmd = vim.api.nvim_create_user_command
|
||||||
|
|
||||||
new_cmd("CompileNvTheme", function()
|
new_cmd("CompileNvTheme", function()
|
||||||
require("base46").compile()
|
require("base46").load_all_highlights()
|
||||||
end, {})
|
end, {})
|
||||||
|
|
|
@ -8,6 +8,35 @@ loadfile(vim.g.base46_cache .. "cmp")()
|
||||||
|
|
||||||
vim.o.completeopt = "menu,menuone,noselect"
|
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)
|
local function border(hl_name)
|
||||||
return {
|
return {
|
||||||
{ "╭", hl_name },
|
{ "╭", hl_name },
|
||||||
|
@ -33,11 +62,12 @@ end
|
||||||
local options = {
|
local options = {
|
||||||
window = {
|
window = {
|
||||||
completion = {
|
completion = {
|
||||||
border = border "CmpBorder",
|
side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0,
|
||||||
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel",
|
||||||
},
|
},
|
||||||
documentation = {
|
documentation = {
|
||||||
border = border "CmpDocBorder",
|
border = border "CmpDocBorder",
|
||||||
|
winhighlight = "Normal:CmpDoc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
|
@ -45,13 +75,9 @@ local options = {
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
formatting = {
|
|
||||||
format = function(_, vim_item)
|
formatting = formatting_style,
|
||||||
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,
|
|
||||||
},
|
|
||||||
mapping = {
|
mapping = {
|
||||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
["<C-n>"] = cmp.mapping.select_next_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
|
-- check for any override
|
||||||
options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")
|
options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue