Merge branch 'main' of github.com:LarssonMartin1998/.dotfiles

This commit is contained in:
Martin Larsson 2025-07-24 09:20:15 +02:00
commit 3754b11751
14 changed files with 358 additions and 261 deletions

6
flake.lock generated
View file

@ -42,11 +42,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1753005798,
"narHash": "sha256-k96HUXcTSRlyCl59KIWCa6vKoC3C0WI9Fv1lr0MI95w=",
"lastModified": 1753265205,
"narHash": "sha256-/G6fub1lmVGMrARuZWiDc1ATVxteACx8wR4CNpc2yic=",
"owner": "LarssonMartin1998",
"repo": "colorsync",
"rev": "28751b339de4560acd31f3759d9e6ccd45a2e47e",
"rev": "8585a2e58ea23c6bb5e41f6c1dce177db58aa975",
"type": "github"
},
"original": {

View file

@ -21,6 +21,10 @@ let
"YouTube"
"https://www.youtube.com/"
]
[
"ChatGPT"
"https://www.chatgpt.com/"
]
];
extensions = with nur.repos.rycee.firefox-addons; [

View file

@ -1,16 +0,0 @@
local has_generated = false
local colors = require("ayu.colors")
colors.generate(true)
local M = {}
function M.get()
if not has_generated then
colors.generate(true)
has_generated = true
end
return colors
end
return M

View file

@ -1,18 +1,19 @@
local theme_colors = require("ayu.colors")
theme_colors.generate(true)
-- These are not apart of the Ayu color theme, however, I needed these
-- colors while still fitting in with the rest
local ayu_turquoise = "#5CCFE6"
local ayu_dark_blue = "#3A7BD5"
local utils = require("utils")
local colors = {
local function setup_colors()
-- These are not apart of the Ayu color theme, however, I needed these
-- colors while still fitting in with the rest
local ayu_turquoise = "#5CCFE6"
local ayu_dark_blue = "#3A7BD5"
local colors = {
info = ayu_dark_blue,
hint = ayu_turquoise,
warning = theme_colors.warning,
error = theme_colors.error,
}
warning = utils.ayu_colors.warning,
error = utils.ayu_colors.error,
}
for _, highlight in ipairs({
for _, highlight in ipairs({
{ "DiagnosticUnderlineInfo", { undercurl = true, sp = colors.info } },
{ "DiagnosticUnderlineHint", { undercurl = true, sp = colors.hint } },
{ "DiagnosticUnderlineWarn", { undercurl = true, sp = colors.warning } },
@ -21,10 +22,14 @@ for _, highlight in ipairs({
{ "DiagnosticHint", { fg = colors.hint } },
{ "DiagnosticWarn", { fg = colors.warning } },
{ "DiagnosticError", { fg = colors.error } },
}) do
}) do
vim.api.nvim_set_hl(0, highlight[1], highlight[2])
end
end
utils.create_user_event_cb("ColorsyncThemeChanged", setup_colors, "ColorsyncEvents")
setup_colors()
local sev = vim.diagnostic.severity
vim.diagnostic.config({
underline = true,

View file

@ -1,3 +1,6 @@
local uv = vim.loop
local utils = require("utils")
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
@ -25,10 +28,17 @@ end
return {
"Shatur/neovim-ayu",
priority = 1010,
config = function()
local function set_colorscheme()
utils.colorsync_theme = vim.fn.system({ "colorsync", "get" }):gsub("%s+", "")
vim.o.background = utils.colorsync_theme == "ayulight" and "light" or "dark"
local is_mirage = utils.colorsync_theme == "ayumirage"
local ayu = require("ayu")
local colors = require("ayu.colors")
colors.generate(true)
utils.ayu_colors = require("ayu.colors")
utils.ayu_colors.generate(is_mirage)
local overrides = {
global_variable = {
@ -40,21 +50,21 @@ return {
},
namespace = {
italic = true,
fg = colors.markup,
fg = utils.ayu_colors.markup,
},
pre_process = {
fg = colors.keyword,
fg = utils.ayu_colors.keyword,
},
default_type = {
fg = colors.regexp
fg = utils.ayu_colors.regexp
},
type = {
fg = colors.entity,
fg = utils.ayu_colors.entity,
},
}
ayu.setup({
mirage = true,
mirage = is_mirage,
terminal = false,
overrides = {
-- TRANSPARENCY
@ -104,6 +114,26 @@ return {
})
ayu.colorscheme()
end
vim.api.nvim_create_augroup("ColorsyncEvents", { clear = true })
local filepath = os.getenv("HOME") .. "/.local/state/colorsync/current"
local handle = uv.new_fs_event()
handle:start(filepath, {}, function(err)
if err then
vim.notify("Error watching: " .. filepath .. "\n" .. err)
return
end
vim.schedule(function()
set_colorscheme()
vim.api.nvim_exec_autocmds("User", { pattern = "ColorsyncThemeChanged" })
vim.api.nvim_exec_autocmds("ColorScheme", {})
end)
end)
set_colorscheme()
-- Fix nuances of the colorscheme in different languages.
-- These changes needs to run after the colorscheme is set.

View file

@ -1,3 +1,5 @@
local utils = require("utils")
return {
"b0o/incline.nvim",
dependencies = {
@ -10,9 +12,9 @@ return {
}
}
},
event = "VeryLazy",
lazy = true,
opts = {
config = function()
local function setup_incline()
require("incline").setup({
window = {
padding = 0,
},
@ -105,8 +107,8 @@ return {
end
return {
guibg = "#1e2030",
guifg = "#cad3f5",
guibg = utils.ayu_colors.panel_bg,
guifg = utils.ayu_colors.fg,
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
@ -116,5 +118,10 @@ return {
{ " " }
}
end,
},
})
end
utils.create_user_event_cb("ColorsyncThemeChanged", setup_incline, "ColorsyncEvents")
setup_incline()
end
}

View file

@ -1,3 +1,5 @@
local utils = require("utils")
local saved_hlsearch = false
local saved_highlights = {}
@ -23,7 +25,7 @@ end
local function save_and_set_invisible_inlay_hints_hl()
saved_highlights = vim.api.nvim_get_hl(0, { name = "LspInlayHint" })
vim.api.nvim_set_hl(0, "LspInlayHint", { fg = require("colors").get().bg, bg = "none" })
vim.api.nvim_set_hl(0, "LspInlayHint", { fg = utils.ayu_colors.bg, bg = "none" })
end
local function restore_inlay_hints_hl()

View file

@ -1,3 +1,5 @@
local utils = require("utils")
local function resize_mode()
if require("window_management").is_in_resizing_mode() then
return "▲ Resizing ▼ "
@ -26,7 +28,9 @@ return {
},
event = "VeryLazy",
lazy = true,
opts = {
config = function()
local function setup_lualine()
require("lualine").setup({
options = {
theme = "ayu",
globalstatus = true,
@ -66,5 +70,10 @@ return {
lualine_z = {}
},
tabline = {},
}
})
end
utils.create_user_event_cb("ColorsyncThemeChanged", setup_lualine, "ColorsyncEvents")
setup_lualine()
end
}

View file

@ -1,5 +1,8 @@
local M = {}
M.colorsync_theme = nil
M.ayu_colors = nil
function M.set_keymap_list(keymap_list, mode)
mode = mode or "n"
M.foreach(keymap_list, function(mapping)

View file

@ -1,7 +1,31 @@
format_for_tmux() {
fg="#1F2430"
bg="#73D0FF"
THEME=$(colorsync get)
default() {
bg="#95E6CB"
fg="#000000"
text_col="#BFBDB6"
}
case "$THEME" in
ayudark)
default
;;
ayumirage)
bg="#95E6CB"
fg="#101521"
text_col="#CCCAC2"
;;
ayulight)
bg="#4CBF99"
fg="#F3F4F5"
text_col="#5C6166"
;;
*)
default
;;
esac
format_for_tmux() {
echo $1 | gawk -v bg="$bg" -v fg="$fg" -v text_col="$text_col" '{printf("#[default]#[fg="bg"]#[default]#[bg="bg", fg="fg", bold]%s #[default]#[fg="bg"]#[default]#[fg="text_col"] %s", substr($0, 1, 1), substr($0, 2))}'
}

28
tmux/tmux-statusbar-color.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
THEME=$(colorsync get)
default() {
tmux set-option -g status-bg "#000000"
tmux setw -g window-status-format "#[bg=#000000,fg=#BFBDB6] #[bold]#I #[default] #[fg=#59C2FF]#W #[default]"
tmux setw -g window-status-current-format "#[bg=#95E6CB,fg=#000000] #[bold]#I #[default] #[fg=#FF8F40]#W #[default]"
}
case "$THEME" in
ayudark)
default
;;
ayumirage)
tmux set-option -g status-bg "#101521"
tmux setw -g window-status-format "#[bg=#101521,fg=#CCCAC2] #[bold]#I #[default] #[fg=#73D0FF]#W #[default]"
tmux setw -g window-status-current-format "#[bg=#95E6CB,fg=#101521] #[bold]#I #[default] #[fg=#FFCC66]#W #[default]"
;;
ayulight)
tmux set-option -g status-bg "#F0F0F0"
tmux setw -g window-status-format "#[bg=#F0F0F0,fg=#5C6166] #[bold]#I #[default] #[fg=#399EE6]#W #[default]"
tmux setw -g window-status-current-format "#[bg=#4CBF99,fg=#F0F0F0] #[bold]#I #[default] #[fg=#FA8D3E]#W #[default]"
;;
*)
default
;;
esac

View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
watchman watch-project "$HOME/.local/state/colorsync"
watchman -- trigger "$HOME/.local/state/colorsync" tmux_statusbar_color 'current' -- bash "$HOME/.config/tmux/tmux-statusbar-color.sh"

View file

@ -107,7 +107,7 @@ set -g history-limit 50000
set -g display-time 2500
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
set -g status-interval 2
set -g status-interval 5
# Focus events enabled for terminals that support them
set -g focus-events on
@ -121,13 +121,11 @@ setw -g automatic-rename off
set-hook -g after-new-window "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
set-hook -g pane-focus-in "run-shell '~/.config/tmux/tmux-rename-window.sh | xargs tmux rename-window'"
setw -g window-status-format "#[bg=#171B24,fg=#CCCAC2] #[bold]#I #[default] #[fg=#73D0FF]#W #[default]"
setw -g window-status-current-format "#[bg=#757B84,fg=#EFEDE7] #[bold]#I #[default] #[fg=#FFAD66]#W #[default]"
# Set the right status: Battery, date and time, session name
set -g status-right "#($HOME/.config/tmux/tmux-status-right.sh)"
run-shell '~/.config/tmux/tmux-statusbar-color.sh'
run-shell '~/.config/tmux/tmux-watchman-statuscolor.sh'
set -g status-bg "#171B24"
set -g status-style bold
# SSH agent forwarding

View file

@ -27,7 +27,6 @@ set_custom_keybindings() {
init() {
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f ~/.local/state/colorsync/current ] && source ~/.local/state/colorsync/current
[ -f ~/.zshrc_local ] && source ~/.zshrc_local
eval "$(fzf --zsh)"
eval "$(zoxide init --cmd cd zsh)"