Skip to content

ujwacha/emacs_config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs Configuration

Emacs Config

This is my configuration of emacs The things work poroperly

Initial UI features

these are the initial UI features, like removing the scroll bar, tool bar etc. Basically to make it look more GNU/Linuxy

remove the startup page

(setq inhibit-startup-message t)

my own confis to remove menu bar , scroll bar and tool bar

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

Make emacs transparent

;; set transparency
;; (set-frame-parameter (selected-frame) 'alpha '(85 85))
;; (add-to-list 'default-frame-alist '(alpha 85 85))

Font configuration

this is where font is configured

;; ;;;; fonts and stuff

(defvar runemacs/default-font-size 150)

;;(set-face-attribute 'default nil :font "monospace" :height runemacs/default-font-size)

;; Set the fixed pitch face
(set-face-attribute 'default nil :font "Hack Nerd Font" :height 150)
;;(set-face-attribute 'fixed-pitch nil :font "Hack Nerd Font" :height 150)

;; Set the variable pitch face
(set-face-attribute 'variable-pitch nil :font "Cantarell" :height 120 :weight 'regular)

Use Package

Here use package is configured to install and use packages from repos like melpa

setting up melpa elpa and use-package

Initialize package sources

(require 'package)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("org" . "https://orgmode.org/elpa/")
                         ("elpa" . "https://elpa.gnu.org/packages/")))

(package-initialize)
(unless package-archive-contents
 (package-refresh-contents))


;; Initialize use-package on non-Linux platforms
(unless (package-installed-p 'use-package)
   (package-install 'use-package))

(require 'use-package)
(setq use-package-always-ensure t)

use the ivy package

(use-package ivy
  :diminish
  :bind (("C-s" . swiper)
         :map ivy-minibuffer-map
         ("TAB" . ivy-alt-done)	
         ("C-l" . ivy-alt-done)
         ("C-j" . ivy-next-line)
         ("C-k" . ivy-previous-line)
         :map ivy-switch-buffer-map
         ("C-k" . ivy-previous-line)
         ("C-l" . ivy-done)
         ("C-d" . ivy-switch-buffer-kill)
         :map ivy-reverse-i-search-map
         ("C-k" . ivy-previous-line)
         ("C-d" . ivy-reverse-i-search-kill))
  :config
  (ivy-mode 1))

Swiper

(use-package swiper :ensure t)

php-mode

(use-package php-mode :ensure t)

doom-modeline

use doom-modeline thingy

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1)
;;  :custom ((doom-modeline-height 25))
  )

All the icons

all the icons for the icons

(use-package all-the-icons
  :ensure t)

other themes

some other themes than doom themes

 ;; (use-package intellij-theme)
  ;;(use-package kaolin-themes)
  ;;(use-package zenburn-theme)
;;  (use-package spacemacs-theme)
;; (use-package ewal-spacemacs-themes)
(use-package ubuntu-theme)

doom themes

doom themes to make emacs look sexy NOTE: the themes are loaded here so make sure to install themes above here

        (use-package doom-themes
          :ensure t
          :config
          ;; Global settings (defaults)
          (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
                doom-themes-enable-italic t) ; if nil, italics is universally disabled
      ;;    (load-theme ' spacemacs-dark t)
         ;; (load-theme ' kaolin-dark t)
        (load-theme 'doom-Iosvkem t)
;;        (load-theme 'ubuntu t)
  ;;        (load-theme 'doom-solarized-dark t)


          ;; Enable flashing mode-line on errors
          (doom-themes-visual-bell-config)
          ;; Enable custom neotree theme (all-the-icons must be installed!)
          (doom-themes-neotree-config)
          ;; or for treemacs users
          (setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
          (doom-themes-treemacs-config)
          ;; Corrects (and improves) org-mode's native fontification.
          (doom-themes-org-config)
          )

Rainbow delemeters

;;(use-package rainbow-delimiters
;;  :hook (prog-mode , rainbow-delimiters-mode ))

which key mode

(use-package which-key
  :init (which-key-mode)
  :diminish which-key-mode
  :config
  (setq which-key-idle-delay 0.3))

ivy rich mode

(use-package ivy-rich
 :init (ivy-rich-mode 1))

properly setting up counsel

(use-package counsel
  :bind (("M-x" . counsel-M-x)
;;       	 ("C-x b" . counsel-ibuffer)
       	 ("C-x b" . counsel-switch-buffer)
       	 ("C-x v" . counsel-describe-variable)
       	 ("C-x f" . counsel-describe-function)
	 ("C-x C-f" . counsel-find-file)
	 :map minibuffer-local-map
	  ("C-r" . 'counsel-minibuffer-history)))

pdf-tools

make emacs a pdf viewer

;;  (use-package pdf-tools
;;    :ensure t
;;    :defer t
;;    :commands (pdf-view-mode pdf-tools-install)
;;    :mode ("\\.[pP][dD][fF]\\" . pdf-view-mode)
;;    :config (pdf-tools-install)
;;    (define-pdf-cache-function pagelabels)
;;    :hook ((pdf-view-mode-hook . (lambda () (display-line-numbers-mode -q)))
;;           (pdf-view-mode-hook . pdf-tools-enable-minor-modes)))

Howdoyou

this package lets you search stack overflow and it’s sister sites and get your results back in org mode. This Package seems to be really cool

(use-package howdoyou
  :ensure t)

Evil Mode configuration

Evil mode lets you run vim keybindings inside of emacs, best of both worlds Everything here is for evil mode, make sure this is good

(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil) ;; initiall nil
  (setq evil-want-C-u-scroll t)
  (setq evil-want-C-i-jump nil) ;; initially nil
;;  (setq evil-respect-visual-line-mode t)
  :config
  (evil-set-undo-system 'undo-tree) 
  (evil-mode 1)  
  (evil-set-initial-state 'messages-buffer-mode 'normal)
  (evil-set-initial-state 'dashboard-mode 'normal))
;; yay goddamit , it is vim now . finally , i am back home .
;; das ist sehr gut damn vim ist uber alles editors 
;; now for evil collection

(use-package evil-collection
  :after evil
  :config
  (evil-collection-init))

;; undo tree to make C-r in evil mode redo
(use-package undo-tree
  :ensure t
  :config
  (global-undo-tree-mode 1))

auto complete

;; auto complete and stuff
(use-package auto-complete
  :ensure t
;;  :config
;;  (require 'auto-complete-config)
;;;   (ac-config-default)
  )

company mode

(use-package company
  :after lsp-mode
  :hook (lsp-mode . company-mode)
  :bind (:map company-active-map
         ("<tab>" . company-complete-selection))
        (:map lsp-mode-map
         ("<tab>" . company-indent-or-complete-common))
	:custom
  (company-minimum-prefix-length 1)
  (company-idle-delay 0.1))

(use-package company-box
  :hook (company-mode . company-box-mode))

yasnepet

(use-package yasnippet
  :ensure t
  :config
  (yas-global-mode 1)
  (add-hook 'prog-mode-hook 'yas-minor-mode)
  )

virtual terminal

A vertual terminal for emacs, I find it better than eshell

(use-package vterm
 :ensure t)

becom mode

it looks kinda cool

(use-package beacon)

use beacon mode, comment if you think it’s annoyingj

;;  (beacon-mode 1)

neotree to flex on vim users

(use-package neotree
  :ensure t)

Helpful

helpful because system crafters said it was cool

(use-package helpful
  :custom
  (counsel-describe-function-function #'helpful-callable)
  (counsel-describe-variable-function #'helpful-variable)
  :bind
  ([remap describe-function] . counsel-describe-function)
  ([remap describe-command] . helpful-command)
  ([remap describe-variable] . counsel-describe-variable)
  ([remap describe-key] . helpful-key))

rainbow delimiters

(use-package rainbow-delimiters
  :hook (prog-mode . rainbow-delimiters-mode))

markdown mode

(use-package markdown-mode 
  :ensure t)

simple-httpd

for opening a web server at a spesefic directory because it is easier for me to make websites and also because i am too lazy to configure apache and stuff

(use-package simple-httpd
  :ensure t)

Elfeed

this package is used to read RSS feeds

;; Configure Elfeed
(use-package elfeed
  :ensure t
  :config
  (setq elfeed-db-directory (expand-file-name "elfeed" user-emacs-directory)
        elfeed-show-entry-switch 'display-buffer)

  (setq elfeed-search-filter "@6-months-ago +unread -lowy")
  )

use some RSS links

(setq elfeed-feeds (quote(
("https://archlinux.org/feeds/news/" linux arch news official)
)))
;; you can put your subs here like this

The way to get rss feed of a youtube channel NOTE: do not use this function directly in the elfeed-feeds list. This function has to first go to the internet and get the whole page and this function is not multithreaded. This function exists for me to get the RSS feeds of the youtube channels. This function just runs a shell command. The shell dependencies are curl and grep. They are available in almost all GNU/Linux systems. IDK and I dont care about other systems

this function is defined below the elfeed-feeds list so that nobody uses this function within that list. This will make emacs really slow as it needs to connect to the internet and fetch it. Don’t directly put it in the list above.

(defun my/get-youtube-channel-rss-feed (link-to-channel-homepage)
  "this takes the link to channel home page and spits out the rss feed"
  (setq my-youtube-command (concat "curl -s " link-to-channel-homepage " | grep -oP '(?<=title\=\"RSS\" href\=\").*?(?=\")' "))
  (setq my-shell-output
        (substring 
         (shell-command-to-string my-youtube-command )
         0 -1))
  my-shell-output
  )

disable evil mode for all elfeed major modes

more mode hooks can be added when we find them

;; (dolist (mode '(elfeed-show-mode-hook
;;                 elfeed-search-mode-hook))
;;   (add-hook mode (lambda () (turn-off-evil-mode))))

Elfeed functions

play a video in mpv if the link of the opened elfeed is a video that can be played by mpv, this function can be used to directly play it.

(defun my/elfeed-open-link-in-mpv()
  "open link in elfeed using mpv"
  (interactive)
  (let ((link (elfeed-entry-link elfeed-show-entry)))
    (when link
      (message "Sent to mpv: %s" link)
      (async-shell-command (concat "mpv \"" link "\"")))))

make evil and elfeed play together

this is copy pasted from the internet, the entire comment is following:

I would suggest using evil-motion-state for Elfeed instead of normal state – Elfeed buffers are read-only, so what you are really doing is moving around. Evil uses this approach for many other read-only buffers, for example help-mode. So:

(add-to-list 'evil-motion-state-modes 'elfeed-search-mode)
(add-to-list 'evil-motion-state-modes 'elfeed-show-mode)

You can rebind some keys to get back important Elfeed functionality. Some examples:

(evil-define-key* 'motion elfeed-search-mode-map
  "gb" #'elfeed-search-browse-url
  "gr" #'elfeed-search-update--force
  "gR" #'elfeed-search-fetch)

(evil-define-key* 'motion elfeed-show-mode-map
  "gb" #'elfeed-show-visit
  "gy" #'my/elfeed-open-link-in-mpv
  "gj" #'elfeed-show-next
  "gk" #'elfeed-show-prev)

(I assume you are not using Spacemacs and don’t have access to evilify-map, as suggested by another answer.)

projectile

projectile to move through projects blazingly fast

(use-package projectile
  :diminish projectile-mode
  :config (projectile-mode)
  :custom ((projectile-completion-system 'ivy))
  :bind-keymap
  ("C-c p" . projectile-command-map)
  :init
  ;; ;; NOTE: Set this to the folder where you keep your Git repos!
  ;; (when (file-directory-p "~/Projects/Code")
  ;;   (setq projectile-project-search-path '("~/Projects/Code")))
  ;; (setq projectile-switch-project-action #'projectile-dired)
)

(use-package counsel-projectile
  :config (counsel-projectile-mode))

web mode

while writing html, i guess

(use-package web-mode
  :ensure t)

for javascript and typescript

this is for javascript, even though lsp just does the job anyway

(use-package typescript-mode
  :mode "\\.ts\\'"
  :hook (typescript-mode . lsp-deferred)
  :config
  (setq typescript-indent-level 2))

flycheck

it checks for errors blazingly fast

(use-package flycheck
  :ensure t)

magit

magit is a git client, people say it’s really good so i’m planning to test it out

(use-package magit
  :ensure t)

gnuplot mode

this package is here just to support ploting in org mode, IDK how to use this package indipendently right now

(use-package gnuplot-mode)
(use-package gnuplot)

rainbow-mode

(use-package rainbow-mode
  :ensure t
  :init (rainbow-mode 1))

dashboard

install dashboard

(use-package dashboard
  :ensure t
  :config
  (dashboard-setup-startup-hook))

customize dashboard

First make things be in the centre

(setq dashboard-center-content t)

enable icons

(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)

using the dashboard mode hook

  • set keybinding to refresh when pressing C-c C-r key in dashboard
  • refresh once on startup to show icons ( there seems to be a bug here )
(add-hook 'dashboard-mode-hook (lambda ()
                                 (local-set-key (kbd "C-c C-r ") 'dashboard-refresh-buffer)))

make initial buffer for emacs client the dashboard

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

all the icons dired

all the icons for dired

(use-package all-the-icons-dired
  :ensure t
  :hook (dired-mode . all-the-icons-dired-mode)
  )

for LaTeX

(use-package auctex
  :ensure t
  :defer t
  :hook (LaTeX-mode .
                    (lambda ()
                      (push (list 'output-pdf "Zathura")
                            TeX-view-program-selection))))

LSP

LSP is Language Server Protocol, this is what gives IDE features to Emacs

lsp mode

initual lsp mode setup function

(defun lsp-mode-setup ()
  (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))
  (lsp-headerline-breadcrumb-mode))

Install lsp-mode and configure it using use-package

(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :hook (lsp-mode . lsp-mode-setup)
  :init
  (setq lsp-keymap-prefix "C-c l")  ;; Or 'C-l', 's-l'
  :config
  (lsp-enable-which-key-integration t))

lsp ui

IDK what it does, but it seems like it makes lsp look better

(use-package lsp-ui
  :hook (lsp-mode . lsp-ui-mode)
  :custom
  (lsp-ui-doc-position 'bottom))

lsp treemacs

LSP treemacs, IDK what it does, I just copied lol

(use-package lsp-treemacs
  :ensure t
  :after lsp)

lsp ivy

I copied this as well, IDK what this does

(use-package lsp-ivy
  :ensure t)

ORG configuration

this is for org mode, the greatest markdown format, i guess

setting initial stuff up

IDK how the hell this works, i just copied this. I just wish this works

(defun efs/org-mode-setup ()
  (org-indent-mode)
  (variable-pitch-mode 1)
  (visual-line-mode 1))



(defun efs/org-font-setup ()
  ;; Replace list hyphen with dot
  (font-lock-add-keywords 'org-mode
                          '(("^ *\\([-]\\) "
                             (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))

  ;; Set faces for heading levels
  (dolist (face '((org-level-1 . 1.2)
                  (org-level-2 . 1.1)
                  (org-level-3 . 1.05)
                  (org-level-4 . 1.0)
                  (org-level-5 . 1.1)
                  (org-level-6 . 1.1)
                  (org-level-7 . 1.1)
                  (org-level-8 . 1.1)))
    (set-face-attribute (car face) nil :font "Hack" :weight 'regular :height (cdr face)))



  ;; Ensure that anything that should be fixed-pitch in Org files appears that way
  (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
  (set-face-attribute 'org-code nil   :inherit '(shadow fixed-pitch))
  (set-face-attribute 'org-table nil   :inherit '(shadow fixed-pitch))
  (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
  (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
  (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
  (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch))

Actually install the packages org and org-bullets

(use-package org
  :hook (org-mode . efs/org-mode-setup)
  :config
  (setq org-ellipsis "")
  (efs/org-font-setup))


(use-package org-bullets
  :after org
  :hook (org-mode . org-bullets-mode)
  ;; :custom
  ;;  (org-bullets-bullet-list '("◉" "○" "●" "○" "●" "○" "●"))
  )

configure org bullets

(defun efs/org-mode-visual-fill ()
  (setq visual-fill-column-width 100
        visual-fill-column-center-text t)
  (visual-fill-column-mode 1))

(use-package visual-fill-column
  :hook (org-mode . efs/org-mode-visual-fill))

org pdf

;;  (use-package org-pdftools
 ;;   :hook (org-load-hook . org-pdftools-setup-link))

Org reveal for slideshow presentations

(use-package ox-reveal
  :ensure t)

Add a function to set size for latex math equation size

this function is an interactive function that makes setting the size of math equations more quality of life friendly. Now you won’t have to go to that file where you stored the code every time you decide to write math equations

(defun my/set_latex_math_size (size)
  "set the required size of your math equations"
    (interactive "sSize:")
    (setq org-format-latex-options (plist-put org-format-latex-options :scale (string-to-number size)))
    (message (concat "size is set to: " size)))

The Rust Programming Language

while writing this, rust is my favouraite programming language. Even though LSP does most of the job, i still keep some more great rust features just because i like rust

flycheck for rust

checks for errors in the buffer

(use-package flycheck-rust
  :ensure t)

some random shit to make it work better

yes

;; (defun rk/rustic-mode-hook ()
;;   ;; so that run C-c C-c C-r works without having to confirm, but don't try to
;;   ;; save rust buffers that are not file visiting. Once
;;   ;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
;;   ;; no longer be necessary.
;;   (when buffer-file-name
;;     (setq-local buffer-save-without-query t)))

rustic

more advanced rust-mode which has some great features and added keybindings

(use-package rustic
  :ensure
  :bind (:map rustic-mode-map
              ("M-j" . lsp-ui-imenu)
              ("M-?" . lsp-find-references)
              ("C-c C-c l" . flycheck-list-errors)
              ("C-c C-c a" . lsp-execute-code-action)
              ("C-c C-c r" . lsp-rename)
              ("C-c C-c q" . lsp-workspace-restart)
              ("C-c C-c Q" . lsp-workspace-shutdown)
              ("C-c C-c s" . lsp-rust-analyzer-status))
  :config
  ;; uncomment for less flashiness
  ;; (setq lsp-eldoc-hook nil)
  ;; (setq lsp-enable-symbol-highlighting nil)
  ;; (setq lsp-signature-auto-activate nil)
  ;; comment to disable rustfmt on save
  (setq rustic-format-on-save t)
  ;;(add-hook 'rustic-mode-hook 'lsp)
  ;;(add-hook 'rustic-mode-hook 'electric-part-local-mode)
  )

User Defined

Here I keep my user defined functions user defined functions (starts with my/)

to get the ide layout like vscode with neotree and stuff

(defun my/ide()
  "Get a modern IDE layout"
  (interactive)
  (evil-window-split)
  (evil-window-down 1)
  (evil-window-decrease-height 10)
  (vterm)
  (neotree)
  (evil-window-right 1)
  (lsp)
  )

a keybinding for howdoyou

(global-set-key (kbd "C-h j") 'howdoyou-query)

run gcc for c mode

make a keybinding to run gcc to the opened file and run a.out

(defun my/run-the-c-code()
  "run the c code via gcc"
  (interactive)
  (eshell-command (concat "gcc " (buffer-file-name) " && ./a.out"))
  )
(defun my/make()
  "run the c code via gcc"
  (interactive)
  (eshell-command "make")
  )


(add-hook 'c-mode-common-hook (lambda()
                                (local-set-key (kbd "C-c C-r C-c") 'my/run-the-c-code)
                                (local-set-key (kbd "C-c C-r C-m") 'my/make)
                                ))
;;(add-hook 'c-mode-common-hook (local-set-key (kbd "C-c C-r") (eshell-command (concat "gcc " (buffer-file-name) " && ./a.out") )))

run shell scripts after making it executable

repurposed the c mode keybinding to run shell scripts

(defun my/run-the-bash-code()
  "run the bash code, NOTE: it gives executable permissions to the file (oviously)"
  (interactive)
  (eshell-command (concat "chmod +x " (buffer-file-name) " && bash " (buffer-file-name)))
  )
(add-hook 'sh-mode-hook (lambda() (local-set-key (kbd "C-c C-r")
                                                 'my/run-the-bash-code
                                                 )))

bracket completion in prog mode

Use electric pair mode or something in prog mode hook NOTE: Does not work rignt now, so not conna care

(add-hook 'prog-mode-hook (lambda () (electric-pair-local-mode 1)))

launch company mode every time in lisp mode

(add-hook 'emacs-lisp-mode-hook (lambda ()
                                  (company-mode 1)))

put the cursor to the next <+_+> and replace it

this is inspired from luke smith, it’s in my opinion pretty cool

first, the function my/goto-thing is defined

(defun my/goto-thing ()
  "put cursor to the string <+_+> and replace it"
  (interactive)
  (if (search-forward "<+_+>") (delete-backward-char 5) (message "pattern <+_+> not found"))
  )

then, keybinding for it is set to C-c C-SPC

(global-set-key (kbd "C-c C-SPC") 'my/goto-thing)

Insert math from within latex in emacs org mode

this is so that i get better keybindings when working with latex in org mode. the trick was to open up a temp latex buffer and use keybinding from there and finally after I’m done there, pasting everything from there to org

first we need the function to copy all of the buffer and kill it

(defun my/copy-all-and-kill()
    (interactive)
    (kill-region 1 (buffer-size))
    (kill-buffer-and-window)
  )

then, we need a function to open the latex buffer and set a keybinding to copy and kill

(defun my/open-latex-buffer ()
  (interactive)
  (split-window)
  (switch-to-buffer "*org-latex-thingy*")
  (latex-mode)
  (local-set-key (kbd "C-C C-;") 'my/copy-all-and-kill ))

then we set a hook to put a keybinding in org mode to start the buffer

(add-hook 'org-mode-hook (lambda()
                           (local-set-key (kbd "C-c C-.") 'my/open-latex-buffer)))

other random stuff

allow these mentioned languages to compile and give result from org source blocks

(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (C . t)
   (emacs-lisp . t)
   (python . t)
   )
 )
;; custom keybindings

End Stuff

Start a org document scratch buffer

This is just me running one command after another to get what I want, i guess this is not very efficient Gonna give up for now, It didn’t work properly

;; (switch-to-buffer "orgscratch")
;; (org-mode)
;; (text-scale-adjust 2)
;; (display-line-numbers-mode 0)
;; (insert "* Notes")
;; (switch-to-buffer "*scratch*")

About

This is my config of emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published