From 5241b7e2cbee2c47749dee06248255416c65db7e Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Sun, 21 Aug 2022 03:26:51 +0200 Subject: Emacs: Update init.el file --- .config/emacs/init.el | 218 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 184 insertions(+), 34 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index ffcd1bb..b9a465c 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -1,6 +1,3 @@ -(setq user-full-name "Jakub Dlugosz" - user-mail-address "jdlugosz963@gmail.com") - (setq gc-cons-threshold (* 50 1000 1000)) (defun jd/display-startup-time () @@ -12,6 +9,18 @@ (add-hook 'emacs-startup-hook #'jd/display-startup-time) +(setq user-full-name "Jakub Dlugosz" + user-mail-address "jdlugosz963@gmail.com") + +(setq backup-directory-alist '(("." . "~/.cache/emacs/backup")) + backup-by-copying t + version-control t + delete-old-versions t + kept-new-versions 20 + kept-old-versions 5) + +(setq user-emacs-directory "~/.cache/emacs") + (require 'package) (setq package-archives '(("melpa" . "https://melpa.org/packages/") ("org" . "https://orgmode.org/elpa/") @@ -40,6 +49,7 @@ :prefix "C-c")) (use-package undo-tree + :diminish :config (setq undo-tree-auto-save-history nil) (global-undo-tree-mode 1)) @@ -78,16 +88,33 @@ (set-face-attribute 'default nil :font "Hack" :height 100) - ; (load-theme 'wombat) +(add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative) (global-set-key (kbd "") 'keyboard-escape-quit) -(use-package monokai-theme +(defalias 'yes-or-no-p 'y-or-n-p) + +(use-package doom-themes :config - (load-theme 'monokai t)) + (load-theme 'doom-molokai t)) (use-package diminish) +(use-package hl-todo + :init + (setq hl-todo-keyword-faces + '(("TODO" . "#FF0000") + ("FIXME" . "#FF0000") + ("DEBUG" . "#A020F0"))) + :config + (global-hl-todo-mode 1)) + +(defun jd/switch-buffer () + (interactive) + (let ((completion-regexp-list '("\\`[^*]" + "\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*"))) + (call-interactively 'counsel-switch-buffer))) + (use-package counsel) (use-package ivy :diminish @@ -106,7 +133,8 @@ "tt" '(counsel-load-theme :which-key "Choose theme")) (jd/leader-key-def - "bb" '(counsel-switch-buffer :which-key "Buffer switch") + "bb" '(jd/switch-buffer :which-key "Buffer switch") + "ba" '(counsel-switch-buffer :which-key "Buffer switch") "b" '(:ignore t :which-key "Buffer") "," '(counsel-switch-buffer :which-key "Buffer switch")) @@ -122,6 +150,10 @@ :init (doom-modeline-mode 1) :custom ((doom-modeline-height 15))) +(use-package beacon + :config + (beacon-mode 1)) + (jd/leader-key-def "f" '(:ignore t :which-key "Files") "fs" '(save-buffer :which-key "File save") @@ -136,8 +168,14 @@ :keymaps '(visual) "er" '(eval-region :which-key "Eval region")) +(defun jd/kill-other-buffers () + (interactive) + (mapc 'kill-buffer (cdr (buffer-list (current-buffer))))) + (jd/leader-key-def - "bk" '(kill-this-buffer :which-key "Buffer kill")) + "bK" '(jd/kill-other-buffers :which-key "Kill other buffers")) + "bk" '(kill-current-buffer :which-key "Kill buffer") + "bB" '(ibuffer :which-key "Open ibuffer")) (defun jd/org-mode-setup () (org-indent-mode) @@ -148,22 +186,23 @@ :pin org :commands (org-capture org-agenda) :hook (org-mode . jd/org-mode-setup) - :config + :init (setq org-ellipsis " ▾") - (setq org-agenda-start-with-log-mode t) (setq org-log-done 'time) (setq org-log-into-drawer t) + (setq org-return-follows-link t) + :config + (menu-bar--display-line-numbers-mode-none) (require 'org-tempo)) (jd/leader-key-def "o" '(:ignore t :which-key "Open") "oa" '(org-agenda :which-key "Open org-agenda")) -(use-package org-make-toc) - -(add-hook 'org-mode-hook #'org-make-toc-mode) -; (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'org-make-toc))) +(use-package toc-org + :config + (add-hook 'org-mode-hook 'toc-org-mode)) (defun jd/org-font-setup () ;; Replace list hyphen with dot @@ -211,7 +250,7 @@ (defun jd/org-babel-tangle-config () (when (string-equal (file-name-directory (buffer-file-name)) - (expand-file-name user-emacs-directory)) + (expand-file-name "~/dotfiles/")) ;; Dynamic scoping to the rescue (let ((org-confirm-babel-evaluate nil)) (org-babel-tangle)))) @@ -228,24 +267,128 @@ (use-package org-superstar :hook (org-mode . org-superstar-mode) - :config + :init (setq org-superstar-special-todo-items t) (setq org-superstar-remove-leading-stars t) (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) +(use-package org-roam + :custom + (org-roam-directory (file-truename "~/Documents/org/roam/")) + :bind (("C-c n l" . org-roam-buffer-toggle) + ("C-c n f" . org-roam-node-find) + ("C-c n g" . org-roam-graph) + ("C-c n i" . org-roam-node-insert) + ("C-c n c" . org-roam-capture) + ;; Dailies + ("C-c n j" . org-roam-dailies-capture-today)) + :config + ;; If you're using a vertical completion framework, you might want a more informative completion interface + (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) + (org-roam-db-autosync-mode)) + +(use-package lsp-mode + :commands (lsp lsp-deferred) + :init + (setq lsp-headerline-breadcrumb-enable nil) + (setq lsp-diagnostics-provider :none) + (setq lsp-modeline-diagnostics-enable nil) + (setq lsp-keymap-prefix "C-c l") + :config + (lsp-enable-which-key-integration t)) + +(use-package lsp-ivy + :after lsp) + +(defun jd/python-mode-setup () + (let ((project-venv-path (concat (projectile-project-root) "venv/"))) + (when (projectile--directory-p project-venv-path) + (pyvenv-activate project-venv-path) + (pyvenv-mode)))) + +(use-package python-mode + :hook (python-mode . lsp-deferred) + :hook (python-mode . jd/python-mode-setup)) + +(use-package pyvenv + :after python-mode) + +(use-package dap-mode + ;; Uncomment the config below if you want all UI panes to be hidden by default! + ;; :custom + ;; (lsp-enable-dap-auto-configure nil) + ;; :config + ;; (dap-ui-mode 1) + :commands dap-debug + :config + ;; Set up Node debugging + (require 'dap-node) + (dap-node-setup) ;; Automatically installs Node debug adapter if needed + + ;; Bind `C-c l d` to `dap-hydra` for easy access + (general-define-key + :keymaps 'lsp-mode-map + :prefix lsp-keymap-prefix + "d" '(dap-hydra t :wk "debugger"))) + +(use-package company + :after lsp-mode + :hook (lsp-mode . company-mode) + :bind (:map company-active-map + ("" . company-complete-selection)) + (:map lsp-mode-map + ("" . company-indent-or-complete-common)) + :custom + (company-minimum-prefix-length 1) + (company-idle-delay 0.0)) + +(use-package company-box + :hook (company-mode . company-box-mode)) + (use-package projectile :diminish projectile-mode :init (when (file-directory-p "~/Documents/code") (setq projectile-project-search-path '("~/Documents/code/"))) - :config (projectile-mode) - :custom ((projectile-Completion-system 'ivy))) + :custom ((projectile-Completion-system 'ivy)) + :config + (setq projectile-switch-project-action #'projectile-dired) + (projectile-mode)) (jd/leader-key-def "p" '(projectile-command-map :which-key "Project") "p " '() "SPC" '(projectile-find-file :which-key "Find file in project")) +(defun jd/neotree-project-dir () + "Open NeoTree using the git root." + (interactive) + (let ((project-dir (projectile-project-root)) + (file-name (buffer-file-name))) + (neotree-toggle) + (if project-dir + (if (neo-global--window-exists-p) + (progn + (neotree-dir project-dir) + (neotree-find file-name))) + (message "Could not find git project root.")))) + +(use-package neotree + :init + (setq neo-theme 'icons) + :config + + (evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter) + (evil-define-key 'normal neotree-mode-map (kbd "C-RET") 'neotree-quick-look) + (evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide) + (evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter) + (evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh) + (evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle) + (evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle)) + +(jd/leader-key-def + "op" '(jd/neotree-project-dir :which-key "Open neotree")) + (use-package magit :custom (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) @@ -254,36 +397,43 @@ "g" '(:ignore t :which-key "Git") "gg" '(magit-status-here :which-key "Magit status")) -(use-package vterm) -(use-package vterm-toggle - :init - (setq vterm-toggle-fullscreen-p nil) +(defun jd/open-new-vterm () + (interactive) + (let ((buffer-name (generate-new-buffer-name vterm-buffer-name))) + (switch-to-buffer buffer-name) + (vterm-mode))) + +(use-package vterm :config - (add-to-list 'display-buffer-alist - '((lambda (buffer-or-name _) - (let ((buffer (get-buffer buffer-or-name))) - (with-current-buffer buffer - (or (equal major-mode 'vterm-mode) - (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) - (display-buffer-reuse-window display-buffer-at-bottom) - (reusable-frames . visible) - (window-height . 0.3)))) + (setq vterm-buffer-name "vterm")) (jd/leader-key-def - "oT" '(vterm :which-key "Open terminal in current window") - "ot" '(vterm-toggle :which-key "Toggle terminal")) + "ot" '(jd/open-new-vterm :which-key "Open terminal in current window")) (use-package all-the-icons-dired :hook (dired-mode . all-the-icons-dired-mode)) (use-package dired-ranger) +(use-package dired-single) + (use-package dired :ensure nil :commands (dired dired-jump) - :bind (("C-x C-j" . dired-jump)) :custom ((dired-listing-switches "-agho --group-directories-first")) :config (evil-collection-define-key 'normal 'dired-mode-map + "y" 'dired-ranger-copy + "p" 'dired-ranger-paste + "X" 'dired-ranger-move "h" 'dired-up-directory "l" 'dired-single-buffer)) + +(use-package emms + :config + (require 'emms-setup) + (emms-all) + (emms-standard) + (emms-default-players) + (emms-mode-line-disable) + (emms-add-directory-tree "~/Documents/music/")) -- cgit v1.2.3