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,30 +1,35 @@
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 = {
info = ayu_dark_blue,
hint = ayu_turquoise,
warning = theme_colors.warning,
error = theme_colors.error,
}
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"
for _, highlight in ipairs({
{ "DiagnosticUnderlineInfo", { undercurl = true, sp = colors.info } },
{ "DiagnosticUnderlineHint", { undercurl = true, sp = colors.hint } },
{ "DiagnosticUnderlineWarn", { undercurl = true, sp = colors.warning } },
{ "DiagnosticUnderlineError", { undercurl = true, sp = colors.error } },
{ "DiagnosticInfo", { fg = colors.info } },
{ "DiagnosticHint", { fg = colors.hint } },
{ "DiagnosticWarn", { fg = colors.warning } },
{ "DiagnosticError", { fg = colors.error } },
}) do
vim.api.nvim_set_hl(0, highlight[1], highlight[2])
local colors = {
info = ayu_dark_blue,
hint = ayu_turquoise,
warning = utils.ayu_colors.warning,
error = utils.ayu_colors.error,
}
for _, highlight in ipairs({
{ "DiagnosticUnderlineInfo", { undercurl = true, sp = colors.info } },
{ "DiagnosticUnderlineHint", { undercurl = true, sp = colors.hint } },
{ "DiagnosticUnderlineWarn", { undercurl = true, sp = colors.warning } },
{ "DiagnosticUnderlineError", { undercurl = true, sp = colors.error } },
{ "DiagnosticInfo", { fg = colors.info } },
{ "DiagnosticHint", { fg = colors.hint } },
{ "DiagnosticWarn", { fg = colors.warning } },
{ "DiagnosticError", { fg = colors.error } },
}) 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,85 +28,112 @@ end
return {
"Shatur/neovim-ayu",
priority = 1010,
config = function()
local ayu = require("ayu")
local colors = require("ayu.colors")
colors.generate(true)
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 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
},
type = {
fg = colors.entity,
},
}
local is_mirage = utils.colorsync_theme == "ayumirage"
ayu.setup({
mirage = true,
terminal = false,
overrides = {
-- TRANSPARENCY
-- Normal = { bg = "none" },
-- NormalFloat = { bg = "none" },
-- ColorColumn = { bg = "none" },
-- SignColumn = { bg = "none" },
-- Folded = { bg = "none" },
-- FoldColumn = { bg = "none" },
-- CursorColumn = { bg = "none" },
-- VertSplit = { bg = "none" },
-- TRANSPARENCY
CursorLineNr = { bg = "none" },
["@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.struct.rust"] = overrides.type,
["@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
},
})
local ayu = require("ayu")
utils.ayu_colors = require("ayu.colors")
utils.ayu_colors.generate(is_mirage)
ayu.colorscheme()
local overrides = {
global_variable = {
underline = true,
italic = true,
},
member_variable = {
bold = true,
},
namespace = {
italic = true,
fg = utils.ayu_colors.markup,
},
pre_process = {
fg = utils.ayu_colors.keyword,
},
default_type = {
fg = utils.ayu_colors.regexp
},
type = {
fg = utils.ayu_colors.entity,
},
}
ayu.setup({
mirage = is_mirage,
terminal = false,
overrides = {
-- TRANSPARENCY
-- Normal = { bg = "none" },
-- NormalFloat = { bg = "none" },
-- ColorColumn = { bg = "none" },
-- SignColumn = { bg = "none" },
-- Folded = { bg = "none" },
-- FoldColumn = { bg = "none" },
-- CursorColumn = { bg = "none" },
-- VertSplit = { bg = "none" },
-- TRANSPARENCY
CursorLineNr = { bg = "none" },
["@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.struct.rust"] = overrides.type,
["@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()
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,111 +12,116 @@ return {
}
}
},
event = "VeryLazy",
lazy = true,
opts = {
window = {
padding = 0,
},
hide = {
cursorline = false,
},
render = function(props)
local fullpath = vim.api.nvim_buf_get_name(props.buf)
local filename = vim.fn.fnamemodify(fullpath, ":t")
if filename == "" then
filename = "[No Name]"
end
local function get_ft_icon()
local ft_icon, ft_color = require("nvim-web-devicons").get_icon_color(filename)
return { (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" }
end
local function get_file_path()
local path_display = ""
if fullpath == "" then
path_display = filename
else
local parts = {}
for part in string.gmatch(vim.fn.fnamemodify(fullpath, ":.:h"), "[^/]+") do
table.insert(parts, part)
config = function()
local function setup_incline()
require("incline").setup({
window = {
padding = 0,
},
hide = {
cursorline = false,
},
render = function(props)
local fullpath = vim.api.nvim_buf_get_name(props.buf)
local filename = vim.fn.fnamemodify(fullpath, ":t")
if filename == "" then
filename = "[No Name]"
end
local ellipsis = ""
local max_path_parts = 2
if #parts > max_path_parts then
local start_index = #parts - max_path_parts + 1
path_display = ellipsis .. "/" .. table.concat(parts, "/", start_index)
elseif #parts > 0 then
path_display = table.concat(parts, "/")
local function get_ft_icon()
local ft_icon, ft_color = require("nvim-web-devicons").get_icon_color(filename)
return { (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" }
end
if path_display ~= "" then
path_display = path_display .. "/" .. filename
else
path_display = filename
local function get_file_path()
local path_display = ""
if fullpath == "" then
path_display = filename
else
local parts = {}
for part in string.gmatch(vim.fn.fnamemodify(fullpath, ":.:h"), "[^/]+") do
table.insert(parts, part)
end
local ellipsis = ""
local max_path_parts = 2
if #parts > max_path_parts then
local start_index = #parts - max_path_parts + 1
path_display = ellipsis .. "/" .. table.concat(parts, "/", start_index)
elseif #parts > 0 then
path_display = table.concat(parts, "/")
end
if path_display ~= "" then
path_display = path_display .. "/" .. filename
else
path_display = filename
end
end
return { path_display .. "", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" }
end
end
return { path_display .. "", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" }
end
local function get_git_diff()
local icons = { removed = "", changed = "", added = "" }
local signs = vim.b[props.buf].gitsigns_status_dict
local labels = {}
if signs == nil then
return labels
end
for name, icon in pairs(icons) do
if tonumber(signs[name]) and signs[name] > 0 then
table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
local function get_git_diff()
local icons = { removed = "", changed = "", added = "" }
local signs = vim.b[props.buf].gitsigns_status_dict
local labels = {}
if signs == nil then
return labels
end
for name, icon in pairs(icons) do
if tonumber(signs[name]) and signs[name] > 0 then
table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
end
end
if #labels > 0 then
table.insert(labels, { "" })
end
return labels
end
end
if #labels > 0 then
table.insert(labels, { "" })
end
return labels
end
local function get_diagnostic_label()
local icons = { error = "", warn = "", info = "", hint = "" }
local label = {}
local function get_diagnostic_label()
local icons = { error = "", warn = "", info = "", hint = "" }
local label = {}
for severity, icon in pairs(icons) do
local n = #vim.diagnostic.get(props.buf,
{ severity = vim.diagnostic.severity[string.upper(severity)] })
if n > 0 then
table.insert(label, { icon .. " " .. n .. " ", group = "DiagnosticSign" .. severity })
for severity, icon in pairs(icons) do
local n = #vim.diagnostic.get(props.buf,
{ severity = vim.diagnostic.severity[string.upper(severity)] })
if n > 0 then
table.insert(label, { icon .. " " .. n .. " ", group = "DiagnosticSign" .. severity })
end
end
if #label > 0 then
table.insert(label, { "" })
end
return label
end
end
if #label > 0 then
table.insert(label, { "" })
end
return label
end
local function get_arrow_label()
local statusline = require("arrow.statusline")
if statusline.is_on_arrow_file(props.buf) == nil then
return ""
end
local function get_arrow_label()
local statusline = require("arrow.statusline")
if statusline.is_on_arrow_file(props.buf) == nil then
return ""
end
return " " .. statusline.text_for_statusline_with_icons(props.buf)
end
return " " .. statusline.text_for_statusline_with_icons(props.buf)
end
return {
guibg = "#1e2030",
guifg = "#cad3f5",
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
{ get_ft_icon() },
{ get_file_path() },
{ get_arrow_label() .. "" .. vim.api.nvim_win_get_number(props.win), group = "DevIconWindows" },
{ " " }
}
end,
},
return {
guibg = utils.ayu_colors.panel_bg,
guifg = utils.ayu_colors.fg,
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
{ get_ft_icon() },
{ get_file_path() },
{ get_arrow_label() .. "" .. vim.api.nvim_win_get_number(props.win), group = "DevIconWindows" },
{ " " }
}
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,45 +28,52 @@ return {
},
event = "VeryLazy",
lazy = true,
opts = {
options = {
theme = "ayu",
globalstatus = true,
section_separators = {
left = "",
right = "",
},
component_separators = {
left = "",
right = ""
},
icons_enabled = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diagnostics",
sources = { "nvim_lsp" },
sections = { "error", "warn", "info", "hint" },
update_in_insert = false,
config = function()
local function setup_lualine()
require("lualine").setup({
options = {
theme = "ayu",
globalstatus = true,
section_separators = {
left = "",
right = "",
},
component_separators = {
left = "",
right = ""
},
icons_enabled = true,
},
resize_mode,
},
lualine_c = { tabs },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
tabline = {},
}
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diagnostics",
sources = { "nvim_lsp" },
sections = { "error", "warn", "info", "hint" },
update_in_insert = false,
},
resize_mode,
},
lualine_c = { tabs },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
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)"