From 93bee8f078858629fd0dbeb4a55266cdecd2fc95 Mon Sep 17 00:00:00 2001 From: lucy Date: Fri, 20 Mar 2026 11:34:59 +0100 Subject: [PATCH] fix tinty setup command so that root also gets the set theme --- init.lua | 24 ++------------ lazy-lock.json | 9 +++--- lua/plugins/tinted.lua | 1 + lua/plugins/ui.lua | 73 +++++++++++++++++++++++++++++++----------- 4 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 lua/plugins/tinted.lua diff --git a/init.lua b/init.lua index 7540750..88fb1b8 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,10 @@ + local opt = vim.opt vim.g.mapleader = " " vim.g.maplocalleader = "\\" opt.number = true opt.relativenumber = true + opt.cursorline = true opt.termguicolors = true opt.winborder = "single" @@ -21,25 +23,3 @@ vim.diagnostic.config({ require("config.options") require("config.lazy") require("config.keymaps") -local theme_script_path = vim.fn.expand("~/.local/share/tinted-theming/tinty/base16-vim-colors-file.vim") - -local function file_exists(file_path) - return vim.fn.filereadable(file_path) == 1 and true or false -end - -local function handle_focus_gained() - if file_exists(theme_script_path) then - vim.cmd("source " .. theme_script_path) - end -end - -if file_exists(theme_script_path) then - vim.o.termguicolors = true - vim.g.tinted_colorspace = 256 - - vim.cmd("source " .. theme_script_path) - - vim.api.nvim_create_autocmd("FocusGained", { - callback = handle_focus_gained, - }) -end diff --git a/lazy-lock.json b/lazy-lock.json index 6143de1..33ba9c8 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,4 +1,5 @@ { + "base16-nvim": { "branch": "master", "commit": "190397833e53fdfd5cf400c5baaf1a4e533158e5" }, "blink.cmp": { "branch": "main", "commit": "451168851e8e2466bc97ee3e026c3dcb9141ce07" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" }, @@ -7,11 +8,11 @@ "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lspsaga.nvim": { "branch": "main", "commit": "562d9724e3869ffd1801c572dd149cc9f8d0cc36" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "a676ab7282da8d651e175118bcf54483ca11e46d" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a979821a975897b88493843301950c456a725982" }, "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "nvim-lspconfig": { "branch": "master", "commit": "d36ace0851744c7ec20213d1c8ff229806a98234" }, - "nvim-tree.lua": { "branch": "master", "commit": "a0db8bf7d6488b1dcd9cb5b0dfd6684a1e14f769" }, - "nvim-treesitter": { "branch": "main", "commit": "2b50ab5ccbcd9e5708deb351308edd738adbf84c" }, + "nvim-lspconfig": { "branch": "master", "commit": "841c6d4139aedb8a3f2baf30cef5327371385b93" }, + "nvim-tree.lua": { "branch": "master", "commit": "e16cd38962bc40c22a51ee004aa4f43726d74a16" }, + "nvim-treesitter": { "branch": "main", "commit": "53f6ce29df5841ce26e5a9f06fb371088b8d8031" }, "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, "snacks.nvim": { "branch": "main", "commit": "a049339328e2599ad6e85a69fa034ac501e921b2" } } diff --git a/lua/plugins/tinted.lua b/lua/plugins/tinted.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins/tinted.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index c106fb0..2ad001f 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -1,4 +1,37 @@ +local default_theme = "base16-oceanicnext" + +local function get_tinty_theme() + local theme_name = vim.fn.system("tinty -d /home/lucy/.local/share/tinted-theming/tinty/ current &> /dev/null && tinty -d /home/lucy/.local/share/tinted-theming/tinty/ current") + + if vim.v.shell_error ~= 0 then + return default_theme + else + return vim.trim(theme_name) + end +end + +local function handle_focus_gained() + local new_theme_name = get_tinty_theme() + local current_theme_name = vim.g.colors_name + + if current_theme_name ~= new_theme_name then + vim.cmd("colorscheme " .. new_theme_name) + end +end + +local function main() + vim.o.termguicolors = true + vim.g.tinted_colorspace = 256 + local current_theme_name = get_tinty_theme() + + vim.cmd("colorscheme " .. current_theme_name) + + vim.api.nvim_create_autocmd("FocusGained", { + callback = handle_focus_gained, + }) +end return { + { "nvim-tree/nvim-tree.lua", version = "*", @@ -9,26 +42,30 @@ return { opts = {}, }, { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("lualine").setup({ - theme = "base16", - options = { - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "diagnostics" }, - lualine_c = { "filename", "branch", "navic" }, - lualine_x = { "lsp_status", "filetype" }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - }) + "RRethy/base16-nvim", + lazy = false, + init = function() + main() end, }, + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", "RRethy/base16-nvim" }, + opts = { + options = { + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "diagnostics" }, + lualine_c = { "filename", "branch", "navic" }, + lualine_x = { "lsp_status", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + }, + }, { "nvimdev/lspsaga.nvim",