Skip to content
Closed
83 changes: 83 additions & 0 deletions colors/dms.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
local present, base46 = pcall(require, "base46")
if not present or not base46._DMS_SUPPORT then
vim.notify(
"base46 plugin not found or incorrect, make sure to install AvengeMedia/base46",
vim.log.levels.ERROR,
{ title = "dms integration" }
)
return
end

local config_home = vim.env.XDG_CONFIG_HOME
if config_home == nil or #config_home == 0 then
config_home = vim.fs.joinpath(vim.env.HOME, ".config")
end
local settings_file_path = vim.fs.joinpath(config_home, "DankMaterialShell", "settings.json")
local settings_file = io.open(settings_file_path, "r")
if settings_file == nil then
vim.notify(
"cannnot read dms settings file at '" .. settings_file_path .. "'",
vim.log.levels.ERROR,
{ title = "dms integration" }
)
return
end
local settings = vim.json.decode(settings_file:read("*a"))
settings_file:close()

local function deepGet(t, k)
for _, s in ipairs(k) do
if type(t) ~= "table" then
return
end
t = t[s]
end
return t
end

local current_file_path = debug.getinfo(1, "S").source:sub(2)
local theme_base = deepGet(settings, { "matugenTemplateNeovimSettings", vim.o.background, "baseTheme" })
or ("github_" .. vim.o.background)
local harmony = deepGet(settings, { "matugenTemplateNeovimSettings", vim.o.background, "harmony" }) or 0.5
local theme_name = "dms"

if not _G._matugen_theme_watcher then
local uv = vim.uv or vim.loop
_G._matugen_theme_watcher = { uv.new_fs_event(), uv.new_fs_event(), reload_timer = uv.new_timer() }

local debounce_time = 100 -- ms
local function handler()
_G._matugen_theme_watcher.reload_timer:stop()
_G._matugen_theme_watcher.reload_timer:start(
debounce_time,
0,
vim.schedule_wrap(function()
base46.theme_tables[theme_name] = nil
if vim.g.colors_name == theme_name then
vim.cmd.colorscheme(theme_name)
vim.notify("Theme reload", vim.log.levels.INFO, { title = "dms integration" })
end
-- NOTE: contrary to what the documentation says, uv fs events usually do not manage to react to more than one edit.
-- I understand that this is not intended: some edit processes in a typical system (e.g. the one neovim uses with
-- multiple renames and changes) make things hard to follow for libuv. Therefore, a restart is the best option.
_G._matugen_theme_watcher[1]:stop()
_G._matugen_theme_watcher[2]:stop()
_G._matugen_theme_watcher[1]:start(current_file_path, {}, handler)
_G._matugen_theme_watcher[2]:start(settings_file_path, {}, handler)
end)
)
end
_G._matugen_theme_watcher[1]:start(current_file_path, {}, handler)
_G._matugen_theme_watcher[2]:start(settings_file_path, {}, handler)
end

if not base46.theme_tables[theme_name] or base46.theme_tables[theme_name].type ~= vim.o.background then
local builtin = vim.deepcopy(assert(base46.get_builtin_theme(theme_base)))
local harmonized = base46.theme_harmonize(builtin, "#89b4fa", harmony)
harmonized = base46.theme_set_bg(harmonized, "#1e1e2e")

base46.theme_tables[theme_name] = harmonized
end

base46.load(theme_name)
vim.g.colors_name = theme_name
65 changes: 48 additions & 17 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true

-- [[ Setting options ]]
-- See `:help vim.o`
Expand All @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true
vim.o.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'
Expand Down Expand Up @@ -481,6 +481,7 @@ require('lazy').setup({
-- Mason must be loaded before its dependents so we need to set it up here.
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ 'mason-org/mason.nvim', opts = {} },
{ 'mason-org/mason-lspconfig.nvim', opts = {} },
'WhoIsSethDaniel/mason-tool-installer.nvim',

-- Useful status updates for LSP.
Expand Down Expand Up @@ -788,25 +789,55 @@ require('lazy').setup({
},
},

{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
--
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
{ -- Colorscheme
'catppuccin/nvim',
name = 'catppuccin',
priority = 1000,
config = function()
---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup {
styles = {
comments = { italic = false }, -- Disable italics in comments
require('catppuccin').setup {
flavour = 'mocha',
background = {
light = 'latte',
dark = 'mocha',
},
transparent_background = true,
show_end_of_buffer = false,
term_colors = true,
integrations = {
gitsigns = true,
mason = true,
mini = {
enabled = true,
indentscope_color = '',
},
native_lsp = {
enabled = true,
inlay_hints = {
background = true,
},
},
telescope = {
enabled = true,
},
treesitter = true,
which_key = true,
},
custom_highlights = function(colors)
return {
CursorLineNr = { fg = colors.lavender, bold = true },
FloatBorder = { bg = colors.mantle, fg = colors.surface2 },
LineNr = { fg = colors.overlay1 },
NormalFloat = { bg = colors.mantle },
Pmenu = { bg = colors.mantle, fg = colors.text },
PmenuSel = { bg = colors.surface0, fg = colors.text, bold = true },
StatusLine = { bg = colors.surface0, fg = colors.text },
StatusLineNC = { bg = colors.base, fg = colors.overlay1 },
Visual = { bg = colors.surface1 },
}
end,
}

-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night'
vim.cmd.colorscheme 'catppuccin'
end,
},

Expand Down
91 changes: 91 additions & 0 deletions lua/plugins/dankcolors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
return {
{
"RRethy/base16-nvim",
priority = 1000,
config = function()
require('base16-colorscheme').setup({
base00 = '#141218',
base01 = '#141218',
base02 = '#9d99a5',
base03 = '#9d99a5',
base04 = '#f4efff',
base05 = '#faf8ff',
base06 = '#faf8ff',
base07 = '#faf8ff',
base08 = '#ff9fb2',
base09 = '#ff9fb2',
base0A = '#d7c6ff',
base0B = '#a5ffb8',
base0C = '#e9e0ff',
base0D = '#d7c6ff',
base0E = '#ded0ff',
base0F = '#ded0ff',
})

vim.api.nvim_set_hl(0, 'Visual', {
bg = '#9d99a5',
fg = '#faf8ff',
bold = true
})
vim.api.nvim_set_hl(0, 'Statusline', {
bg = '#d7c6ff',
fg = '#141218',
})
vim.api.nvim_set_hl(0, 'LineNr', { fg = '#9d99a5' })
vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = '#e9e0ff', bold = true })

vim.api.nvim_set_hl(0, 'Statement', {
fg = '#ded0ff',
bold = true
})
vim.api.nvim_set_hl(0, 'Keyword', { link = 'Statement' })
vim.api.nvim_set_hl(0, 'Repeat', { link = 'Statement' })
vim.api.nvim_set_hl(0, 'Conditional', { link = 'Statement' })

vim.api.nvim_set_hl(0, 'Function', {
fg = '#d7c6ff',
bold = true
})
vim.api.nvim_set_hl(0, 'Macro', {
fg = '#d7c6ff',
italic = true
})
vim.api.nvim_set_hl(0, '@function.macro', { link = 'Macro' })

vim.api.nvim_set_hl(0, 'Type', {
fg = '#e9e0ff',
bold = true,
italic = true
})
vim.api.nvim_set_hl(0, 'Structure', { link = 'Type' })

vim.api.nvim_set_hl(0, 'String', {
fg = '#a5ffb8',
italic = true
})

vim.api.nvim_set_hl(0, 'Operator', { fg = '#f4efff' })
vim.api.nvim_set_hl(0, 'Delimiter', { fg = '#f4efff' })
vim.api.nvim_set_hl(0, '@punctuation.bracket', { link = 'Delimiter' })
vim.api.nvim_set_hl(0, '@punctuation.delimiter', { link = 'Delimiter' })

vim.api.nvim_set_hl(0, 'Comment', {
fg = '#9d99a5',
italic = true
})

local current_file_path = vim.fn.stdpath("config") .. "/lua/plugins/dankcolors.lua"
if not _G._matugen_theme_watcher then
local uv = vim.uv or vim.loop
_G._matugen_theme_watcher = uv.new_fs_event()
_G._matugen_theme_watcher:start(current_file_path, {}, vim.schedule_wrap(function()
local new_spec = dofile(current_file_path)
if new_spec and new_spec[1] and new_spec[1].config then
new_spec[1].config()
print("Theme reload")
end
end))
end
end
}
}
Loading