From 67a7c8ea27165976dd8fd51f9854b87eeee10a7e Mon Sep 17 00:00:00 2001 From: Amneesh Singh Date: Tue, 24 Jan 2023 15:10:52 +0530 Subject: [PATCH] add catppuccin themes for emacs and nvim Signed-off-by: Amneesh Singh --- home/natto/config/emacs/config.org | 94 ++++++------------- home/natto/config/neomutt/neomuttrc | 3 + home/natto/gtk.nix | 1 - home/natto/pkgs.nix | 1 + home/natto/stuff.nix | 1 + home/natto/zsh.nix | 1 + hosts/modules/nvim/default.nix | 2 +- hosts/modules/nvim/init.lua | 137 ++++++++++++++++------------ lib/colors.nix | 2 +- 9 files changed, 117 insertions(+), 125 deletions(-) diff --git a/home/natto/config/emacs/config.org b/home/natto/config/emacs/config.org index 2846f4c..7b083b8 100644 --- a/home/natto/config/emacs/config.org +++ b/home/natto/config/emacs/config.org @@ -1,34 +1,11 @@ -#+TITLE: My Emacs Configuration -#+AUTHOR: Amneesh Singh +# #+TITLE: My Emacs Configuration +# #+AUTHOR: Amneesh Singh #+PROPERTY: header-args:emacs-lisp :tangle yes -* Color Variables -idk random variables to match my color theme -#+begin_src emacs-lisp - ; -*- lexical-binding: t; -*- -( setq - c-bg "#073642" - c-fg "#eee8d5" - c-red "#dc322f" - c-green "#859900" - c-yellow "#b58900" - c-blue "#268bd2" - c-magenta "#d33682" - c-cyan "#2aa198" - c-white "#eee8d5" - c-black "#002b36" - c-red-2 "#cb4b16" - c-green-2 "#586e75" - c-yellow-2 "#657b83" - c-blue-2 "#839496" - c-magenta-2 "#6c71c4" - c-cyan-2 "#93a1a1" - c-white-2 "#fdf6e3") -#+end_src - * Settings ** Setting the default face #+begin_src emacs-lisp + ; -*- lexical-binding: t; -*- (set-frame-font "Fira Code 13" nil t) (add-to-list 'default-frame-alist '(font . "Fira Code-13")) #+end_src @@ -43,6 +20,7 @@ idk random variables to match my color theme ;; (cua-mode 1) (global-display-line-numbers-mode 1) (xterm-mouse-mode 1) +(setq ring-bell-function 'ignore) #+end_src ** Setting some variables @@ -53,7 +31,6 @@ idk random variables to match my color theme scroll-step 1 display-line-numbers-type 'relative confirm-kill-processes nil - dark-theme t inhibit-startup-screen t) (setq-default tab-width 2 indent-tabs-mode nil) @@ -84,14 +61,10 @@ idk random variables to match my color theme *** Set theme #+begin_src emacs-lisp -(use-package doom-themes +(use-package catppuccin-theme :config - (setq doom-themes-enable-bold t - doom-themes-enable-italic t - doom-themes-treemacs-theme "doom-colors") - (load-theme 'doom-solarized-dark t) - (doom-themes-treemacs-config) - (doom-themes-org-config)) + (load-theme 'catppuccin t) + (setq dark-theme t)) #+end_src ** Configure Selectrum @@ -267,11 +240,6 @@ For autocomplete (use-package nix-mode :mode "\\.nix\\'") -(add-to-list 'lsp-language-id-configuration '(nix-mode . "nix")) -(lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection '("rnix-lsp")) - :major-modes '(nix-mode) - :server-id 'nix)) (use-package hcl-mode :mode @@ -418,29 +386,29 @@ For autocomplete * Custom mode line #+begin_src emacs-lisp (defface mode-line-buf-name - `((t :foreground ,c-fg - :background ,c-bg + `((t :foreground ,(catppuccin-get-color 'text) + :background ,(catppuccin-get-color 'base) :weight bold )) "Custom face for buffer name" :group 'mode-line-faces ) (defface mode-line-maj-mode - `((t :foreground ,c-fg - :background ,c-bg + `((t :foreground ,(catppuccin-get-color 'text) + :background ,(catppuccin-get-color 'base) )) "Custom face for major mode" :group 'mode-line-faces ) (defface mode-line-vc - `((t :foreground ,c-fg - :background ,c-red-2 + `((t :foreground ,(catppuccin-get-color 'base) + :background ,(catppuccin-get-color 'sky) :weight bold )) "Custom face for VC" :group 'mode-line-faces ) (defface mode-line-info - `((t :foreground ,c-bg - :background ,c-cyan + `((t :foreground ,(catppuccin-get-color 'base) + :background ,(catppuccin-get-color 'green) :weight bold )) "For showing line and column number" @@ -459,17 +427,16 @@ For autocomplete (setq exclude-ln (cdr exclude-ln))) (let ((default-color (cons (face-background 'mode-line) (face-foreground 'mode-line)))) - (add-hook 'post-command-hook - (lambda () - (let ((color (cond ((minibufferp) default-color) - ((evil-insert-state-p) (cons c-magenta c-fg)) - ((evil-visual-state-p) (cons c-cyan c-fg)) - ((evil-normal-state-p) (cons c-fg c-bg)) - ((buffer-modified-p) (cons c-blue c-fg)) - (t default-color)))) - (set-face-background 'mode-line-buf-name (car color)) - (set-face-foreground 'mode-line-buf-name (cdr color)) - )))) + (add-hook 'post-command-hook + (lambda () + (let ((color (cond ((minibufferp) default-color) + ((evil-insert-state-p) (cons (catppuccin-get-color 'mauve) (catppuccin-get-color 'base))) + ((evil-normal-state-p) (cons (catppuccin-get-color 'yellow) (catppuccin-get-color 'base))) + ((evil-visual-state-p) (cons (catppuccin-get-color 'teal) (catppuccin-get-color 'base))) + ((buffer-modified-p) (cons (catppuccin-get-color 'red) (catppuccin-get-color 'text))) + (t default-color)))) + (set-face-background 'mode-line-buf-name (car color)) + (set-face-foreground 'mode-line-buf-name (cdr color)))))) #+end_src * Pop-up terminal @@ -595,14 +562,13 @@ This returns the command to run in the terminal #+begin_src emacs-lisp (defun toggle-theme-shade () (if (symbol-value dark-theme) - (progn (disable-theme 'doom-solarized-dark) - (load-theme 'doom-solarized-light t)) - (progn (disable-theme 'doom-solarized-light) - (load-theme 'doom-solarized-dark t))) + (progn (setq catppuccin-flavor 'latte) + (catppuccin-reload)) + (progn (setq catppuccin-flavor 'mocha) + (catppuccin-reload))) (setq-local dark-theme (not dark-theme)) (centaur-tabs-display-update) - (centaur-tabs-headline-match) - ) + (centaur-tabs-headline-match)) (general-define-key :states '(normal) diff --git a/home/natto/config/neomutt/neomuttrc b/home/natto/config/neomutt/neomuttrc index a8bfc7a..2a49723 100644 --- a/home/natto/config/neomutt/neomuttrc +++ b/home/natto/config/neomutt/neomuttrc @@ -34,3 +34,6 @@ set mail_check=60 auto_view text/html alternative_order text/enriched text/plain text/html text macro index,pager U "mbsync -a" "run mbsync to sync all emails" +macro index A \ + "~NN." \ + "mark all new as read" diff --git a/home/natto/gtk.nix b/home/natto/gtk.nix index 05f16b3..6578694 100644 --- a/home/natto/gtk.nix +++ b/home/natto/gtk.nix @@ -14,5 +14,4 @@ name = "Zafiro-icons-Dark"; }; }; - qt.platformTheme = "gtk"; } diff --git a/home/natto/pkgs.nix b/home/natto/pkgs.nix index 68d813a..ef4798a 100644 --- a/home/natto/pkgs.nix +++ b/home/natto/pkgs.nix @@ -82,5 +82,6 @@ anki-bin tor-browser-bundle-bin mailcap + libsForQt5.qtstyleplugins ]; } diff --git a/home/natto/stuff.nix b/home/natto/stuff.nix index 41daa04..c95b9b5 100644 --- a/home/natto/stuff.nix +++ b/home/natto/stuff.nix @@ -11,6 +11,7 @@ LV2_PATH = lib.makeSearchPath "lib/lv2" (with pkgs; [ calf ]); QT_X11_NO_MITSHM = "1"; HM_CONF_DIR = "/etc/nixos"; + QT_QPA_PLATFORMTHEME = "gtk2"; }; shellAliases = rec { diff --git a/home/natto/zsh.nix b/home/natto/zsh.nix index 06574e3..010435b 100644 --- a/home/natto/zsh.nix +++ b/home/natto/zsh.nix @@ -22,6 +22,7 @@ in }; initExtra = '' . ${secretPath}; + unsetopt extendedGlob ''; }; diff --git a/hosts/modules/nvim/default.nix b/hosts/modules/nvim/default.nix index 76fe28d..eb68621 100644 --- a/hosts/modules/nvim/default.nix +++ b/hosts/modules/nvim/default.nix @@ -37,7 +37,7 @@ (nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars)) vim-latex-live-preview lspkind-nvim - base16-vim + catppuccin-nvim ]; }; }; diff --git a/hosts/modules/nvim/init.lua b/hosts/modules/nvim/init.lua index f1eb5da..41c6f53 100644 --- a/hosts/modules/nvim/init.lua +++ b/hosts/modules/nvim/init.lua @@ -1,11 +1,10 @@ +--i do not really maintain this anymore since emacs is my main editor now + vim.api.nvim_set_option("termguicolors", true) -local comm = vim.api.nvim_command -local bind = vim.api.nvim_set_keymap -local setvar = vim.api.nvim_set_var -local getvar = vim.api.nvim_get_var +local bind = vim.keymap.set function hi(hi_var, hi_value) - comm("hi " .. hi_var .. " " .. hi_value) + vim.cmd("hi " .. hi_var .. " " .. hi_value) end --SETTINGS vim.o.cmdheight = 1 @@ -20,7 +19,6 @@ vim.o.cmdheight = 1 vim.o.mouse = "a" vim.o.splitbelow = true vim.o.splitright = true ---comm("set nowrap") vim.o.conceallevel = 0 vim.o.tabstop = 2 vim.o.shiftwidth = 2 @@ -42,12 +40,8 @@ vim.o.cursorcolumn = true --Colemak-DH bind fuction for hjkl [mnei]) local function cdhbind(a, b) - bind('n', a:lower(), b:lower(), { noremap = true}) - bind('n', a:upper(), b:upper(), { noremap = true}) - bind('o', a:lower(), b:lower(), { noremap = true}) - bind('o', a:upper(), b:upper(), { noremap = true}) - bind('x', a:lower(), b:lower(), { noremap = true}) - bind('x', a:upper(), b:upper(), { noremap = true}) + bind('', a:lower(), b:lower()) + bind('', a:upper(), b:upper()) end cdhbind('m', 'h') @@ -61,20 +55,19 @@ cdhbind('f', 'e') cdhbind('t', 'f') cdhbind('j', 't') -bind('n', "", ":w", {noremap=true}) -bind('n', "", ":resize -2", {noremap=true, silent=true}) -bind('n', "", ":resize +2", {noremap=true, silent=true}) -bind('n', "", ":vertical resize -2", {noremap=true, silent=true}) -bind('n', "", ":vertical resize +2", {noremap=true, silent=true}) -bind('v', '<', "', ">gv", {noremap=true}) -bind('n', "", "q", {noremap=true}) -bind('n', "", "h", {noremap=true}) -bind('n', "", "j", {noremap=true}) -bind('n', "", "k", {noremap=true}) -bind('n', "", "l", {noremap=true}) -bind('n', "", ":vsplit", {noremap=true, silent=true}) -bind('n', "", ":split", {noremap=true, silent=true}) +bind('n', "", ":resize -2") +bind('n', "", ":resize +2") +bind('n', "", ":vertical resize -2") +bind('n', "", ":vertical resize +2") +bind('v', '<', "', ">gv") +bind('n', "", "q") +bind('n', "", "h") +bind('n', "", "j") +bind('n', "", "k") +bind('n', "", "l") +bind('n', "", ":vsplit") +bind('n', "", ":split") --RUN AND REPL (using vim-floaterm) @@ -94,7 +87,7 @@ function _G.CompileRun() ['typescript']= 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' .. noext .. '.js' } filetype = vim.api.nvim_buf_get_option(0, "filetype") - if commandMap[filetype] ~= nil then comm("FloatermNew --autoclose=0 " .. commandMap[filetype]) end + if commandMap[filetype] ~= nil then vim("FloatermNew --autoclose=0 " .. commandMap[filetype]) end end function _G.Repl() @@ -110,17 +103,16 @@ function _G.Repl() ['lua'] = 'lua' } filetype = vim.api.nvim_buf_get_option(0, "filetype") - if commandMap[filetype] ~= nil then comm("FloatermNew " .. commandMap[filetype]) end + if commandMap[filetype] ~= nil then vim.cmd("FloatermNew " .. commandMap[filetype]) end end -bind('n', "", ":call v:lua.CompileRun()", {silent=true}) -bind('n', "", ":call v:lua.Repl()", {silent=true}) +bind('n', "", ":call v:lua.CompileRun()") +bind('n', "", ":call v:lua.Repl()") --PLUGINS CONFIG --nvim-tree.lua - require'nvim-tree'.setup { diagnostics = { enable = true, @@ -146,16 +138,28 @@ require'nvim-tree'.setup { window_picker = { enable = true, exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, }, }, }, }, + view = { + adaptive_size = true, + mappings = { + list = { + { key = "e", action = "" }, + { key = "m", action = "" }, + { key = "f", action = "rename_basename" } + }, + }, + }, } -bind('n', "", ":NvimTreeToggle", {noremap=true, silent=true}) -bind('n', "r", ":NvimTreeRefresh", {noremap=true, silent=true}) -bind('n', "f", ":NvimTreeFindFile", {noremap=true, silent=true}) + +bind('n', "", ":NvimTreeToggle") +bind('n', "r", ":NvimTreeRefresh") +bind('n', "f", ":NvimTreeFindFile") +bind('n', "f", ":NvimTreeFindFile") --floaterm @@ -177,18 +181,18 @@ vim.g.closetag_emptyTags_caseSensitive = 1 vim.g.closetag_shortcut = '>' --nerdcommenter -bind('n',"","NERDCommenterToggle", {noremap=true, silent=true}) -bind('n',"","NERDCommenterSexy", {noremap=true, silent=true}) +bind('n',"","NERDCommenterToggle") +bind('n',"","NERDCommenterSexy") --barbar -bind('n', "", ":BufferPrevious", {silent=true, noremap=true}) -bind('n', "", ":BufferNext", {silent=true, noremap=true}) -bind('n', "", ":BufferMovePrevious", {silent=true, noremap=true}) -bind('n', ">", ":BufferMoveNext", {silent=true, noremap=true}) -bind('n', "", ":BufferClose", {silent=true, noremap=true}) +bind('n', "", ":BufferPrevious") +bind('n', "", ":BufferNext") +bind('n', "", ":BufferMovePrevious") +bind('n', ">", ":BufferMoveNext") +bind('n', "", ":BufferClose") for i = 1,8,1 do - bind('n', string.format("", i), string.format(":BufferGoto %d", i), {silent=true, noremap=true}) + bind('n', string.format("", i), string.format(":BufferGoto %d", i)) end --presence.nvim @@ -223,7 +227,7 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', '', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', "", function() vim.lsp.buf.format { async = true } end, bufopts) + vim.keymap.set('n', "", function() vim.lsp.buf.format { async = true } end, bufopts) end local servers = { "clangd", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp", "html", "cssls", "jsonls", "svelte", "gopls" } @@ -313,10 +317,10 @@ cmp.setup { }, } -comm("set shortmess+=c") +vim.cmd("set shortmess+=c") --STATUSLINE -comm("set noruler") +vim.cmd("set noruler") vim.o.laststatus = 2 local function mode() local mode_map = { @@ -340,11 +344,21 @@ end --theming local dark = true -comm("colorscheme base16-solarized-dark") -hi("Light", "guibg=#eee8d5 guifg=#002b36") -hi("Misc", "guibg=#dc322f guifg=#fdf6e3") -hi("Dark", "guibg=#002b36 guifg=#839496") +require("catppuccin").setup({ + flavour = "mocha", + background = { + light = "latte", + dark = "mocha", + }, +}) + +vim.cmd("colorscheme catppuccin") + +local colors = require("catppuccin.palettes").get_palette "latte" +hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust) +hi("Misc", "guibg=" .. colors.pink .. " guifg=" .. colors.base) +hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text) local function git() local branch = io.popen([[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read("*a") @@ -375,15 +389,22 @@ vim.o.statusline = table.concat(statusline) function _G.ToggleTheme() if dark then - comm("colorscheme base16-solarized-light") + vim.cmd("set background=light") + local colors = require("catppuccin.palettes").get_palette "latte" + hi("Light", "guibg=" .. colors.crust .. " guifg=" .. colors.text) + hi("Misc", "guibg=" .. colors.peach .. " guifg=" .. colors.text) + hi("Dark", "guibg=" .. colors.text .. " guifg=" .. colors.crust) + vim.o.statusline = table.concat(statusline) else - comm("colorscheme base16-solarized-dark") + vim.cmd("set background=dark") + local colors = require("catppuccin.palettes").get_palette "mocha" + hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust) + hi("Misc", "guibg=" .. colors.pink .. " guifg=" .. colors.base) + hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text) + vim.o.statusline = table.concat(statusline) end dark = not dark - hi("Light", "guibg=#eee8d5 guifg=#002b36") - hi("Dark", "guibg=#002b36 guifg=#839496") - hi("Misc", "guibg=#dc322f guifg=#fdf6e3") - vim.o.statusline = table.concat(statusline) end -bind('n', "", ":call v:lua.ToggleTheme()", {silent=true}) + +bind('n', "", ":call v:lua.ToggleTheme()") vim.g.tex_flavor = "latex" diff --git a/lib/colors.nix b/lib/colors.nix index ff4e642..19065a2 100644 --- a/lib/colors.nix +++ b/lib/colors.nix @@ -30,7 +30,7 @@ let mantle = "#181825"; crust = "#11111B"; - background = crust; + background = base; foreground = text; }; in