Emacs-Configuration/config.org

430 lines
11 KiB
Org Mode
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

* Bloxie's Emacs Configuration
** By Curt Spark / Bloxiebird.
* Introduction
Welcome to my Emacs configuration!
* Config
** Appearance
*** Remove Tool Bar
#+BEGIN_SRC emacs-lisp
(tool-bar-mode -1)
#+END_SRC
*** Remove Menu Bar
#+BEGIN_SRC emacs-lisp
(menu-bar-mode -1)
#+END_SRC
*** Remove Scroll Bar
#+BEGIN_SRC emacs-lisp
(scroll-bar-mode -1)
#+END_SRC
*** Display Line Numbers
#+BEGIN_SRC emacs-lisp
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
#+END_SRC
*** Modern Fringes
#+BEGIN_SRC emacs-lisp
(use-package modern-fringes
:ensure t
:init
(modern-fringes-invert-arrows))
#+END_SRC
*** Theming
#+BEGIN_SRC emacs-lisp
(use-package dracula-theme
:ensure t
:init
(load-theme 'dracula t))
#+END_SRC
*** All The Icons
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons
:ensure t)
#+END_SRC
All The Icons for Ivy/Counsel
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons-ivy
:ensure t
:init
(all-the-icons-ivy-setup))
#+END_SRC
*** Mode Line
**** Spaceline
#+BEGIN_SRC emacs-lisp
(use-package spaceline
:ensure t
:config
(require 'spaceline-config)
(setq powerline-default-separator (quote arrow))
(spaceline-spacemacs-theme))
#+END_SRC
Display the time on the Mode Line, this is more useful for EXWM.
#+BEGIN_SRC emacs-lisp
(setq display-time-default-load-average nil)
(display-time-mode t)
#+END_SRC
**** Diminish
With Diminish you can optionally remove some of the names of the modes in the Mode Line.
#+BEGIN_SRC emacs-lisp
(use-package diminish
:ensure t)
#+END_SRC
*** Emacs Dashboard
Install the Emacs Dashboard :
#+BEGIN_SRC emacs-lisp
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
#+END_SRC
Emacs Dashboard Config :
#+BEGIN_SRC emacs-lisp
;; Set the title
(setq dashboard-banner-logo-title "Welcome to Bloxie's Emacs!")
;; Set the banner
(setq dashboard-startup-banner 'logo)
;; Value can be
;; 'official which displays the official emacs logo
;; 'logo which displays an alternative emacs logo
;; 1, 2 or 3 which displays one of the text banners
;; "path/to/your/image.png" which displays whatever image you would prefer
;; Content is not centered by default. To center, set
(setq dashboard-center-content t)
;; To disable shortcut "jump" indicators for each section, set
(setq dashboard-show-shortcuts nil)
;;To customize which widgets are displayed, you can use the following snippet
(setq dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
;; To show agenda for the upcoming seven days set the variable show-week-agenda-p to t.
;; (setq show-week-agenda-p t)
;; Note that setting list-size for the agenda list is intentionally ignored; all agenda items for the current day will be displayed.
;; To customize which categories from the agenda items should be visible in the dashboard set the dashboard-org-agenda-categories to the list of categories you need.
;; (setq dashboard-org-agenda-categories '("Tasks" "Appointments"))
;; To add icons to the widget headings and their items:
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
;; To show navigator below the banner:
(setq dashboard-set-navigator t)
;; To customize the buttons of the navigator like this:
;; Format: "(icon title help action face prefix suffix)"
(setq dashboard-navigator-buttons
`(;; line1
((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
"Homepage"
"Browse homepage"
(lambda (&rest _) (browse-url "https://gitlab.com/bloxiebird/linux-emacs-configuration")))
("" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning)
("?" "" "?/h" #'show-help nil "<" ">"))
))
#+END_SRC
** Dynamic Window Tiling
*** Edwina
Edwina is a dynamic window manager for Emacs.
It automatically arranges your Emacs panes (called “windows” in Emacs parlance) into predefined layouts, dwm-style.
+BEGIN_SRC emacs-lisp
(use-package edwina
:ensure t
:config
(setq display-buffer-base-action '(display-buffer-below-selected))
(edwina-setup-dwm-keys)
(edwina-mode 1))
+END_SRC
*** Golden Ratio
+BEGIN_SRC emacs-lisp
(use-package golden-ratio
:ensure t
:init
(golden-ratio-mode 1))
+END_SRC
** Custom
*** Resizing Buffers
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "<C-up>") 'shrink-window)
(global-set-key (kbd "<C-down>") 'enlarge-window)
(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)
(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)
#+END_SRC
*** Fullscreen Function
#+BEGIN_SRC emacs-lisp
(defun fullscreen (&optional f)
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
#+END_SRC
Call Function on Startup
#+BEGIN_SRC emacs-lisp
(fullscreen)
#+END_SRC
** Evil Mode
#+BEGIN_SRC emacs-lisp
(use-package evil
:ensure t
:init
(evil-mode 1))
#+END_SRC
** Org Mode
*** Simple Org Mode Preview in HTML
#+BEGIN_SRC emacs-lisp
(defun update-other-buffer ()
(interactive)
(other-window 1)
(revert-buffer nil t)
(other-window -1))
(defun org-compile-beamer-and-update-other-buffer ()
"Has as a premise that it's run from an org-mode buffer and the
other buffer already has the PDF open"
(interactive)
(org-beamer-export-to-pdf)
(update-other-buffer))
(defun org-compile-latex-and-update-other-buffer ()
"Has as a premise that it's run from an org-mode buffer and the
other buffer already has the PDF open"
(interactive)
(org-latex-export-to-pdf)
(update-other-buffer))
(define-key org-mode-map (kbd "C-c rl") 'org-compile-latex-and-update-other-buffer)
(define-key org-mode-map (kbd "C-c rb") 'org-compile-beamer-and-update-other-buffer)
#+END_SRC
*** LateX Preview
#+BEGIN_SRC emacs-lisp
(use-package org-fragtog
:ensure t
:init
(add-hook 'org-mode-hook 'org-fragtog-mode))
#+END_SRC
*** Org Bullets
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
#+END_SRC
*** Enable Indent Mode
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'org-indent-mode)
#+END_SRC
*** Enable Beamer Support
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'org-beamer-mode)
#+END_SRC
** Agenda
Set Agenda Directory :
#+BEGIN_SRC emacs-lisp
(setq org-agenda-files (quote("~/.emacs.d/agenda.org")))
#+END_SRC
Calendar/Diary integration :
#+BEGIN_SRC emacs-lisp
(setq org-agenda-include-diary t)
#+END_SRC
** Projectile
Install Projectile:
#+BEGIN_SRC emacs-lisp
(use-package projectile
:ensure t
:init
(projectile-mode))
#+END_SRC
** Auto Completion
*** Ivy
#+BEGIN_SRC emacs-lisp
(use-package ivy
:ensure t
:init
(ivy-mode 1)
:bind
("C-s" . swiper))
#+END_SRC
Ivy Configuration :
#+BEGIN_SRC emacs-lisp
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
#+END_SRC
*** Counsel
#+BEGIN_SRC emacs-lisp
(use-package counsel
:ensure t)
#+END_SRC
Counsel for Projectile
#+BEGIN_SRC emacs-lisp
(use-package counsel-projectile
:ensure t
:init
(counsel-projectile-mode))
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
#+END_SRC
*** Company
**** Company Base
#+BEGIN_SRC emacs-lisp
(use-package company
:ensure t
:init
(add-hook 'prog-mode-hook 'company-mode))
#+END_SRC
Configuration :
#+BEGIN_SRC emacs-lisp
; No delay in showing suggestions.
(setq company-idle-delay 0)
; Show suggestions after entering one character.
(setq company-minimum-prefix-length 1)
; Wrap around when suggestions reach bottom.
(setq company-selection-wrap-around t)
; Use tab key to cycle through suggestions.
; ('tng' means 'tab and go')
(company-tng-configure-default)
#+END_SRC
**** Company Quickhelp
#+BEGIN_SRC emacs-lisp
(use-package company-quickhelp
:ensure t
:init
(company-quickhelp-mode))
#+END_SRC
*** Which Key
#+BEGIN_SRC emacs-lisp
(use-package which-key
:ensure t
:init
(which-key-mode))
#+END_SRC
** LSP Mode
#+BEGIN_SRC emacs-lisp
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "s-l")
(use-package lsp-mode
:ensure t
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(prog-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
;; optionally
(use-package lsp-ui :commands lsp-ui-mode
:ensure t)
(use-package company-lsp :commands company-lsp
:ensure t)
;; if you are helm user
;;(use-package helm-lsp :commands helm-lsp-workspace-symbol)
;; if you are ivy user
(use-package lsp-ivy :commands lsp-ivy-workspace-symbol
:ensure t)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list
:ensure t)
;; optionally if you want to use debugger
(use-package dap-mode
:ensure t)
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
#+END_SRC
** Spell Correction
*** Flyspell Correct Ivy
+BEGIN_SRC emacs-lisp
(use-package flyspell-correct-ivy
:ensure t
:bind ("C-;" . flyspell-correct-wrapper)
:init
(setq flyspell-correct-interface #'flyspell-correct-ivy)
(add-hook 'org-mode-hook 'flyspell-mode)
(setq-default ispell-program-name "aspell"))
+END_SRC
** Multiple Cursors
#+BEGIN_SRC emacs-lisp
(use-package multiple-cursors
:ensure t
:bind
("C-c m" . 'mc/mark-next-like-this)
:bind
("C-c C-m" . 'mc/mark-all-like-this))
#+END_SRC
** Expand Region
Auto selects a region of text/code.
#+BEGIN_SRC emacs-lisp
(use-package expand-region
:ensure t
:bind
("C-c e" . 'er/expand-region))
#+END_SRC
** Rainbow Delimiters
This Minor Mode will mark pairs of brackets with colours.
#+BEGIN_SRC emacs-lisp
(use-package rainbow-delimiters
:ensure t)
#+END_SRC
Set Minor Mode as Global :
#+BEGIN_SRC emacs-lisp
(define-globalized-minor-mode global-rainbow-delimiters-mode rainbow-delimiters-mode
(lambda () (rainbow-delimiters-mode 1)))
(global-rainbow-delimiters-mode 1)
#+END_SRC
** Rainbow Mode
This Minor Mode will highlight RGB/HEX values with their respective colours.
#+BEGIN_SRC emacs-lisp
(use-package rainbow-mode
:ensure t)
#+END_SRC
Set Minor Mode as Global :
#+BEGIN_SRC emacs-lisp
(define-globalized-minor-mode global-rainbow-mode rainbow-mode
(lambda () (rainbow-mode 1)))
(global-rainbow-mode 1)
#+END_SRC
** Autosave
#+BEGIN_SRC emacs-lisp
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
#+END_SRC
** Global Revert Mode
#+BEGIN_SRC emacs-lisp
(global-auto-revert-mode t)
#+END_SRC
** Wind Move
Windmove is built into Emacs. It lets you move point from window to window using Shift and the arrow keys. This is easier to type than C-x o when there are multiple windows open.
#+BEGIN_SRC emacs-lisp
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
#+END_SRC