From e100b9cf57fe20179c6b3c31f881d7fbd675b5ff Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 9 Jan 2025 17:10:29 +0100 Subject: [PATCH] Switch from catppuccin to a custom version of ayu mirage in neovim --- home/.config/bat/config | 2 +- home/.config/nvim/lua/plugs/ayu.lua | 108 +++++++++++++++++++++ home/.config/nvim/lua/plugs/catppuccin.lua | 57 ----------- home/.config/nvim/lua/plugs/leap.lua | 5 +- home/.config/nvim/lua/plugs/lspsaga.lua | 2 +- home/.config/nvim/lua/plugs/lualine.lua | 5 +- 6 files changed, 114 insertions(+), 65 deletions(-) create mode 100644 home/.config/nvim/lua/plugs/ayu.lua delete mode 100644 home/.config/nvim/lua/plugs/catppuccin.lua diff --git a/home/.config/bat/config b/home/.config/bat/config index 768b0ce..f8567dd 100644 --- a/home/.config/bat/config +++ b/home/.config/bat/config @@ -1 +1 @@ ---theme="Catppuccin Macchiato" +--theme="ayu_mirage" diff --git a/home/.config/nvim/lua/plugs/ayu.lua b/home/.config/nvim/lua/plugs/ayu.lua new file mode 100644 index 0000000..ceb9b65 --- /dev/null +++ b/home/.config/nvim/lua/plugs/ayu.lua @@ -0,0 +1,108 @@ +local function force_color_from_reference_on_others(others, reference) + local reference_hl = vim.api.nvim_get_hl(0, { name = reference }) + for _, member in ipairs(others) do + local property = vim.api.nvim_get_hl(0, { name = member }) + property.fg = reference_hl.fg + vim.api.nvim_set_hl(0, member, property) + end +end + +local function reset_hl_groups_for_ft(groups_to_reset) + for _, group in ipairs(groups_to_reset) do + local ft = group[1] + local groups = group[2] + + vim.api.nvim_create_autocmd("FileType", { + pattern = ft, + callback = function() + for _, group_name in ipairs(groups) do + vim.api.nvim_set_hl(0, group_name, {}) + end + end, + }) + end +end + +return { + "Shatur/neovim-ayu", + config = function() + local is_mirage = true + + local ayu = require("ayu") + local colors = require("ayu.colors") + colors.generate(is_mirage) + + local overrides = { + global_variable = { + underline = true, + italic = true, + }, + member_variable = { + bold = true, + }, + namespace = { + italic = true, + fg = colors.markup, + }, + pre_process = { + fg = colors.keyword, + }, + default_type = { + fg = colors.regexp + }, + } + + ayu.setup({ + mirage = is_mirage, -- Set to `true` to use `mirage` variant instead of `dark` for dark background. + terminal = false, -- Set to `false` to let terminal manage its own colors. + overrides = { + ["@property"] = overrides.member_variable, + ["PreProc"] = overrides.pre_process, + --CPP + ["@lsp.typemod.variable.fileScope.cpp"] = overrides.global_variable, + ["@lsp.type.namespace.cpp"] = overrides.namespace, + ["@type.builtin.cpp"] = overrides.default_type, + -- CPP + -- + -- Rust + ["@lsp.type.namespace.rust"] = overrides.namespace, + ["@lsp.type.builtinType.rust"] = overrides.default_type, + -- Rust + -- + -- C + ["@lsp.typemod.variable.globalScope.c"] = overrides.global_variable, + ["@type.builtin.c"] = overrides.default_type, + -- C + -- + -- Go + -- ["@module.go"] = overrides.namespace, -- The go LSP is not reliable enough for this sadly, sometimes it adds module tokens and sometimes it doesnt. + ["@variable.member.go"] = overrides.member_variable, + ["@type.builtin.go"] = overrides.default_type, + -- Go + -- + -- Zig + ["@module.zig"] = overrides.namespace, + ["@type.builtin.zig"] = overrides.default_type, + ["@function.builtin.zig"] = overrides.default_type, + -- ["@variable.member.zig"] = overrides.member_variable,-- Cant have bold member variable in zig, they don't differentiate function calls/accessors from variables, they are all just "members" .... BS LSP + -- ["@variable.parameter"] = {},-- Zig LSP is lacking, a parameter is marked as a regular variable outside of it's definition, can't separate between them. + -- Zig + }, + }) + + ayu.colorscheme() + + -- Fix nuances of the colorscheme in different languages. + -- These changes needs to run after the colorscheme is set. + force_color_from_reference_on_others({ + "@property", + "@variable.member.go", + "@variable.member", + "@variable.member.zig", + }, "@variable") + + reset_hl_groups_for_ft({ + { "go", { "@property", } }, + }) + end +} diff --git a/home/.config/nvim/lua/plugs/catppuccin.lua b/home/.config/nvim/lua/plugs/catppuccin.lua deleted file mode 100644 index 9ad9c32..0000000 --- a/home/.config/nvim/lua/plugs/catppuccin.lua +++ /dev/null @@ -1,57 +0,0 @@ -return { - "catppuccin/nvim", - name = "catppuccin", - priority = 1000, - config = function() - require("catppuccin").setup({ - flavour = "macchiato", - background = { - light = "latte", - dark = "macchiato" - }, - transparent_background = true, - term_colors = true, - sidebars = { "qf", "help" }, - integrations = { - lsp_saga = true, - lsp_trouble = true, - mason = true, - semantic_tokens = true, - treesitter_context = true, - telescope = { -- This doesn't seem to be compatible when running the custom dropdown theme - enable = true - }, - cmp = true, - dap_ui = true, - dap = true, - notify = true, - }, - dim_inactive = { - enabled = false, - shade = "dark", - percent = 0.15, - }, - styles = { - comments = { "italic" }, - }, - custom_highlights = function(colors) - return { - FloatBorder = { fg = colors.surface0 }, - CmpItemMenu = { fg = colors.overlay2 }, - CopilotSuggestion = { fg = colors.overlay2 }, - - -- Saga - ActionPreviewTitle = { bg = colors.mantle }, - - -- Leap - LeapLabelPrimary = { bg = colors.green, fg = colors.base }, - LeapBackdrop = { link = "Comment" }, - - ["@lsp.typemod.variable.functionScope.cpp"] = { bold = true }, - } - end - }) - - vim.cmd.colorscheme "catppuccin" - end -} diff --git a/home/.config/nvim/lua/plugs/leap.lua b/home/.config/nvim/lua/plugs/leap.lua index 29f6400..689a72f 100644 --- a/home/.config/nvim/lua/plugs/leap.lua +++ b/home/.config/nvim/lua/plugs/leap.lua @@ -1,10 +1,11 @@ local saved_hlsearch = false local saved_highlights = {} -local colors = require("catppuccin.palettes.macchiato"); +local colors = require("ayu.colors") +colors.generate(true) local function save_and_set_invisible_inlay_hints_hl() saved_highlights = vim.api.nvim_get_hl_by_name("LspInlayHint", true) - vim.api.nvim_set_hl(0, "LspInlayHint", { fg = colors.crust, bg = colors.crust }) + vim.api.nvim_set_hl(0, "LspInlayHint", { fg = colors.bg, bg = colors.bg }) end local function restore_inlay_hints_hl() diff --git a/home/.config/nvim/lua/plugs/lspsaga.lua b/home/.config/nvim/lua/plugs/lspsaga.lua index 96567a0..419e8b0 100644 --- a/home/.config/nvim/lua/plugs/lspsaga.lua +++ b/home/.config/nvim/lua/plugs/lspsaga.lua @@ -19,7 +19,7 @@ return { win_width = 52, }, ui = { - kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(), + -- kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(), border = "single", title = false }, diff --git a/home/.config/nvim/lua/plugs/lualine.lua b/home/.config/nvim/lua/plugs/lualine.lua index fa2e904..62df061 100644 --- a/home/.config/nvim/lua/plugs/lualine.lua +++ b/home/.config/nvim/lua/plugs/lualine.lua @@ -16,12 +16,9 @@ return { event = "VeryLazy", lazy = true, config = function() - local catppuccin_theme = require("lualine.themes.catppuccin") - local slightly_darker_surface0 = "#2c3045" - catppuccin_theme.normal.c.bg = slightly_darker_surface0 require("lualine").setup { options = { - theme = catppuccin_theme, + theme = "ayu", section_separators = { left = "", right = "",