From 4d516d6b9da0455d5a1ec93a61488aca0589d6a9 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Thu, 26 Sep 2024 02:21:11 +0200 Subject: [PATCH] Auto dark/light mode switching, fix Mason --- config/nvim/lua/chadrc.lua | 6 ++++++ config/nvim/lua/plugins/init.lua | 35 ++++++++++++++++++-------------- config/zsh/.zshenv | 1 + config/zsh/.zshrc | 8 ++++++-- config/zsh/aliases.zsh | 9 ++++---- config/zsh/fzf.zsh | 15 ++++++++++++-- config/zsh/settheme.zsh | 7 +++++++ 7 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 config/zsh/settheme.zsh diff --git a/config/nvim/lua/chadrc.lua b/config/nvim/lua/chadrc.lua index 052c562..1469e2f 100644 --- a/config/nvim/lua/chadrc.lua +++ b/config/nvim/lua/chadrc.lua @@ -25,6 +25,12 @@ M.ui = { statusline = { theme = "vscode_colored", } + +} + +M.mason = { + cmd = true, + pkgs = {"lua-language-server"} } return M diff --git a/config/nvim/lua/plugins/init.lua b/config/nvim/lua/plugins/init.lua index 23adc87..a552ee0 100644 --- a/config/nvim/lua/plugins/init.lua +++ b/config/nvim/lua/plugins/init.lua @@ -1,3 +1,10 @@ +--local function set_theme(name) +-- local cur_theme = require('nvconfig').ui.theme +-- require("nvchad.utils").replace_word(cur_theme, name) +-- require('nvconfig').ui.theme = name +-- require('base46').load_all_highlights() +--end + return { { "stevearc/conform.nvim", @@ -16,15 +23,6 @@ return { -- end, -- }, - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { - "lua-language-server", - }, - }, - }, - { "nvim-treesitter/nvim-treesitter", opts = { @@ -40,12 +38,19 @@ return { }, }, - { - "kdheepak/lazygit.nvim", - keys = { - { "lg", "LazyGit", desc = "LazyGit" }, - }, - } +-- { +-- "f-person/auto-dark-mode.nvim", +-- event = 'VeryLazy', +-- config = { +-- update_interval = 1000, +-- set_dark_mode = function() +-- set_theme('monekai') +-- end, +-- set_light_mode = function() +-- set_theme('ayu_light') +-- end, +-- } +-- } -- Install a plugin -- { diff --git a/config/zsh/.zshenv b/config/zsh/.zshenv index 704b17d..0146981 100644 --- a/config/zsh/.zshenv +++ b/config/zsh/.zshenv @@ -6,3 +6,4 @@ export XDG_STATE_HOME=$HOME/.local/state export HISTFILE=$XDG_DATA_HOME/zsh/history export HISTSIZE=10000 export SAVEHIST=$HISTSIZE +source $ZDOTDIR/settheme.zsh diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 97766e1..da73ff8 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -1,4 +1,4 @@ -# mac specific configuration +# macOS specific if [[ $(uname -s) = "Darwin" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" fi @@ -36,7 +36,11 @@ fpath=(~/.local/git/zsh_modules/wd $fpath) # theme and colors if [[ $(command -v vivid) ]]; then - export LS_COLORS=$(vivid generate molokai) + if [[ "${macos_interface_style}" = "Dark" ]]; then + export LS_COLORS=$(vivid generate molokai) + else + export LS_COLORS=$(vivid generate ayu) + fi else unset LS_COLORS fi diff --git a/config/zsh/aliases.zsh b/config/zsh/aliases.zsh index 4b2fb73..3715a67 100644 --- a/config/zsh/aliases.zsh +++ b/config/zsh/aliases.zsh @@ -12,7 +12,11 @@ gd() { alias less='less -R' if [[ $(command -v bat) ]]; then - alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright' + if [[ "${macos_interface_style}" = "Dark" ]]; then + alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright' + else + alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Light' + fi fi if [[ $(command -v eza) ]]; then @@ -44,9 +48,6 @@ elif [ $(command -v vim) ] ; then else export EDITOR=vi fi -if [ $(command -v zed) ] && [ $(id -u) -ne 0 ]; then - alias vim=zed -fi if [[ $(command -v rg) ]]; then alias grep='rg -i' diff --git a/config/zsh/fzf.zsh b/config/zsh/fzf.zsh index 6287655..6194077 100644 --- a/config/zsh/fzf.zsh +++ b/config/zsh/fzf.zsh @@ -2,8 +2,19 @@ if [[ $(command -v fzf) ]]; then source <(fzf --zsh) export FZF_DEFAULT_COMMAND='fd -H -L --ignore-file ~/.local/config/fd' export FZF_CTRL_T_COMMAND='fd -H -L --ignore-file ~/.local/config/fd' - export FZF_DEFAULT_OPTS="--multi -e --ansi --layout=reverse --preview='bat --color=always --tabs=2 --style=plain --theme=Monokai\ Extended\ Bright {}'" - export FZF_CTRL_R_OPTS="-e --ansi --layout=reverse --preview=''" + if [[ $macos_interface_style = "Light" ]]; then + FZF_COLORS=' + --color=fg:#5C6166,fg+:#FCFCFC,bg:#FCFCFC,bg+:#5C6166 + --color=hl:#4196df,hl+:#6daee6,info:#eba54d,marker:#80ab24 + --color=prompt:#e7666a,spinner:#9870c3,pointer:#b294d2,header:#51b891 + --color=border:#5C6166,label:#e7666a,query:#5C6166 + --border="rounded" --border-label="" --preview-window="border-rounded" --prompt="> " + --marker=">" --pointer="◆" --separator="─" --scrollbar="│"' + else + FZF_COLORS="" + fi + export FZF_DEFAULT_OPTS=$FZF_COLORS" --multi -e --ansi --layout=reverse --preview='bat --color=always --tabs=2 --style=plain --theme=Monokai\ Extended\ Light {}'" + export FZF_CTRL_R_OPTS=$FZF_COLORS" -e --ansi --layout=reverse --preview=''" _fzf_compgen_path() { fd -H -L --ignore-file ~/.local/config/fd . "$1" } diff --git a/config/zsh/settheme.zsh b/config/zsh/settheme.zsh new file mode 100644 index 0000000..0ec0fde --- /dev/null +++ b/config/zsh/settheme.zsh @@ -0,0 +1,7 @@ +if [[ $(uname -s) = "Darwin" ]]; then + if defaults read -g AppleInterfaceStyle > /dev/null 2>&1; then + export macos_interface_style=Dark + else + export macos_interface_style=Light + fi +fi