add catppuccin themes for emacs and nvim

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-01-24 15:10:52 +05:30
parent ec6533a782
commit 67a7c8ea27
9 changed files with 117 additions and 125 deletions

View File

@@ -1,34 +1,11 @@
#+TITLE: My Emacs Configuration # #+TITLE: My Emacs Configuration
#+AUTHOR: Amneesh Singh # #+AUTHOR: Amneesh Singh
#+PROPERTY: header-args:emacs-lisp :tangle yes #+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 * Settings
** Setting the default face ** Setting the default face
#+begin_src emacs-lisp #+begin_src emacs-lisp
; -*- lexical-binding: t; -*-
(set-frame-font "Fira Code 13" nil t) (set-frame-font "Fira Code 13" nil t)
(add-to-list 'default-frame-alist '(font . "Fira Code-13")) (add-to-list 'default-frame-alist '(font . "Fira Code-13"))
#+end_src #+end_src
@@ -43,6 +20,7 @@ idk random variables to match my color theme
;; (cua-mode 1) ;; (cua-mode 1)
(global-display-line-numbers-mode 1) (global-display-line-numbers-mode 1)
(xterm-mouse-mode 1) (xterm-mouse-mode 1)
(setq ring-bell-function 'ignore)
#+end_src #+end_src
** Setting some variables ** Setting some variables
@@ -53,7 +31,6 @@ idk random variables to match my color theme
scroll-step 1 scroll-step 1
display-line-numbers-type 'relative display-line-numbers-type 'relative
confirm-kill-processes nil confirm-kill-processes nil
dark-theme t
inhibit-startup-screen t) inhibit-startup-screen t)
(setq-default tab-width 2 (setq-default tab-width 2
indent-tabs-mode nil) indent-tabs-mode nil)
@@ -84,14 +61,10 @@ idk random variables to match my color theme
*** Set theme *** Set theme
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package doom-themes (use-package catppuccin-theme
:config :config
(setq doom-themes-enable-bold t (load-theme 'catppuccin t)
doom-themes-enable-italic t (setq dark-theme t))
doom-themes-treemacs-theme "doom-colors")
(load-theme 'doom-solarized-dark t)
(doom-themes-treemacs-config)
(doom-themes-org-config))
#+end_src #+end_src
** Configure Selectrum ** Configure Selectrum
@@ -267,11 +240,6 @@ For autocomplete
(use-package nix-mode (use-package nix-mode
:mode "\\.nix\\'") :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 (use-package hcl-mode
:mode :mode
@@ -418,29 +386,29 @@ For autocomplete
* Custom mode line * Custom mode line
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defface mode-line-buf-name (defface mode-line-buf-name
`((t :foreground ,c-fg `((t :foreground ,(catppuccin-get-color 'text)
:background ,c-bg :background ,(catppuccin-get-color 'base)
:weight bold :weight bold
)) ))
"Custom face for buffer name" "Custom face for buffer name"
:group 'mode-line-faces ) :group 'mode-line-faces )
(defface mode-line-maj-mode (defface mode-line-maj-mode
`((t :foreground ,c-fg `((t :foreground ,(catppuccin-get-color 'text)
:background ,c-bg :background ,(catppuccin-get-color 'base)
)) ))
"Custom face for major mode" "Custom face for major mode"
:group 'mode-line-faces ) :group 'mode-line-faces )
(defface mode-line-vc (defface mode-line-vc
`((t :foreground ,c-fg `((t :foreground ,(catppuccin-get-color 'base)
:background ,c-red-2 :background ,(catppuccin-get-color 'sky)
:weight bold :weight bold
)) ))
"Custom face for VC" "Custom face for VC"
:group 'mode-line-faces ) :group 'mode-line-faces )
(defface mode-line-info (defface mode-line-info
`((t :foreground ,c-bg `((t :foreground ,(catppuccin-get-color 'base)
:background ,c-cyan :background ,(catppuccin-get-color 'green)
:weight bold :weight bold
)) ))
"For showing line and column number" "For showing line and column number"
@@ -459,17 +427,16 @@ For autocomplete
(setq exclude-ln (cdr exclude-ln))) (setq exclude-ln (cdr exclude-ln)))
(let ((default-color (cons (face-background 'mode-line) (let ((default-color (cons (face-background 'mode-line)
(face-foreground 'mode-line)))) (face-foreground 'mode-line))))
(add-hook 'post-command-hook (add-hook 'post-command-hook
(lambda () (lambda ()
(let ((color (cond ((minibufferp) default-color) (let ((color (cond ((minibufferp) default-color)
((evil-insert-state-p) (cons c-magenta c-fg)) ((evil-insert-state-p) (cons (catppuccin-get-color 'mauve) (catppuccin-get-color 'base)))
((evil-visual-state-p) (cons c-cyan c-fg)) ((evil-normal-state-p) (cons (catppuccin-get-color 'yellow) (catppuccin-get-color 'base)))
((evil-normal-state-p) (cons c-fg c-bg)) ((evil-visual-state-p) (cons (catppuccin-get-color 'teal) (catppuccin-get-color 'base)))
((buffer-modified-p) (cons c-blue c-fg)) ((buffer-modified-p) (cons (catppuccin-get-color 'red) (catppuccin-get-color 'text)))
(t default-color)))) (t default-color))))
(set-face-background 'mode-line-buf-name (car color)) (set-face-background 'mode-line-buf-name (car color))
(set-face-foreground 'mode-line-buf-name (cdr color)) (set-face-foreground 'mode-line-buf-name (cdr color))))))
))))
#+end_src #+end_src
* Pop-up terminal * Pop-up terminal
@@ -595,14 +562,13 @@ This returns the command to run in the terminal
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun toggle-theme-shade () (defun toggle-theme-shade ()
(if (symbol-value dark-theme) (if (symbol-value dark-theme)
(progn (disable-theme 'doom-solarized-dark) (progn (setq catppuccin-flavor 'latte)
(load-theme 'doom-solarized-light t)) (catppuccin-reload))
(progn (disable-theme 'doom-solarized-light) (progn (setq catppuccin-flavor 'mocha)
(load-theme 'doom-solarized-dark t))) (catppuccin-reload)))
(setq-local dark-theme (not dark-theme)) (setq-local dark-theme (not dark-theme))
(centaur-tabs-display-update) (centaur-tabs-display-update)
(centaur-tabs-headline-match) (centaur-tabs-headline-match))
)
(general-define-key (general-define-key
:states '(normal) :states '(normal)

View File

@@ -34,3 +34,6 @@ set mail_check=60
auto_view text/html auto_view text/html
alternative_order text/enriched text/plain text/html text alternative_order text/enriched text/plain text/html text
macro index,pager U "<shell-escape>mbsync -a<enter>" "run mbsync to sync all emails" macro index,pager U "<shell-escape>mbsync -a<enter>" "run mbsync to sync all emails"
macro index A \
"<tag-pattern>~N<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" \
"mark all new as read"

View File

@@ -14,5 +14,4 @@
name = "Zafiro-icons-Dark"; name = "Zafiro-icons-Dark";
}; };
}; };
qt.platformTheme = "gtk";
} }

View File

@@ -82,5 +82,6 @@
anki-bin anki-bin
tor-browser-bundle-bin tor-browser-bundle-bin
mailcap mailcap
libsForQt5.qtstyleplugins
]; ];
} }

View File

@@ -11,6 +11,7 @@
LV2_PATH = lib.makeSearchPath "lib/lv2" (with pkgs; [ calf ]); LV2_PATH = lib.makeSearchPath "lib/lv2" (with pkgs; [ calf ]);
QT_X11_NO_MITSHM = "1"; QT_X11_NO_MITSHM = "1";
HM_CONF_DIR = "/etc/nixos"; HM_CONF_DIR = "/etc/nixos";
QT_QPA_PLATFORMTHEME = "gtk2";
}; };
shellAliases = rec { shellAliases = rec {

View File

@@ -22,6 +22,7 @@ in
}; };
initExtra = '' initExtra = ''
. ${secretPath}; . ${secretPath};
unsetopt extendedGlob
''; '';
}; };

View File

@@ -37,7 +37,7 @@
(nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars)) (nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))
vim-latex-live-preview vim-latex-live-preview
lspkind-nvim lspkind-nvim
base16-vim catppuccin-nvim
]; ];
}; };
}; };

View File

@@ -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) vim.api.nvim_set_option("termguicolors", true)
local comm = vim.api.nvim_command local bind = vim.keymap.set
local bind = vim.api.nvim_set_keymap
local setvar = vim.api.nvim_set_var
local getvar = vim.api.nvim_get_var
function hi(hi_var, hi_value) function hi(hi_var, hi_value)
comm("hi " .. hi_var .. " " .. hi_value) vim.cmd("hi " .. hi_var .. " " .. hi_value)
end end
--SETTINGS --SETTINGS
vim.o.cmdheight = 1 vim.o.cmdheight = 1
@@ -20,7 +19,6 @@ vim.o.cmdheight = 1
vim.o.mouse = "a" vim.o.mouse = "a"
vim.o.splitbelow = true vim.o.splitbelow = true
vim.o.splitright = true vim.o.splitright = true
--comm("set nowrap")
vim.o.conceallevel = 0 vim.o.conceallevel = 0
vim.o.tabstop = 2 vim.o.tabstop = 2
vim.o.shiftwidth = 2 vim.o.shiftwidth = 2
@@ -42,12 +40,8 @@ vim.o.cursorcolumn = true
--Colemak-DH bind fuction for hjkl [mnei]) --Colemak-DH bind fuction for hjkl [mnei])
local function cdhbind(a, b) local function cdhbind(a, b)
bind('n', a:lower(), b:lower(), { noremap = true}) bind('', a:lower(), b:lower())
bind('n', a:upper(), b:upper(), { noremap = true}) bind('', a:upper(), b:upper())
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})
end end
cdhbind('m', 'h') cdhbind('m', 'h')
@@ -61,20 +55,19 @@ cdhbind('f', 'e')
cdhbind('t', 'f') cdhbind('t', 'f')
cdhbind('j', 't') cdhbind('j', 't')
bind('n', "<M-s>", ":w<CR>", {noremap=true}) bind('n', "<M-n>", ":resize -2<CR>")
bind('n', "<M-n>", ":resize -2<CR>", {noremap=true, silent=true}) bind('n', "<M-e>", ":resize +2<CR>")
bind('n', "<M-e>", ":resize +2<CR>", {noremap=true, silent=true}) bind('n', "<M-m>", ":vertical resize -2<CR>")
bind('n', "<M-m>", ":vertical resize -2<CR>", {noremap=true, silent=true}) bind('n', "<M-i>", ":vertical resize +2<CR>")
bind('n', "<M-i>", ":vertical resize +2<CR>", {noremap=true, silent=true}) bind('v', '<', "<gv")
bind('v', '<', "<gv", {noremap=true}) bind('v', '>', ">gv")
bind('v', '>', ">gv", {noremap=true}) bind('n', "<C-q>", "<C-w>q")
bind('n', "<C-q>", "<C-w>q", {noremap=true}) bind('n', "<C-m>", "<C-w>h")
bind('n', "<C-m>", "<C-w>h", {noremap=true}) bind('n', "<C-n>", "<C-w>j")
bind('n', "<C-n>", "<C-w>j", {noremap=true}) bind('n', "<C-e>", "<C-w>k")
bind('n', "<C-e>", "<C-w>k", {noremap=true}) bind('n', "<C-i>", "<C-w>l")
bind('n', "<C-i>", "<C-w>l", {noremap=true}) bind('n', "<M-v>", ":vsplit<CR>")
bind('n', "<M-v>", ":vsplit<CR>", {noremap=true, silent=true}) bind('n', "<M-h>", ":split<CR>")
bind('n', "<M-h>", ":split<CR>", {noremap=true, silent=true})
--RUN AND REPL (using vim-floaterm) --RUN AND REPL (using vim-floaterm)
@@ -94,7 +87,7 @@ function _G.CompileRun()
['typescript']= 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' .. noext .. '.js' ['typescript']= 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' .. noext .. '.js'
} }
filetype = vim.api.nvim_buf_get_option(0, "filetype") 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 end
function _G.Repl() function _G.Repl()
@@ -110,17 +103,16 @@ function _G.Repl()
['lua'] = 'lua' ['lua'] = 'lua'
} }
filetype = vim.api.nvim_buf_get_option(0, "filetype") 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 end
bind('n', "<F5>", ":call v:lua.CompileRun()<CR>", {silent=true}) bind('n', "<F5>", ":call v:lua.CompileRun()<CR>")
bind('n', "<F6>", ":call v:lua.Repl()<CR>", {silent=true}) bind('n', "<F6>", ":call v:lua.Repl()<CR>")
--PLUGINS CONFIG --PLUGINS CONFIG
--nvim-tree.lua --nvim-tree.lua
require'nvim-tree'.setup { require'nvim-tree'.setup {
diagnostics = { diagnostics = {
enable = true, enable = true,
@@ -146,16 +138,28 @@ require'nvim-tree'.setup {
window_picker = { window_picker = {
enable = true, enable = true,
exclude = { exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" }, buftype = { "nofile", "terminal", "help" },
}, },
}, },
}, },
}, },
view = {
adaptive_size = true,
mappings = {
list = {
{ key = "e", action = "" },
{ key = "m", action = "" },
{ key = "f", action = "rename_basename" }
},
},
},
} }
bind('n', "<M-o>", ":NvimTreeToggle<CR>", {noremap=true, silent=true})
bind('n', "<Space>r", ":NvimTreeRefresh<CR>", {noremap=true, silent=true}) bind('n', "<M-o>", ":NvimTreeToggle<CR>")
bind('n', "<Space>f", ":NvimTreeFindFile<CR>", {noremap=true, silent=true}) bind('n', "<Space>r", ":NvimTreeRefresh<CR>")
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
--floaterm --floaterm
@@ -177,18 +181,18 @@ vim.g.closetag_emptyTags_caseSensitive = 1
vim.g.closetag_shortcut = '>' vim.g.closetag_shortcut = '>'
--nerdcommenter --nerdcommenter
bind('n',"<C-c>","<plug>NERDCommenterToggle", {noremap=true, silent=true}) bind('n',"<M-c>","<plug>NERDCommenterToggle")
bind('n',"<C-d>","<plug>NERDCommenterSexy", {noremap=true, silent=true}) bind('n',"<M-d>","<plug>NERDCommenterSexy")
--barbar --barbar
bind('n', "<M-,>", ":BufferPrevious<CR>", {silent=true, noremap=true}) bind('n', "<M-,>", ":BufferPrevious<CR>")
bind('n', "<M-.>", ":BufferNext<CR>", {silent=true, noremap=true}) bind('n', "<M-.>", ":BufferNext<CR>")
bind('n', "<M-<>", ":BufferMovePrevious<CR>", {silent=true, noremap=true}) bind('n', "<M-<>", ":BufferMovePrevious<CR>")
bind('n', "<M->>", ":BufferMoveNext<CR>", {silent=true, noremap=true}) bind('n', "<M->>", ":BufferMoveNext<CR>")
bind('n', "<M-w>", ":BufferClose<CR>", {silent=true, noremap=true}) bind('n', "<M-w>", ":BufferClose<CR>")
for i = 1,8,1 for i = 1,8,1
do do
bind('n', string.format("<M-%d>", i), string.format(":BufferGoto %d<CR>", i), {silent=true, noremap=true}) bind('n', string.format("<M-%d>", i), string.format(":BufferGoto %d<CR>", i))
end end
--presence.nvim --presence.nvim
@@ -223,7 +227,7 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', '<M-k>', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', '<M-k>', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, 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', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', "<M-f>", function() vim.lsp.buf.format { async = true } end, bufopts) vim.keymap.set('n', "<M-C-f>", function() vim.lsp.buf.format { async = true } end, bufopts)
end end
local servers = { "clangd", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp", "html", "cssls", "jsonls", "svelte", "gopls" } 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 --STATUSLINE
comm("set noruler") vim.cmd("set noruler")
vim.o.laststatus = 2 vim.o.laststatus = 2
local function mode() local function mode()
local mode_map = { local mode_map = {
@@ -340,11 +344,21 @@ end
--theming --theming
local dark = true local dark = true
comm("colorscheme base16-solarized-dark")
hi("Light", "guibg=#eee8d5 guifg=#002b36") require("catppuccin").setup({
hi("Misc", "guibg=#dc322f guifg=#fdf6e3") flavour = "mocha",
hi("Dark", "guibg=#002b36 guifg=#839496") 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 function git()
local branch = io.popen([[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read("*a") 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() function _G.ToggleTheme()
if dark then 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 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 end
dark = not dark 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 end
bind('n', "<F7>", ":call v:lua.ToggleTheme()<CR>", {silent=true})
bind('n', "<F7>", ":call v:lua.ToggleTheme()<CR>")
vim.g.tex_flavor = "latex" vim.g.tex_flavor = "latex"

View File

@@ -30,7 +30,7 @@ let
mantle = "#181825"; mantle = "#181825";
crust = "#11111B"; crust = "#11111B";
background = crust; background = base;
foreground = text; foreground = text;
}; };
in in