From a68558e4aef6e3127e8c5738c0539e1d1a5d6fcf Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 1 Apr 2025 22:14:38 +0200 Subject: [PATCH 1/2] Add tmux theme toggle configuration --- tasks/dotfiles.yml | 14 +++++++++++++- templates/tmux-toggle.j2 | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 templates/tmux-toggle.j2 diff --git a/tasks/dotfiles.yml b/tasks/dotfiles.yml index 44445b2..1d097f9 100644 --- a/tasks/dotfiles.yml +++ b/tasks/dotfiles.yml @@ -38,9 +38,15 @@ - src: '{{ ansible_env.HOME }}/dotfiles/.profile' dest: '{{ ansible_env.HOME }}/.profile' - - src: '{{ ansible_env.HOME }}/dotfiles/.tmux.conf' + - src: '{{ ansible_env.HOME }}/dotfiles/tmux/tmux.conf' dest: '{{ xdg_config_dir }}/tmux/tmux.conf' + - src: '{{ ansible_env.HOME }}/dotfiles/tmux/light.conf' + dest: '{{ xdg_config_dir }}/tmux/light.conf' + + - src: '{{ ansible_env.HOME }}/dotfiles/tmux/dark.conf' + dest: '{{ xdg_config_dir }}/tmux/dark.conf' + - src: '{{ ansible_env.HOME }}/dotfiles/.gitignore' dest: '{{ xdg_config_dir }}/git/ignore' @@ -49,3 +55,9 @@ src: 'templates/gitconfig.j2' dest: '{{ xdg_config_dir }}/git/config' mode: '0755' + +- name: Copy tmux toggle script + ansible.builtin.template: + src: 'templates/tmux-toggle.j2' + dest: '{{ ansible_env.HOME }}/.local/bin/tmux-toggle.sh' + mode: '0755' diff --git a/templates/tmux-toggle.j2 b/templates/tmux-toggle.j2 new file mode 100644 index 0000000..3a2bda6 --- /dev/null +++ b/templates/tmux-toggle.j2 @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +# +# {{ ansible_managed }} +# +# Toggle the current window (all panes) between light and dark themes. + +set -e + +current_window_style=$(tmux show -Av window-style) + +case $current_window_style in + 'fg=#000000,bg=#eff0f1') + tmux source-file ~/.config/tmux/dark.conf + ;; + *) + # Change back to the default window style. + tmux source-file ~/.config/tmux/light.conf + ;; +esac From 87f05c5d832c8dfba4c881949e319f8ea5f72c17 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 1 Apr 2025 22:15:23 +0200 Subject: [PATCH 2/2] Split diagnostic configuration to separate file --- tasks/neovim.yml | 3 +++ templates/nvim/init.lua.j2 | 1 + templates/nvim/lua/diagnostic.lua.j2 | 11 +++++++++++ templates/nvim/lua/lsp.lua.j2 | 8 -------- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 templates/nvim/lua/diagnostic.lua.j2 diff --git a/tasks/neovim.yml b/tasks/neovim.yml index f6e0696..ef4b2e3 100644 --- a/tasks/neovim.yml +++ b/tasks/neovim.yml @@ -123,3 +123,6 @@ - src: 'templates/nvim/lua/formatting.lua.j2' dest: '{{ xdg_config_dir }}/nvim/lua/formatting.lua' + + - src: 'templates/nvim/lua/diagnostic.lua.j2' + dest: '{{ xdg_config_dir }}/nvim/lua/diagnostic.lua' diff --git a/templates/nvim/init.lua.j2 b/templates/nvim/init.lua.j2 index 309c912..d017527 100644 --- a/templates/nvim/init.lua.j2 +++ b/templates/nvim/init.lua.j2 @@ -12,3 +12,4 @@ require('_nvim-tree') require('lua-line') require('_source-link') require('formatting') +require('diagnostic') diff --git a/templates/nvim/lua/diagnostic.lua.j2 b/templates/nvim/lua/diagnostic.lua.j2 new file mode 100644 index 0000000..97baa9e --- /dev/null +++ b/templates/nvim/lua/diagnostic.lua.j2 @@ -0,0 +1,11 @@ +-- {{ ansible_managed }} + +vim.diagnostic.config { + float = { + suffix = function(diagnostic) + return (' %s | [%s]'):format(diagnostic.code, diagnostic.source) + end + }, + + virtual_text = { current_line = true } +} diff --git a/templates/nvim/lua/lsp.lua.j2 b/templates/nvim/lua/lsp.lua.j2 index b324de2..55da53c 100644 --- a/templates/nvim/lua/lsp.lua.j2 +++ b/templates/nvim/lua/lsp.lua.j2 @@ -186,11 +186,3 @@ cmp.setup { end, }, } - -vim.diagnostic.config { - float = { - suffix = function(diagnostic) - return (' %s | [%s]'):format(diagnostic.code, diagnostic.source) - end - }, -}