Skip to content

Cobalt-Inferno/emacs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Configure use-package

Setup archives

(require 'package)
(add-to-list 'package-archives '("gnu"   . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

Ensure installed

(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t
  use-package-expand-minimally t))

Installing packages

Evil Mode

I’m using both Evil and Evil collection, as it’s better than just evil. We will enable some configurations, thus making it a bit better.

(use-package evil
  :ensure t
  :init
  (setq evil-want-keybinding nil)
  (setq evil-vsplit-window-right t)
  (setq evil-want-C-u-scroll t)
  (setq evil-split-window-below t)
  (evil-mode))
(use-package evil-collection
  :after evil
  :ensure t
  :config
  (evil-collection-init))

Themes

I typically use the Dracula theme, but its good to mix.

(use-package dracula-theme
  :ensure t)
(use-package catppuccin-theme
  :ensure t)
(use-package nord-theme
  :ensure t)
(use-package doom-themes
  :ensure t)

Dirvish

Dirvish is my file manager of choice, and it is also based off Dired.

(use-package dirvish
  :ensure t)

Here we can also override dired by using this configuration

(dirvish-override-dired-mode)

General

General gives us some nice features for other packages.

(use-package general
  :ensure t
  :config
  (general-evil-setup t))

All The Icons

Just a simple icon plugin

(use-package all-the-icons)

Projectile

(use-package projectile
  :config
  (projectile-global-mode 1))

Neotree

Neotree is a plugin that gives us a nice little “file manager” on the side of emacs.

(use-package neotree
  :ensure t)

Here we can enable some nice defaults

(setq neo-smart-open t
  neo-window-width 35
  neo-theme (if (display-graphic-p) 'icons 'arrow)
  inhibit-compacting-font-caches t
  projectile-switch-project-action 'neotree-projectile-action)
  (add-hook 'neo-after-create-hook
    #'(lambda (_)
      (with-current-buffer (get-buffer neo-buffer-name)
      (setq truncate-lines t)
      (setq word-wrap nil)
      (make-local-variable 'auto-hscroll-mode)
      (setq auto-hscroll-mode nil))))
(defcustom neo-window-width 25
"*Specifies the width of the NeoTree window."
  :type 'integer
  :group 'neotree)
(setq-default neo-show-hidden-files t)

Treesitter

(use-package tree-sitter
  :ensure t)
(use-package tree-sitter-langs
  :ensure t)

Dashboard

Here I’ll just do all the configurations inside the init block.

(use-package dashboard
  :init      ;; tweak dashboard config before loading it
  (setq dashboard-set-heading-icons t)
  (setq dashboard-set-file-icons t)
  (setq dashboard-banner-logo-title "real programmers use vi")
  ;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner
  (setq dashboard-startup-banner "~/.emacs.d/.local/logo.png")  ;; use custom image as banner
  (setq dashboard-center-content t) ;; set to 't' for centered content
  (setq dashboard-items '((recents . 5)
                          (agenda . 5 )
                          (bookmarks . 3)
                          (projects . 3)))
  :config
  (dashboard-setup-startup-hook)
  (dashboard-modify-heading-icons '((recents . "file-text")
			      (bookmarks . "book"))))

Everything for a better M-x

(use-package smex
  :ensure t
  :config
  (smex-initialize))
(use-package vertico
  :ensure t
  :bind (:map vertico-map
	      ("C-j" . vertico-next)
	      ("C-k" . vertico-previous)
	      ("C-f" . vertico-exit))
  :custom
  (vertico-cycle t)
  :init
  (vertico-mode))
(use-package marginalia
  :after vertico
  :ensure t
  :custom
  (marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
  :init
  (marginalia-mode))

Terminal

I prefer vterm

(use-package vterm
    :ensure t)

Which-key

Which key helps with ‘definitions’ for functions

(use-package which-key
    :config
    (which-key-mode))

Writing plugins

(use-package sublimity
  :ensure t
  :config
  (sublimity-mode 1))
(use-package flycheck
  :ensure t
  :init
  (global-flycheck-mode t))
(use-package emojify
  :hook (after-init . global-emojify-mode))
(use-package writegood-mode
  :ensure t)

Code improvements

(use-package auto-complete
  :ensure t
  :init
  (progn
    (ac-config-default)
    (global-auto-complete-mode t)
  ))
(use-package yasnippet
  :ensure t)

Org plugins

(use-package org-bullets)
(use-package ox-asciidoc
  :ensure t)

Here we can also just enable org bullets for org files.

(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

Doom Modeline

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1))

Configurations

General configurations

Set short answers

(setq use-short-answers t)

Disable backup files

(setq make-backup-files nil)

Disabling bars

(tool-bar-mode -1)
(menu-bar-mode -1)
(tab-bar-mode -1)
(scroll-bar-mode -1)

Setting Font and themes

(setq doom-themes-enable-bold t
	doom-themes-enable-italic t)
(load-theme 'dracula t)
(add-to-list 'default-frame-alist '(font . "Inconsolata-17"))

Setting warning level

(setq warning-minimum-level :emergency)

Line numbers

(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))
(setq display-line-numbers-type 'relative)

Load dashboard with emacsclient

(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))

Set temp directory

(setq temporary-file-directory "~/.tmp/")
 (setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))

Here we will also set auto save to nil

(setq auto-save-default nil)

Yasnippet and treesitter

(yas-global-mode 1)
(tree-sitter-require 'cpp)
(tree-sitter-require 'c)
(tree-sitter-require 'haskell)
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)

Vim like insert TABs

(define-key evil-insert-state-map (kbd "TAB") 'tab-to-tab-stop)

Tabs

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

General Keybinds

C-c remap

I personally like doing this, though it will break some stuff, so you probably shouldn’t use it

(define-key evil-insert-state-map (kbd "C-c") 'evil-normal-state)
(define-key evil-normal-state-map (kbd "C-c") 'evil-normal-state)
(define-key key-translation-map (kbd "C-c C-c") (kbd "C-g"))

SPC commands

These are just some doom emacs keybinds I like having

(nvmap :prefix "SPC"
  "t n"   '(neotree-toggle :which-key "Toggle neotree file viewer")
  "d n"   '(neotree-dir :which-key "Open directory in neotree"))
(nvmap :keymaps 'override :prefix "SPC"
  "SPC"   '(counsel-M-x :which-key "M-x")
  "."     '(find-file :which-key "Find file") 
  "c c"   '(compile :which-key "Compile")
  "f f"   '(dirvish :which-key "Dirvish")
  "c C"   '(recompile :which-key "Recompile")
  "h r r" '((lambda () (interactive) (load-file "~/.emacs.d/init.el")) :which-key "Reload emacs config")
  "t t"   '(toggle-truncate-lines :which-key "Toggle truncate lines"))
(nvmap :prefix "SPC"
  "b b"   '(ibuffer :which-key "Ibuffer")
  "b c"   '(clone-indirect-buffer-other-window :which-key "Clone indirect buffer other window")
  "b k"   '(kill-current-buffer :which-key "Kill current buffer")
  "b n"   '(next-buffer :which-key "Next buffer")
  "b p"   '(previous-buffer :which-key "Previous buffer")
  "b B"   '(ibuffer-list-buffers :which-key "Ibuffer list buffers")
  "b K"   '(kill-buffer :which-key "Kill buffer")
  "r f"   '(dashboard-refresh-buffer :which-key "Refresh buffer"))

Neotree keybinds

;; just for neotree
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "SPC") '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 "n") 'neotree-next-line)
(evil-define-key 'normal neotree-mode-map (kbd "p") 'neotree-previous-line)
(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)
(evil-define-key 'normal neotree-mode-map (kbd "w") 'neotree-create-node)

Evil mode undo/redo

(define-key evil-normal-state-map "u" 'evil-undo)
(define-key evil-normal-state-map (kbd "C-r") 'undo-tree-redo)

Doom modeline config

(setq doom-modeline-time-icon t)
(setq doom-modeline-icon t)
(setq doom-modeline-buffer-file-name-style 'auto)
(setq doom-modeline-buffer-name t)
(setq doom-modeline-indent-info nil)
(setq doom-modeline-buffer-encoding t)
(setq doom-modeline-enable-word-count nil)

Custom functions

Disable quit with evil mode :q and :wq

(defun save-and-kill-this-buffer()
  "Quits the buffer"
  (interactive)
  (save-buffer)
  (kill-current-buffer))
(defun quit-buffer()
  "Quits the buffer"
  (interactive)
  (kill-current-buffer))

And here are the keybinds

(evil-ex-define-cmd "wq" 'save-and-kill-this-buffer)
(evil-ex-define-cmd "q" 'quit-buffer)

Autopairs

(defun electric-pair ()
  "Autoconnects a given char with another"
  (interactive)
  (if (eolp) (let (parens-require-spaces) (insert-pair)) (self-insert-command 1)))

And here are the hooks we define.

(add-hook 'c-mode-hook
          (lambda ()
            (define-key c-mode-map "\"" 'electric-pair)
            (define-key c-mode-map "\'" 'electric-pair)
            (define-key c-mode-map "(" 'electric-pair)
            (define-key c-mode-map "[" 'electric-pair)
            (define-key c-mode-map "{" 'electric-pair)))
(add-hook 'lisp-mode-hook
          (lambda ()
            (define-key lisp-mode-map "\"" 'electric-pair)
            (define-key lisp-mode-map "\'" 'electric-pair)
            (define-key lisp-mode-map "(" 'electric-pair)
            (define-key lisp-mode-map "[" 'electric-pair)
            (define-key lisp-mode-map "{" 'electric-pair)))
(add-hook 'scheme-mode-hook
          (lambda ()
            (define-key scheme-mode-map "\"" 'electric-pair)
            (define-key scheme-mode-map "\'" 'electric-pair)
            (define-key scheme-mode-map "(" 'electric-pair)
            (define-key scheme-mode-map "[" 'electric-pair)
            (define-key scheme-mode-map "{" 'electric-pair)))
;;(add-hook 'haskell-mode-hook
 ;;         (lambda ()
  ;;          (define-key haskell-mode-map "\"" 'electric-pair)
   ;;         (define-key haskell-mode-map "\'" 'electric-pair)
    ;;        (define-key haskell-mode-map "(" 'electric-pair)
     ;;       (define-key haskell-mode-map "[" 'electric-pair)
      ;;      (define-key haskell-mode-map "{" 'electric-pair)))

Garbage Collection

(defun my-gc-function ()
  (setq gc-cons-threshold 800000)
  (defun my-gc-function ()
    (garbage-collect)))

And here is the hook for it.

(add-hook 'focus-out-hook #'my-gc-function)

Org Configurations

Writing Configuration

(add-hook 'org-mode-hook 'flyspell-mode)
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook 'writegood-mode)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published