1730 lines
60 KiB
Org Mode
1730 lines
60 KiB
Org Mode
* Curt Spark's Emacs Configuration
|
||
** By Curt Spark.
|
||
|
||
* Introduction
|
||
Welcome to my Emacs configuration!
|
||
|
||
[[./dashboard.png]]
|
||
|
||
This configuration is inspired by :
|
||
|
||
`https://github.com/munen/emacs.d`
|
||
|
||
And also loosely inspired by :
|
||
|
||
`https://github.com/daedreth/UncleDavesEmacs/blob/master/config.org`
|
||
|
||
With help from his fantastic Emacs tutorial series :
|
||
|
||
`https://www.youtube.com/playlist?list=PLX2044Ew-UVVv31a0-Qn3dA6Sd_-NyA1n`
|
||
|
||
This configuration is much more barebones and suited for someone just
|
||
doing some writing or editing, which is exactly my use case. It does
|
||
however copy over the useful functionalities (In my personal
|
||
preference) As this is a simple literate configuration, not a large
|
||
actively maintained distribution like Spacemacs or Doom Emacs, feel
|
||
free to do whatever you want with the configuration. I've tried to
|
||
document what every package does, what the code does briefly for
|
||
beginners to Emacs or literate configurations.
|
||
|
||
* Config
|
||
** Appearance
|
||
*** Remove Tool Bar
|
||
Remove the Tool bar at the top for more room.
|
||
Set mode to false:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(tool-bar-mode -1)
|
||
#+END_SRC
|
||
*** Remove Menu Bar
|
||
Remove the Menu Bar at the top for more room.
|
||
Set mode to false:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(menu-bar-mode -1)
|
||
#+END_SRC
|
||
*** Remove Scroll Bar
|
||
Remove the Scroll Bar at the side for more room.
|
||
Set mode to false:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(scroll-bar-mode -1)
|
||
#+END_SRC
|
||
*** Display Line Numbers
|
||
Display line numbers for all Programming Modes.
|
||
Add hook to enable display-line-numbers-mode on all programming major modes:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
|
||
(add-hook 'org-mode-hook 'display-line-numbers-mode)
|
||
|
||
;; Alternatively, globally
|
||
;; (global-display-line-numbers-mode)
|
||
#+END_SRC
|
||
*** Relative Line Numbers
|
||
Relative line numbers
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook 'display-line-numbers-mode-hook (lambda () (setq display-line-numbers 'relative)))
|
||
#+END_SRC
|
||
*** Tab Width
|
||
Change tab width.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq-default tab-width 8)
|
||
#+END_SRC
|
||
*** Window Gaps/Dividers
|
||
Window Dividers/Gaps for windows, you can also use the mouse to resize the windows within the gaps.
|
||
|
||
Set window divider mode to true:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(window-divider-mode 1)
|
||
#+END_SRC
|
||
|
||
*** Modern Fringes
|
||
Modern Fringes is a package that makes the side fringes of Emacs much more cleaner and modern.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package modern-fringes
|
||
:ensure t
|
||
:init
|
||
(modern-fringes-invert-arrows))
|
||
#+END_SRC
|
||
*** Theming
|
||
**** Pywal
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package ewal
|
||
:init (setq
|
||
;; Always use built-in palettes:
|
||
ewal-use-built-in-always-p nil
|
||
|
||
;; Use built-in palettes if your pywal theme fails to load (otherwise you just get a black-and-white theme and something about color being nil):
|
||
ewal-use-built-in-on-failure-p t
|
||
|
||
;; Pick a built-in palette:
|
||
;; ewal-built-in-palette "sexy-material"
|
||
|
||
;; Use special cursor for insert state when evil insert bindings are disabled:
|
||
ewal-evil-cursors-obey-evil-p t
|
||
|
||
))
|
||
|
||
(use-package ewal-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 'ewal-doom-vibrant 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-colors") ; use the colorful treemacs theme
|
||
(doom-themes-treemacs-config)
|
||
|
||
;; Corrects (and improves) org-mode's native fontification.
|
||
(doom-themes-org-config)
|
||
|
||
|
||
(use-package ewal-evil-cursors
|
||
:after (ewal-spacemacs-themes)
|
||
:config (ewal-evil-cursors-get-colors
|
||
:apply t :spaceline t))
|
||
+END_SRC
|
||
**** Classic
|
||
The theme for Emacs.
|
||
Install and set the theme, ensuring that it is always installed:
|
||
Old theme for if you'd like to follow Xresources
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package xresources-theme
|
||
:ensure t
|
||
:init
|
||
(load-theme 'xresources t))
|
||
+END_SRC
|
||
|
||
*** Doom Themes
|
||
Themes from Doom Emacs
|
||
Install and set the theme, ensuring that it is always installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(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 'doom-gruvbox-light t)
|
||
;; (load-theme 'doom-homage-black 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-colors") ; use the colorful treemacs theme
|
||
;; (doom-themes-treemacs-config)
|
||
|
||
;; Corrects (and improves) org-mode's native fontification.
|
||
(doom-themes-org-config)
|
||
#+END_SRC
|
||
*** Custom Modeline
|
||
A custom sleek modeline which is also used in Centaur Emacs, Doom Emacs and Spacemacs.
|
||
|
||
|
||
Install and set the modeline, ensuring that it is always installed:
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package doom-modeline
|
||
:ensure t
|
||
:init (doom-modeline-mode 1))
|
||
|
||
;; Display the current time on the modeline
|
||
(display-time-mode 1)
|
||
|
||
;; Display time in the 24hr format
|
||
(setq display-time-24hr-format t)
|
||
|
||
;; Display also the date on the modeline
|
||
(setq display-time-day-and-date t)
|
||
|
||
;; Display the battery (if has one) on the modeline
|
||
(display-battery-mode 1)
|
||
#+END_SRC
|
||
*** All The Icons
|
||
All The Icons is a package to display cool icons within Emacs.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package all-the-icons
|
||
:ensure t)
|
||
|
||
(setq inhibit-compacting-font-caches t) ; Don’t compact font caches during GC. Fixes lag on doom modeline
|
||
+END_SRC
|
||
|
||
All The Icons Support for Ivy/Counsel. Which are autocompletion tools in emacs
|
||
Install the package, enable it and ensure that it always is installed:
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package all-the-icons-ivy
|
||
:ensure t
|
||
:init
|
||
(all-the-icons-ivy-setup))
|
||
+END_SRC
|
||
*** Nerd Fonts
|
||
Alternative to All The Icons, provides unified experience in TTY and GUI.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package nerd-icons
|
||
:ensure t)
|
||
|
||
(setq inhibit-compacting-font-caches t) ; Don’t compact font caches during GC. Fixes lag on doom modeline
|
||
#+END_SRC
|
||
|
||
Nerd Icons support for the ivy rich plugin.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package nerd-icons-ivy-rich
|
||
:ensure t
|
||
:init
|
||
(nerd-icons-ivy-rich-mode 1))
|
||
#+END_SRC
|
||
*** Default Font
|
||
#+BEGIN_SRC emacs-lisp
|
||
;;(set-frame-font "Deja Vu Sans Mono 14")
|
||
(set-frame-font "SFMono Nerd Font 14")
|
||
(add-hook 'prog-mode-hook (lambda () (text-scale-increase 2)))
|
||
#+END_SRC
|
||
*** Emacs Dashboard
|
||
A startup dashboard for Emacs, replacing the boring old one.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package dashboard
|
||
:ensure t
|
||
:config
|
||
(dashboard-setup-startup-hook))
|
||
|
||
;; Fixes emacs not auto opening buffer when 1st argument is specifying a file to edit
|
||
(if (< (length command-line-args) 2)
|
||
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))))
|
||
#+END_SRC
|
||
|
||
**** Emacs Dashboard Configuration
|
||
#+BEGIN_SRC emacs-lisp
|
||
;; Set the title
|
||
(setq dashboard-banner-logo-title "The EMACS operating system.")
|
||
;; Set the banner
|
||
;;(setq dashboard-startup-banner '3)
|
||
;; 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
|
||
(setq dashboard-startup-banner "~/.emacs.d/banner.txt")
|
||
|
||
;; 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://git.cspark.dev/emacs-configuration")))
|
||
("★" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning)
|
||
("?" "" "?/h" #'show-help nil "<" ">"))
|
||
))
|
||
|
||
;; Ensure dashboard gets started up even if the hook fails
|
||
(dashboard-open)
|
||
#+END_SRC
|
||
** Performance
|
||
*** Gcmh Mode
|
||
Enforce a sneaky Garbage Collection strategy to minimize GC interference with
|
||
user activity.
|
||
|
||
During normal use a high GC threshold is set.
|
||
|
||
When idling GC is triggered and a low threshold is set.
|
||
|
||
This greatly improves performance/startup time of emacs.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package gcmh
|
||
:ensure t
|
||
:init
|
||
(gcmh-mode 1)
|
||
|
||
;; Ensure garbage collector does not run TOO frequently which causes random freezes
|
||
(defun gcmh-mode-optimisation-setup-hook ()
|
||
(setq gc-cons-threshold most-positive-fixnum))
|
||
|
||
(defun gcmh-mode-optimisation-exit-hook ()
|
||
(setq gc-cons-threshold 800000))
|
||
|
||
(add-hook 'minibuffer-setup-hook 'gcmh-mode-optimisation-setup-hook)
|
||
(add-hook 'minibuffer-exit-hook 'gcmh-mode-optimisation-exit-hook)
|
||
)
|
||
#+END_SRC
|
||
*** Doom Modeline
|
||
Tweaks to doom modeline
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
|
||
;; Disable modeline word count as it causes lots of lag
|
||
(setq doom-modeline-enable-word-count nil)
|
||
|
||
#+END_SRC
|
||
*** Custom
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
|
||
(setq auto-window-vscroll nil)
|
||
|
||
(setq fast-but-imprecise-scrolling t)
|
||
|
||
#+END_SRC
|
||
*** Midnight Mode
|
||
Midnight mode will automatically clear up configured buffers or buffers that havent been displayed in a certain amount of time.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq midnight-mode t)
|
||
#+END_SRC
|
||
|
||
*** Fontification
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(jit-lock-mode 1)
|
||
(setq jit-lock-stealth-time 1.25)
|
||
(setq jit-lock-stealth-nice 0.5) ;; Seconds between font locking.
|
||
(setq jit-lock-chunk-size 4096)
|
||
|
||
(setq jit-lock-defer-time 0)
|
||
(with-eval-after-load 'evil
|
||
(add-hook 'evil-insert-state-entry-hook
|
||
(lambda ()
|
||
(setq jit-lock-defer-time 0.25)) nil t)
|
||
(add-hook 'evil-insert-state-exit-hook
|
||
(lambda ()
|
||
(setq jit-lock-defer-time 0)) nil t))
|
||
#+END_SRC
|
||
** Eshell
|
||
*** Bash-like Completion
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook
|
||
'eshell-mode-hook
|
||
(lambda ()
|
||
(setq pcomplete-cycle-completions nil)))
|
||
|
||
(setq eshell-cmpl-cycle-completions nil)
|
||
|
||
(use-package bash-completion
|
||
:ensure t
|
||
:init
|
||
(autoload 'bash-completion-dynamic-complete
|
||
"bash-completion"
|
||
"BASH completion hook")
|
||
(add-hook 'shell-dynamic-complete-functions
|
||
'bash-completion-dynamic-complete)
|
||
(add-hook 'eshell-mode-hook
|
||
(lambda ()
|
||
(add-hook 'completion-at-point-functions
|
||
'bash-completion-capf-nonexclusive nil t)))
|
||
|
||
)
|
||
#+END_SRC
|
||
*** Zoxide
|
||
Zoxide Z like functionality, better cd inside eshell
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package eshell-z
|
||
:init
|
||
(add-hook 'eshell-mode-hook
|
||
(defun my-eshell-mode-hook ()
|
||
(require 'eshell-z)))
|
||
:ensure t)
|
||
#+END_SRC
|
||
|
||
*** Eat Terminal
|
||
Eat is a terminal emulator that can integrate nicely with eshell, allows us to run full ncurses applications inside eshell.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package eat
|
||
:straight '(eat :type git
|
||
:host codeberg
|
||
:repo "akib/emacs-eat"
|
||
:files ("*.el" ("term" "term/*.el") "*.texi"
|
||
"*.ti" ("terminfo/e" "terminfo/e/*")
|
||
("terminfo/65" "terminfo/65/*")
|
||
("integration" "integration/*")
|
||
(:exclude ".dir-locals.el" "*-tests.el")))
|
||
:ensure t
|
||
:init
|
||
;; For `eat-eshell-mode'.
|
||
(add-hook 'eshell-load-hook #'eat-eshell-mode)
|
||
|
||
;; For `eat-eshell-visual-command-mode'.
|
||
(add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode)
|
||
)
|
||
#+END_SRC
|
||
*** Terminal Colours
|
||
Ensure eshell has terminal colours.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook 'eshell-mode-hook (lambda () (setenv "TERM" "xterm-256color")))
|
||
#+END_SRC
|
||
** Default Shell
|
||
Set the default shell used to run commands.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq shell-file-name "/bin/sh")
|
||
#+END_SRC
|
||
|
||
** TRAMP
|
||
TRAMP edit files over SSH configuration
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package tramp
|
||
:ensure t
|
||
:config
|
||
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
|
||
(when (eq window-system 'w32)
|
||
(setq tramp-default-method "plink")))
|
||
#+END_SRC
|
||
|
||
** Custom
|
||
*** Eshell Terminal Bind
|
||
Bind the eshell terminal to Alt-Enter
|
||
Set keys:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(global-set-key (kbd "<M-RET>") 'eshell)
|
||
(add-hook 'org-mode-hook
|
||
(lambda ()
|
||
(local-unset-key (kbd "<M-RET>"))
|
||
(local-unset-key (kbd "M-h"))
|
||
)
|
||
)
|
||
#+END_SRC
|
||
*** Auto Popup frame Mode
|
||
A mode that is similiar in functionality to pop-up-frame, however much more granular in control and toggleable as it is mode. Will stop duplicate windows from creating new frames etc.
|
||
|
||
Using simpler solution instead:
|
||
+BEGIN_SRC emacs-lisp
|
||
(setq pop-up-frames t)
|
||
+END_SRC
|
||
|
||
+BEGIN_SRC emacs-lisp
|
||
(defun which-active-modes ()
|
||
"Which minor modes are enabled in the current buffer."
|
||
(let ((active-modes))
|
||
(mapc (lambda (mode) (condition-case nil
|
||
(if (and (symbolp mode) (symbol-value mode))
|
||
(add-to-list 'active-modes mode))
|
||
(error nil) ))
|
||
minor-mode-list)
|
||
active-modes))
|
||
|
||
(defun pop-up-frames-switch-to-buffer (buffer alist)
|
||
"Auto Pop up frames switch to buffer command."
|
||
(member 'pop-up-frames-mode (which-active-modes)))
|
||
|
||
(setq display-buffer-alist
|
||
(append display-buffer-alist
|
||
'((pop-up-frames-switch-to-buffer . ((display-buffer-reuse-window display-buffer-pop-up-frame) . ((reusable-frames . 0)))
|
||
))))
|
||
|
||
(define-minor-mode pop-up-frames-mode
|
||
"Pop up frames minor mode"
|
||
:lighter " PUF")
|
||
|
||
(provide 'pop-up-frames-mode)
|
||
+END_SRC
|
||
*** Resizing Buffers
|
||
These are controls to resize the width and height of windows.
|
||
Set keys:
|
||
#+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
|
||
*** Split and Follow Buffer
|
||
When splitting a window vertically or horizontally, make sure the mouse and focus follows that new window.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(defun split-and-follow-horizontally ()
|
||
(interactive)
|
||
(split-window-below)
|
||
(balance-windows)
|
||
(other-window 1))
|
||
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
|
||
|
||
(defun split-and-follow-vertically ()
|
||
(interactive)
|
||
(split-window-right)
|
||
(balance-windows)
|
||
(other-window 1))
|
||
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
|
||
#+END_SRC
|
||
** Autosave
|
||
Default Emacs will store backup and "temporary" files in the edited files directory, instead this changes it to move it to the UNIX Temporary Directory.
|
||
Set backup/temporary file directories:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq backup-directory-alist
|
||
`((".*" . ,temporary-file-directory)))
|
||
(setq auto-save-file-name-transforms
|
||
`((".*" ,temporary-file-directory 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.
|
||
Enable Wind Move:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(when (fboundp 'windmove-default-keybindings)
|
||
(windmove-default-keybindings))
|
||
#+END_SRC
|
||
** Global Revert Mode
|
||
Global Revert Mode is a minor mode that automatically refreshes opened buffers when an external tool has changed their data.
|
||
Enable Global Revert Mode:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(global-auto-revert-mode t)
|
||
#+END_SRC
|
||
** Rainbow Delimiters
|
||
This Minor Mode will mark pairs of brackets with colours.
|
||
Install the package, enable it and ensure that it always is installed.
|
||
#+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.
|
||
Install the package, enable it and ensure that it always is installed.
|
||
#+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
|
||
** Pdf Viewer
|
||
PDF Tools is, among other things, a replacement of DocView for PDF
|
||
files. The key difference is that pages are not pre-rendered by
|
||
e.g. ghostscript and stored in the file-system, but rather created
|
||
on-demand and stored in memory.
|
||
|
||
Actually, displaying PDF files is just one part of PDF Tools. Since
|
||
poppler can provide us with all kinds of information about a document
|
||
and is also able to modify it, there is a lot more we can do with
|
||
it.
|
||
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package pdf-tools
|
||
:ensure t
|
||
;;:hook (pdf-tools-enabled . pdf-view-midnight-minor-mode)
|
||
:hook (pdf-tools-enabled . pdf-view-themed-minor-mode)
|
||
;;:hook (pdf-tools-enabled . hide-mode-line-mode)
|
||
:init
|
||
(pdf-loader-install)
|
||
:config
|
||
;; Set color of PDF foreground/background
|
||
(setq pdf-view-midnight-colors '("#ebdbb2" . "#282828")))
|
||
;; Doom-One F:#ABB2BF B:#282C35
|
||
;; Doom-Gruvbox F:#ebdbb2 B:#282828
|
||
#+END_SRC
|
||
|
||
** Org Mode
|
||
*** Simple Org Mode Preview
|
||
These are a simple set of functions that will automatically refresh
|
||
the other buffer, which presumably has the Org Mode PDF open. Once
|
||
using the keybindings to quickly export the file, another window will
|
||
pop up as a live preview (Which is just an automatically opened
|
||
preview of the exported PDF). Define functions and set keybindings:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(defun open-pdf ()
|
||
(split-window-right)
|
||
(other-window 1)
|
||
(find-file (concat "/" (substring buffer-file-name 1 (- (length buffer-file-name) 4)) ".pdf"))
|
||
(revert-buffer nil t)
|
||
(other-window -1))
|
||
|
||
(defun update-other-buffer ()
|
||
(interactive)
|
||
(other-window 1)
|
||
(revert-buffer nil t)
|
||
(other-window -1))
|
||
|
||
(defun check-if-pdf-is-open ()
|
||
(setq openwindows (length (delete-dups (mapcar #'window-buffer (window-list)))))
|
||
(if (>= openwindows 2) (update-other-buffer) (open-pdf)))
|
||
|
||
(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)
|
||
(check-if-pdf-is-open))
|
||
|
||
(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)
|
||
(check-if-pdf-is-open))
|
||
|
||
(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
|
||
This package will automatically convert LaTeX Snippets into viewable LaTeX in your Org Mode Documents.
|
||
LaTeX Snippets can be defined with text between dollar signs. Example : $ax+bx^2$
|
||
|
||
These LaTeX snippets will also show up when converting to PDF.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package org-fragtog
|
||
:ensure t
|
||
:init
|
||
(add-hook 'org-mode-hook 'org-fragtog-mode))
|
||
#+END_SRC
|
||
*** Org Bullets
|
||
Org Bullets convert the Asterisks of Org Mode headers into unicode Bullet point with multiple styles.
|
||
Install the package, enable it and ensure that it always is installed, then add a hook to enable the Bullet Points when on Org Major Mode:
|
||
#+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
|
||
A hook that will autmatically make sure that indenting of headers are enabled by default, this is visually useful and emulates code hierarchy.
|
||
Add a hook to enable the Indentation when on Org Major Mode:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook 'org-mode-hook 'org-indent-mode)
|
||
#+END_SRC
|
||
*** Enable Beamer Support
|
||
A hook that will automatically make sure that Beamer Org Mode templates and exportion are enabled by default, for slideshow creation with LaTeX.
|
||
Add a hook to enable the Beamer Mode when on Org Major Mode:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(add-hook 'org-mode-hook 'org-beamer-mode)
|
||
#+END_SRC
|
||
** Agenda
|
||
For Org-Agenda, you can set a location of your Org Agenda file here.
|
||
Set Agenda Directory:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq org-agenda-files (quote("~/.emacs.d/agenda.org")))
|
||
#+END_SRC
|
||
|
||
This is will integrate the Calendar/Diary into Org-Agenda, so you can get access to dates on public holidays etc.
|
||
Set diary to true:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq org-agenda-include-diary t)
|
||
#+END_SRC
|
||
** Evil Mode
|
||
Evil Mode, a package designed to emulate modal editing and vim keybindings in Emacs.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that evil-mode is enabled by default:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package evil
|
||
:ensure t
|
||
:config
|
||
(evil-define-key '(normal) 'global "/" (lambda () (interactive) (swiper)))
|
||
:init
|
||
(evil-mode 1))
|
||
#+END_SRC
|
||
|
||
*** Cursor Theming
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq evil-default-cursor '("black" box)
|
||
evil-normal-state-cursor '("black" box)
|
||
evil-emacs-state-cursor '("black" box)
|
||
evil-motion-state-cursor '("black" box)
|
||
evil-insert-state-cursor '("black" bar)
|
||
evil-visual-state-cursor '("black" hbar)
|
||
evil-replace-state-cursor '("black" hbar))
|
||
#+END_SRC
|
||
** Projectile
|
||
Projectile is a project manager, like a dynamic bookmarking system. It will automatically add repositories as projects which you can access via Dired or Ivy completion.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that projectile-mode is enabled by default:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package projectile
|
||
:ensure t
|
||
:init
|
||
(projectile-mode))
|
||
#+END_SRC
|
||
** Auto Completion
|
||
Autocompletion can also be handled by ACM in LSP Bridge.
|
||
|
||
*** Which Key
|
||
Which Key is an insanely useful package that will automatically show you the possible key combinations to finish a binded keychord.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that which-key is enabled by default:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package which-key
|
||
:ensure t
|
||
:init
|
||
(setq which-key-idle-delay 0)
|
||
(setq which-key-idle-secondary-delay 0)
|
||
(which-key-mode))
|
||
#+END_SRC
|
||
*** Ivy
|
||
Ivy is an autocompletion framework, it will automatically fuzzy find search words for you. This includes file managing, searching, and more via its extensibility and the Counsel package.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that ivy-mode is enabled by default:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package ivy
|
||
:ensure t
|
||
:init
|
||
(ivy-mode 1)
|
||
;; :bind
|
||
;; ("C-s" . swiper)
|
||
)
|
||
|
||
;; Ivy Pass - GNU Pass integrated into Ivy
|
||
(use-package ivy-pass
|
||
:ensure t)
|
||
#+END_SRC
|
||
|
||
Ivy Configuration
|
||
Set an option to make Ivy show previously opened/edited buffers in the buffer selection :
|
||
#+BEGIN_SRC emacs-lisp
|
||
(setq ivy-use-virtual-buffers t)
|
||
;(setq enable-recursive-minibuffers t)
|
||
#+END_SRC
|
||
|
||
This package comes with rich transformers for commands from ivy and counsel.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that ivy-rich-mode is enabled by default:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package ivy-rich
|
||
:ensure t
|
||
:init
|
||
(ivy-rich-mode 1)
|
||
|
||
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
|
||
#+END_SRC
|
||
*** Counsel
|
||
A collection of Ivy-enhanced versions of common Emacs commands.
|
||
Install the package, enable it and ensure that it always is installed:
|
||
#+BEGIN_SRC emacs-lisp
|
||
;;(use-package counsel
|
||
;; :ensure t
|
||
;; :config
|
||
;; (counsel-mode))
|
||
|
||
;; Taken from https://raw.githubusercontent.com/protesilaos/dotfiles/aa8a5d96b013462cfa622e396e65abb66725318a/emacs/.emacs.d/emacs-init.org
|
||
;; Thank you Protesilaos Stavrou!
|
||
(use-package counsel
|
||
:ensure t
|
||
:after ivy
|
||
:custom
|
||
(counsel-yank-pop-preselect-last t)
|
||
(counsel-yank-pop-separator "\n—————————\n")
|
||
(counsel-rg-base-command
|
||
"rg -SHn --no-heading --color never --no-follow --hidden %s")
|
||
(counsel-find-file-occur-cmd ; TODO Simplify this
|
||
"ls -a | grep -i -E '%s' | tr '\\n' '\\0' | xargs -0 ls -d --group-directories-first")
|
||
:config
|
||
(defun prot/counsel-fzf-rg-files (&optional input dir)
|
||
"Run `fzf' in tandem with `ripgrep' to find files in the
|
||
present directory. Both of those programs are external to
|
||
Emacs."
|
||
(interactive)
|
||
(let ((process-environment
|
||
(cons (concat "FZF_DEFAULT_COMMAND=rg -Sn --color never --files --no-follow --hidden")
|
||
process-environment)))
|
||
(counsel-fzf input dir)))
|
||
|
||
(defun prot/counsel-fzf-dir (arg)
|
||
"Specify root directory for `counsel-fzf'."
|
||
(prot/counsel-fzf-rg-files ivy-text
|
||
(read-directory-name
|
||
(concat (car (split-string counsel-fzf-cmd))
|
||
" in directory: "))))
|
||
|
||
(defun prot/counsel-rg-dir (arg)
|
||
"Specify root directory for `counsel-rg'."
|
||
(let ((current-prefix-arg '(4)))
|
||
(counsel-rg ivy-text nil "")))
|
||
|
||
(ivy-add-actions
|
||
'counsel-fzf
|
||
'(("r" prot/counsel-fzf-dir "change root directory")
|
||
("g" prot/counsel-rg-dir "use ripgrep in root directory")))
|
||
|
||
(ivy-add-actions
|
||
'counsel-rg
|
||
'(("r" prot/counsel-rg-dir "change root directory")
|
||
("z" prot/counsel-fzf-dir "find files with fzf in root directory")))
|
||
|
||
;; Remove commands that only work with key bindings
|
||
(put 'counsel-find-symbol 'no-counsel-M-x t)
|
||
:bind (("M-x" . counsel-M-x)
|
||
|
||
;; This doesnt work with lsp-bridge over TRAMP, i'll just disable for now.
|
||
;; ("C-x f" . counsel-find-file)
|
||
("C-x f" . find-file)
|
||
|
||
("s-f" . counsel-find-file)
|
||
("s-F" . find-file-other-window)
|
||
("C-x b" . ivy-switch-buffer)
|
||
("s-b" . ivy-switch-buffer)
|
||
("C-x B" . counsel-switch-buffer-other-window)
|
||
("s-B" . counsel-switch-buffer-other-window)
|
||
("C-x d" . counsel-dired)
|
||
("s-d" . counsel-dired)
|
||
("s-D" . dired-other-window)
|
||
("C-x C-r" . counsel-recentf)
|
||
("s-r" . counsel-recentf)
|
||
("s-y" . counsel-yank-pop)
|
||
("C-h f" . counsel-describe-function)
|
||
("C-h v" . counsel-describe-variable)
|
||
("C-s" . counsel-rg)
|
||
("M-s g" . counsel-git-grep)
|
||
("C-x C-f" . prot/counsel-fzf-rg-files)
|
||
:map ivy-minibuffer-map
|
||
("C-r" . counsel-minibuffer-history)
|
||
("s-y" . ivy-next-line) ; Avoid 2× `counsel-yank-pop'
|
||
("C-SPC" . ivy-restrict-to-matches)))
|
||
#+END_SRC
|
||
|
||
Counsel Support in Projectile.
|
||
Install the package, enable it and ensure that it always is installed, and then set up bindings for the Projectile specific prefix:
|
||
#+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
|
||
Company is a text completion framework for Emacs. The name stands for "complete anything". It uses pluggable back-ends and front-ends to retrieve and display completion candidates.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that company-mode is enabled by default:
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package company
|
||
:ensure t
|
||
:init
|
||
(global-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)
|
||
|
||
(dolist (key '("<return>" "RET"))
|
||
;; Here we are using an advanced feature of define-key that lets
|
||
;; us pass an "extended menu item" instead of an interactive
|
||
;; function. Doing this allows RET to regain its usual
|
||
;; functionality when the user has not explicitly interacted with
|
||
;; Company.
|
||
(define-key company-active-map (kbd key)
|
||
`(menu-item nil company-complete
|
||
:filter ,(lambda (cmd)
|
||
(when (company-explicit-action-p)
|
||
cmd)))))
|
||
|
||
; Use tab key to cycle through suggestions.
|
||
; ('tng' means 'tab and go')
|
||
(company-tng-configure-default)
|
||
|
||
+END_SRC
|
||
**** Company Quickhelp
|
||
Company Quickhelp is an extension to company which introduces documentation popups that appears when idling on a company completion candidate.
|
||
Install the package, enable it and ensure that it always is installed, and then make sure that company-quickhelp-mode is enabled by default:
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package company-quickhelp
|
||
:ensure t
|
||
:init
|
||
(company-quickhelp-mode))
|
||
+END_SRC
|
||
**** Company Box
|
||
Company Box Mode is a mode that gives Company menu options icons.
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package company-box
|
||
:ensure t
|
||
:hook (company-mode . company-box-mode))
|
||
+END_SRC
|
||
** Multiple Cursors
|
||
The Multiple Cursors package is pretty self explanatory, you can select and manipulate multiple lines of the same text at the same time, move the cursors in unison. Etc.
|
||
Install the package, enable it and ensure that it always is installed, and then bind the useful functions to a mnenomic key chord:
|
||
|
||
To remove the cursors on non-evil mode implementation, use keybind C-g.
|
||
For non-evil mode:
|
||
+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
|
||
|
||
To undo the last cursors added on evil mode implementation, type gru in NORMAL mode.
|
||
To remove the cursors on evil mode implementation, type grq in NORMAL mode.
|
||
For evil mode:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package evil-mc
|
||
:ensure t
|
||
:config
|
||
(global-evil-mc-mode 1)
|
||
:bind
|
||
("C-c m" . 'evil-mc-make-cursor-here)
|
||
:bind
|
||
("C-c C-m" . 'evil-mc-make-and-goto-next-match))
|
||
#+END_SRC
|
||
|
||
** Expand Region
|
||
Auto selects a region of text/code, if executed multiple times it will wrap further, like layers of a binary onion.
|
||
Install the package, enable it and ensure that it always is installed, and then bind the useful functions to a mnenomic key chord:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package expand-region
|
||
:ensure t
|
||
:bind
|
||
("C-c e" . 'er/expand-region))
|
||
#+END_SRC
|
||
** Discord Rich Presence
|
||
Rich Presence in Emacs for discord, `https://github.com/Mstrodl/elcord`
|
||
|
||
Install the package, enable it and ensure that it always is installed, and then enable the mode:
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package elcord
|
||
:ensure t
|
||
:init
|
||
(elcord-mode 1))
|
||
#+END_SRC
|
||
** Languages
|
||
*** Nix Mode
|
||
An Emacs major mode for editing Nix expressions. There is also a manual available at nix-mode.org.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package nix-mode
|
||
:ensure t
|
||
:mode "\\.nix\\'")
|
||
#+END_SRC
|
||
|
||
*** LUA Mode
|
||
lua-mode is a major mode for editing Lua sources in Emacs.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package lua-mode
|
||
:ensure t)
|
||
|
||
(add-to-list 'auto-mode-alist '("\\.iy\\'" . lua-mode))
|
||
#+END_SRC
|
||
*** Swift Mode
|
||
Major-mode for Apple's Swift programming language.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package swift-mode
|
||
:ensure t)
|
||
|
||
(add-to-list 'auto-mode-alist '("\\.swift\\'" . swift-mode))
|
||
|
||
;; For LSP
|
||
;;(use-package lsp-sourcekit
|
||
;; :after lsp-mode
|
||
;; :config
|
||
;; ;;(setq lsp-sourcekit-executable "/ssh:work-laptop:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp")
|
||
;; (setq lsp-sourcekit-executable "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp")
|
||
;; )
|
||
|
||
#+END_SRC
|
||
*** TSX Mode
|
||
A batteries-included Emacs major mode for TSX/JSX files.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package jtsx
|
||
:ensure t
|
||
:mode (("\\.jsx?\\'" . jtsx-jsx-mode)
|
||
("\\.tsx\\'" . jtsx-tsx-mode)
|
||
("\\.ts\\'" . jtsx-typescript-mode))
|
||
:commands jtsx-install-treesit-language
|
||
:hook ((jtsx-jsx-mode . hs-minor-mode)
|
||
(jtsx-tsx-mode . hs-minor-mode)
|
||
(jtsx-typescript-mode . hs-minor-mode))
|
||
:custom
|
||
;; Optional customizations
|
||
(js-indent-level 8)
|
||
;; (typescript-ts-mode-indent-offset 2)
|
||
;; (jtsx-switch-indent-offset 0)
|
||
;; (jtsx-indent-statement-block-regarding-standalone-parent nil)
|
||
;; (jtsx-jsx-element-move-allow-step-out t)
|
||
;; (jtsx-enable-jsx-electric-closing-element t)
|
||
;; (jtsx-enable-electric-open-newline-between-jsx-element-tags t)
|
||
;; (jtsx-enable-jsx-element-tags-auto-sync nil)
|
||
(jtsx-enable-all-syntax-highlighting-features t)
|
||
:config
|
||
(defun jtsx-bind-keys-to-mode-map (mode-map)
|
||
"Bind keys to MODE-MAP."
|
||
(define-key mode-map (kbd "C-c C-j") 'jtsx-jump-jsx-element-tag-dwim)
|
||
(define-key mode-map (kbd "C-c j o") 'jtsx-jump-jsx-opening-tag)
|
||
(define-key mode-map (kbd "C-c j c") 'jtsx-jump-jsx-closing-tag)
|
||
(define-key mode-map (kbd "C-c j r") 'jtsx-rename-jsx-element)
|
||
(define-key mode-map (kbd "C-c <down>") 'jtsx-move-jsx-element-tag-forward)
|
||
(define-key mode-map (kbd "C-c <up>") 'jtsx-move-jsx-element-tag-backward)
|
||
(define-key mode-map (kbd "C-c C-<down>") 'jtsx-move-jsx-element-forward)
|
||
(define-key mode-map (kbd "C-c C-<up>") 'jtsx-move-jsx-element-backward)
|
||
(define-key mode-map (kbd "C-c C-S-<down>") 'jtsx-move-jsx-element-step-in-forward)
|
||
(define-key mode-map (kbd "C-c C-S-<up>") 'jtsx-move-jsx-element-step-in-backward)
|
||
(define-key mode-map (kbd "C-c j w") 'jtsx-wrap-in-jsx-element)
|
||
(define-key mode-map (kbd "C-c j u") 'jtsx-unwrap-jsx)
|
||
(define-key mode-map (kbd "C-c j d") 'jtsx-delete-jsx-node))
|
||
|
||
(defun jtsx-bind-keys-to-jtsx-jsx-mode-map ()
|
||
(jtsx-bind-keys-to-mode-map jtsx-jsx-mode-map))
|
||
|
||
(defun jtsx-bind-keys-to-jtsx-tsx-mode-map ()
|
||
(jtsx-bind-keys-to-mode-map jtsx-tsx-mode-map))
|
||
|
||
(add-hook 'jtsx-jsx-mode-hook 'jtsx-bind-keys-to-jtsx-jsx-mode-map)
|
||
(add-hook 'jtsx-tsx-mode-hook 'jtsx-bind-keys-to-jtsx-tsx-mode-map))
|
||
#+END_SRC
|
||
*** Emmet Mode
|
||
Provides support for Zen Coding by producing HTML from CSS-like selectors
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package emmet-mode
|
||
:ensure t
|
||
:init
|
||
(add-hook 'html-mode-hook 'emmet-mode)
|
||
(add-hook 'css-mode-hook 'emmet-mode)
|
||
(add-hook 'js-mode-hook 'emmet-mode))
|
||
|
||
(define-key emmet-mode-keymap (kbd "C-j") 'emmet-expand-yas)
|
||
#+END_SRC
|
||
|
||
** Snippets
|
||
YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package yasnippet
|
||
:ensure t
|
||
:init
|
||
(yas-global-mode 1))
|
||
|
||
(use-package yasnippet-snippets
|
||
:ensure t)
|
||
#+END_SRC
|
||
|
||
** Prettier Mode
|
||
The prettier Emacs package reformats your code by running Prettier with minimal overhead, by request or transparently on file save.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package prettier
|
||
:ensure t
|
||
:init
|
||
(add-hook 'after-init-hook #'global-prettier-mode)
|
||
:hook ((jtsx-jsx-mode . prettier-mode)
|
||
(jtsx-tsx-mode . prettier-mode)
|
||
(jtsx-typescript-mode . prettier-mode)))
|
||
#+END_SRC
|
||
|
||
** Flycheck
|
||
Flycheck is a modern version of Flymake, provides error messages. (Disabling, flycheck currently does not integrate with lsp-bridge. See https://github.com/flycheck/flycheck/issues/2094)
|
||
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package flycheck
|
||
:ensure t
|
||
:config
|
||
(add-hook 'after-init-hook #'global-flycheck-mode)
|
||
(add-hook 'prog-mode-hook #'flycheck-mode))
|
||
|
||
;; Display errors inline
|
||
+END_SRC
|
||
*** Inline Errors
|
||
**** Flycheck Inline
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package flycheck-inline
|
||
:after flycheck
|
||
:ensure t
|
||
:config
|
||
(add-hook 'flycheck-mode-hook #'flycheck-inline-mode))
|
||
+END_SRC
|
||
**** Flycheck Posframe
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package flycheck-posframe
|
||
:after flycheck
|
||
:ensure t
|
||
:config
|
||
(add-hook 'flycheck-mode-hook #'flycheck-inline-mode))
|
||
+END_SRC
|
||
** LSP
|
||
*** Eglot Mode
|
||
Emacs Polyglot is the Emacs LSP client that stays out of your way, built into emacs.
|
||
|
||
+BEGIN_SRC emacs-lisp
|
||
;;(with-eval-after-load 'eglot
|
||
;; (add-to-list 'eglot-server-programs '(swift-mode . ("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp")))
|
||
;; )
|
||
|
||
(with-eval-after-load 'eglot
|
||
(add-to-list 'eglot-server-programs
|
||
'(swift-mode . ("sourcekit-lsp"))))
|
||
|
||
;; Ensure eglot is using flycheck
|
||
(use-package flycheck-eglot
|
||
:ensure t
|
||
:after (flycheck eglot)
|
||
:config
|
||
(global-flycheck-eglot-mode 1))
|
||
|
||
(add-hook 'prog-mode-hook 'eglot-ensure)
|
||
+END_SRC
|
||
*** LSP Mode
|
||
LSP mode will give you IDE capabilities in Emacs, using Microsoft's
|
||
Universal Language Server Protocol. The same one that VSCode uses for
|
||
linting, autocompletion. Etc. Install the package, enable it and
|
||
ensure that it always is installed, add a hook to make sure it only is
|
||
activated on Programming Related Major Modes, and set a keychord for
|
||
the custom prefix. Please check
|
||
`https://github.com/emacs-lsp/lsp-mode#installation` for instructions
|
||
on how to install the Programming Language Servers that you want.
|
||
**** Lsp Mode
|
||
+BEGIN_SRC emacs-lisp
|
||
;; For some reason this logging variable being set SOMETIMES fixes LSP not working over TRAMP. https://github.com/emacs-lsp/lsp-mode/issues/2709
|
||
(setq *lsp-log-io* t)
|
||
(setq lsp-log-io t)
|
||
|
||
|
||
|
||
|
||
(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))
|
||
:config
|
||
(setq *lsp-log-io* t)
|
||
(setq lsp-log-io t)
|
||
:commands lsp)
|
||
|
||
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
|
||
(setq lsp-keymap-prefix "C-l")
|
||
#+END_SRC
|
||
|
||
**** Configuration
|
||
+BEGIN_SRC emacs-lisp
|
||
;; 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
|
||
:init
|
||
(require 'dap-lldb))
|
||
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
|
||
|
||
;; New luau lsp for roblox implementation
|
||
(with-eval-after-load 'lsp-mode
|
||
(defun return-true () t)
|
||
|
||
|
||
;; Connect to LSP via SSH port forwarding instead
|
||
(defun lsp-tramp-connection-over-ssh-port-forwarding (command)
|
||
"Like lsp-tcp-connection, but uses SSH portforwarding."
|
||
(print command)
|
||
(list
|
||
:connect (lambda (filter sentinel name environment-fn _workspace)
|
||
(let* ((host "localhost")
|
||
(lsp-port (lsp--find-available-port host (cl-incf lsp--tcp-port)))
|
||
(command (with-parsed-tramp-file-name buffer-file-name nil
|
||
(message "[tcp/ssh hack] running LSP %s on %s / %s" command host localname)
|
||
(let* ((unix-socket (format "/tmp/lsp-ssh-portforward-%s.sock" lsp-port))
|
||
(command (list
|
||
"ssh"
|
||
;; "-vvv"
|
||
"-L" (format "%s:%s" lsp-port unix-socket)
|
||
host
|
||
"socat"
|
||
(format "unix-listen:%s" unix-socket)
|
||
(format "system:'\"cd %s && %s\"'" (file-name-directory localname) command)
|
||
)))
|
||
(message "using local command %s" command)
|
||
command)))
|
||
(final-command (if (consp command) command (list command)))
|
||
(_ (unless (executable-find (cl-first final-command))
|
||
(user-error (format "Couldn't find executable %s" (cl-first final-command)))))
|
||
(process-environment
|
||
(lsp--compute-process-environment environment-fn))
|
||
(proc (make-process :name name :connection-type 'pipe :coding 'no-conversion
|
||
:command final-command :sentinel sentinel :stderr (format "*%s::stderr*" name) :noquery t))
|
||
(tcp-proc (progn
|
||
(sleep-for 1) ; prevent a connection before SSH has run socat. Ugh.
|
||
(lsp--open-network-stream host lsp-port (concat name "::tcp")))))
|
||
|
||
;; TODO: Same :noquery issue (see above)
|
||
(set-process-query-on-exit-flag proc nil)
|
||
(set-process-query-on-exit-flag tcp-proc nil)
|
||
(set-process-filter tcp-proc filter)
|
||
(cons tcp-proc proc)))
|
||
:test? (lambda () t)))
|
||
|
||
(add-to-list 'lsp-language-id-configuration
|
||
'(lua-mode . "luau"))
|
||
|
||
(lsp-register-client
|
||
(make-lsp-client :new-connection (lsp-stdio-connection "luau-lsp")
|
||
:activation-fn (lsp-activate-on "luau")
|
||
:server-id 'luau-lsp))
|
||
|
||
;;(lsp-register-client
|
||
;; (make-lsp-client :new-connection (lsp-tramp-connection "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp" 'return-true)
|
||
;; :major-modes '(swift-mode)
|
||
;; :remote? t
|
||
;; :server-id 'sourcekit-lsp-tramp))
|
||
(lsp-register-client
|
||
(make-lsp-client :new-connection (lsp-tramp-connection-over-ssh-port-forwarding "sourcekit-lsp")
|
||
:major-modes '(swift-mode)
|
||
:remote? t
|
||
:server-id 'sourcekit-lsp-ssh-forward))
|
||
|
||
(lsp-register-client
|
||
(make-lsp-client :new-connection (lsp-tramp-connection-over-ssh-port-forwarding "bash-language-server")
|
||
:major-modes '(shell-mode)
|
||
;;:initialization-options '((omitInitBuild . t)
|
||
;; (cmdRun . t))
|
||
:remote? t
|
||
:server-id 'bash-language-ssh-forward))
|
||
|
||
)
|
||
+END_SRC
|
||
|
||
*** LSP Bridge
|
||
LSP Bridge is meant to be a super fast LSP integration.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package lsp-bridge
|
||
:straight '(lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge"
|
||
:files (:defaults "*.el" "*.py" "acm" "core" "langserver" "multiserver" "resources")
|
||
:build (:not compile)) ;; Do not compile lsp-bridge
|
||
:init
|
||
;; Automatically start the lsp_bridge.py process on the remote host (which needs to support bash) when opening a tramp file
|
||
(setq lsp-bridge-enable-log t)
|
||
(setq lsp-bridge-enable-with-tramp t)
|
||
;;(setq lsp-bridge-remote-start-automatically t)
|
||
;;(setq lsp-bridge-remote-python-command "~/usr/bin/python3")
|
||
;;(setq lsp-bridge-remote-python-file "~/.emacs.d/straight/repos/lsp-bridge/lsp_bridge.py")
|
||
(setq lsp-bridge-remote-log "~/.emacs.d/lbr_log.txt")
|
||
|
||
(setq lsp-bridge-diagnostic-fetch-idle 0.5)
|
||
(setq lsp-bridge-diagnostic-overlays t)
|
||
|
||
(setq acm-enable-capf t)
|
||
(setq acm-enable-icon t)
|
||
(setq acm-enable-lsp-workspace-symbol t)
|
||
(setq acm-backend-search-file-words-enable-fuzzy-match t)
|
||
(setq acm-enable-yas t)
|
||
(setq acm-backend-lsp-candidate-min-length 1)
|
||
(setq acm-backend-elisp-candidate-min-length 1)
|
||
(setq acm-backend-yas-candidate-min-length 1)
|
||
|
||
(setq lsp-bridge-enable-org-babel t)
|
||
(setq acm-enable-doc-markdown-render 'async)
|
||
|
||
(global-lsp-bridge-mode)
|
||
)
|
||
#+END_SRC
|
||
|
||
**** Flymake Integration
|
||
Integrate lsp-bridge with flymake to provide error messages. (Disabled for now as it causes "let: Wrong type argument: listp, t" error)
|
||
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package flymake-bridge
|
||
:ensure t
|
||
:straight '(flymake-bridge :type git :host github :repo "liuyinz/flymake-bridge")
|
||
:after (lsp-bridge flymake)
|
||
:hook ((prog-mode . flymake-mode)
|
||
;;(flymake-mode . flymake-bridge-setup)
|
||
(lsp-bridge-mode . flymake-bridge-setup))
|
||
:config
|
||
(setq flymake-start-on-save-buffer t)
|
||
(setq flymake-start-on-flymake-mode t)
|
||
(setq flymake-start-syntax-check-on-find-file t)
|
||
)
|
||
+END_SRC
|
||
** Ranger
|
||
This is a minor mode that runs within dired, it emulates many of
|
||
ranger's (terminal file manager) features. This minor mode shows a
|
||
stack of parent directories, and updates the parent buffers, while
|
||
you're navigating the file system. The preview window takes some of
|
||
the ideas from Peep-Dired, to display previews for the selected files,
|
||
in the primary dired buffer.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package ranger
|
||
:ensure t)
|
||
#+END_SRC
|
||
** Libvterm
|
||
A better terminal
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package vterm
|
||
:ensure t)
|
||
+END_SRC
|
||
** Sudo Edit
|
||
Allows you to edit files as root via running sudo-edit
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package sudo-edit
|
||
:ensure t)
|
||
#+END_SRC
|
||
** MPD
|
||
Clients that support MPD
|
||
*** MPDel
|
||
MPDel is an Emacs client for Music Player Daemon (MPD), a flexible, powerful, server-side application for playing music.
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package mpdel
|
||
:ensure t)
|
||
+END_SRC
|
||
*** Mingus
|
||
Mingus is a frontend for GNU Emacs to the Music Player daemon. The interface closely, though not strictly, resembles that of ncmpc.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package mingus
|
||
:ensure t
|
||
)
|
||
|
||
(with-eval-after-load 'mingus
|
||
(define-key mingus-playlist-mode-map (kbd "<XF86AudioRaiseVolume>") 'mingus-vol-up)
|
||
(define-key mingus-playlist-mode-map (kbd "<XF86AudioLowerVolume>") 'mingus-vol-down)
|
||
(define-key mingus-playlist-mode-map (kbd "C-s") 'mingus-query)
|
||
)
|
||
#+END_SRC
|
||
|
||
** Databases
|
||
*** Sqlite Mode
|
||
Emacs has a built in sqlite mode to view sqlite database files and modify them. Configure to be a bit nicer
|
||
#+BEGIN_SRC emacs-lisp
|
||
(with-eval-after-load 'sqlite-mode
|
||
(define-key sqlite-mode-map (kbd "<tab>") 'sqlite-mode-list-data)
|
||
)
|
||
;; Hook into find-file, basically allows us to open the sqlite db file directly instead of using sqlite-mode-open-file function
|
||
(defun sqlite-find-file-hook ()
|
||
(when (string= (file-name-extension buffer-file-name) "sqlite")
|
||
(let
|
||
(
|
||
(sql-original-buffer-name (buffer-name))
|
||
(sql-original-buffer-file-name (buffer-file-name))
|
||
)
|
||
|
||
(kill-buffer sql-original-buffer-name)
|
||
(sqlite-mode-open-file sql-original-buffer-file-name)
|
||
)
|
||
)
|
||
)
|
||
|
||
(add-hook 'find-file-hook 'sqlite-find-file-hook)
|
||
#+END_SRC
|
||
** Edwina Dynamic Tiling
|
||
Edwina is a dynamic window manager for Emacs. It automatically arranges your Emacs panes (called “windows” in Emacs parlance) into predefined layouts, dwm-style.
|
||
|
||
Install the package, enable it and ensure that it always is installed, and then configure:
|
||
+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
|
||
** Ranger
|
||
This is a minor mode that runs within dired, it emulates many of
|
||
ranger's (terminal file manager) features. This minor mode shows a
|
||
stack of parent directories, and updates the parent buffers, while
|
||
you're navigating the file system. The preview window takes some of
|
||
the ideas from Peep-Dired, to display previews for the selected files,
|
||
in the primary dired buffer.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package ranger
|
||
:ensure t)
|
||
#+END_SRC
|
||
** Libvterm
|
||
A better terminal
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package vterm
|
||
:ensure t)
|
||
+END_SRC
|
||
** Sudo Edit
|
||
Allows you to edit files as root via running sudo-edit
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package sudo-edit
|
||
:ensure t)
|
||
#+END_SRC
|
||
** MPD
|
||
Clients that support MPD
|
||
*** MPDel
|
||
MPDel is an Emacs client for Music Player Daemon (MPD), a flexible, powerful, server-side application for playing music.
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package mpdel
|
||
:ensure t)
|
||
+END_SRC
|
||
*** Mingus
|
||
Mingus is a frontend for GNU Emacs to the Music Player daemon. The interface closely, though not strictly, resembles that of ncmpc.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package mingus
|
||
:ensure t
|
||
)
|
||
|
||
(with-eval-after-load 'mingus
|
||
(define-key mingus-playlist-mode-map (kbd "<XF86AudioRaiseVolume>") 'mingus-vol-up)
|
||
(define-key mingus-playlist-mode-map (kbd "<XF86AudioLowerVolume>") 'mingus-vol-down)
|
||
(define-key mingus-playlist-mode-map (kbd "C-s") 'mingus-query)
|
||
)
|
||
#+END_SRC
|
||
|
||
** Databases
|
||
*** Sqlite Mode
|
||
Emacs has a built in sqlite mode to view sqlite database files and modify them. Configure to be a bit nicer
|
||
#+BEGIN_SRC emacs-lisp
|
||
(with-eval-after-load 'sqlite-mode
|
||
(define-key sqlite-mode-map (kbd "<tab>") 'sqlite-mode-list-data)
|
||
)
|
||
;; Hook into find-file, basically allows us to open the sqlite db file directly instead of using sqlite-mode-open-file function
|
||
(defun sqlite-find-file-hook ()
|
||
(when (string= (file-name-extension buffer-file-name) "sqlite")
|
||
(let
|
||
(
|
||
(sql-original-buffer-name (buffer-name))
|
||
(sql-original-buffer-file-name (buffer-file-name))
|
||
)
|
||
|
||
(kill-buffer sql-original-buffer-name)
|
||
(sqlite-mode-open-file sql-original-buffer-file-name)
|
||
)
|
||
)
|
||
)
|
||
|
||
(add-hook 'find-file-hook 'sqlite-find-file-hook)
|
||
#+END_SRC
|
||
*** PGMacs
|
||
PGmacs provides an editing interface for the PostgreSQL object-relational DBMS from Emacs.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(use-package pg
|
||
:ensure t)
|
||
|
||
(use-package pgmacs
|
||
:straight '(pgmacs :type git :host github :repo "emarsden/pgmacs")
|
||
:ensure t
|
||
:after pg)
|
||
#+END_SRC
|
||
|
||
** Emacs Server
|
||
Start emacs server, this can then be used to open buffers/set the current emacs session as the EDITOR.
|
||
#+BEGIN_SRC emacs-lisp
|
||
(server-start)
|
||
#+END_SRC
|
||
** EXWM - Emacs as an operating system
|
||
EXWM, The Emacs X Window Manager. As it says, it is an Emacs window
|
||
manager for the X display server. The benefits include using all your
|
||
emacs functions and fuzzy searching in tangent with X windows.
|
||
|
||
For more information on setup, you should check out `https://github.com/ch11ng/exwm/wiki`
|
||
|
||
Install the package, enable it and ensure that it always is installed, and then configure:
|
||
*** EXWM
|
||
+BEGIN_SRC emacs-lisp
|
||
(use-package exwm
|
||
:ensure t
|
||
:config
|
||
(exwm-enable))
|
||
+END_SRC
|
||
**** Configuration
|
||
+BEGIN_SRC emacs-lisp
|
||
(with-eval-after-load 'exwm
|
||
;; Autostart applications
|
||
(start-process-shell-command "udiskie" nil "udiskie -t")
|
||
(start-process-shell-command "dunst" nil "dunst")
|
||
(start-process-shell-command "qpwgraph" nil "qpwgraph")
|
||
(start-process-shell-command "kdeconnectd" nil "kdeconnectd")
|
||
(start-process-shell-command "kdeconnect-indicator" nil "kdeconnect-indicator")
|
||
|
||
;; Systemtray
|
||
(require 'exwm-systemtray)
|
||
(exwm-systemtray-mode)
|
||
|
||
;; Mouse input/bindings
|
||
(require 'exwm-input)
|
||
|
||
;; Set number of workspaces by default
|
||
(setq exwm-workspace-number 10)
|
||
|
||
;; EXWM Randr, makes sure that the screens automatically update with the proper resolutions
|
||
;; You may want to install a program such as arandr to graphically manage the screens and resolutions, you can export it into Xrandr commands
|
||
(require 'exwm-randr)
|
||
(exwm-randr-mode)
|
||
(setq exwm-randr-workspace-monitor-plist '(0 "DP-3" 1 "DP-3" 2 "DP-3" 3 "DP-3" 4 "DP-3" 5 "HDMI-1" 6 "HDMI-1" 7 "HDMI-1" 8 "HDMI-1" 9 "HDMI-1"))
|
||
|
||
(start-process-shell-command "xrandr1" nil "xrandr --output DP-3 --mode 1920x1080 --rate 239.97")
|
||
(start-process-shell-command "xrandr2" nil "xrandr --output HDMI-1 --mode 1920x1080 --rate 60 --rotate right")
|
||
|
||
(setq exwm-workspace-warp-cursor t)
|
||
|
||
|
||
(defun exwm-switch-workspace-left ()
|
||
"Switch one workspace to the left"
|
||
(interactive)
|
||
(if (= exwm-workspace-current-index 0)
|
||
(exwm-workspace-switch (- exwm-workspace-number 1))
|
||
(exwm-workspace-switch (- exwm-workspace-current-index 1))
|
||
)
|
||
(message (concat "Switched to workspace " (number-to-string exwm-workspace-current-index) "!")))
|
||
|
||
|
||
(defun exwm-switch-workspace-right ()
|
||
"Switch one workspace to the right"
|
||
(interactive)
|
||
(if (= exwm-workspace-current-index (- exwm-workspace-number 1))
|
||
(exwm-workspace-switch 0)
|
||
(exwm-workspace-switch (+ exwm-workspace-current-index 1))
|
||
)
|
||
(message (concat "Switched to workspace " (number-to-string exwm-workspace-current-index) "!")))
|
||
|
||
(defun exwm-swap-workspace-left ()
|
||
"Swap current workspace with the workspace to the left"
|
||
(interactive)
|
||
(if (= exwm-workspace-current-index 0)
|
||
(exwm-workspace-swap exwm-workspace--current (exwm-workspace--workspace-from-frame-or-index (- exwm-workspace-number 1)))
|
||
(exwm-workspace-swap exwm-workspace--current (exwm-workspace--workspace-from-frame-or-index (- exwm-workspace-current-index 1)))
|
||
)
|
||
(message (concat "Swapped current workspace with workspace " (number-to-string exwm-workspace-current-index) "!")))
|
||
|
||
(defun exwm-swap-workspace-right ()
|
||
"Swap current workspace with the workspace to the right"
|
||
(interactive)
|
||
(if (= exwm-workspace-current-index (- exwm-workspace-number 1))
|
||
(exwm-workspace-swap exwm-workspace--current (exwm-workspace--workspace-from-frame-or-index 0))
|
||
(exwm-workspace-swap exwm-workspace--current (exwm-workspace--workspace-from-frame-or-index (+ exwm-workspace-current-index 1)))
|
||
)
|
||
(message (concat "Swapped current workspace with workspace " (number-to-string exwm-workspace-current-index) "!")))
|
||
|
||
;; Rename EXWM buffers with window title so they are all identifiable/unique
|
||
(defun exwm-rename-buffer ()
|
||
(interactive)
|
||
(exwm-workspace-rename-buffer
|
||
(concat exwm-class-name ":"
|
||
(if (<= (length exwm-title) 50) exwm-title
|
||
(concat (substring exwm-title 0 49) "...")))))
|
||
|
||
;; Add these hooks in a suitable place (e.g., as done in exwm-config-default)
|
||
(add-hook 'exwm-update-class-hook 'exwm-rename-buffer)
|
||
(add-hook 'exwm-update-title-hook 'exwm-rename-buffer)
|
||
|
||
;; Keybindings
|
||
(setq exwm-input-global-keys
|
||
`(;; Standard EXWM Bindings
|
||
|
||
;; Reset EXWM
|
||
([?\s-r] . exwm-reset)
|
||
|
||
;; EXWM Workspace Switcher
|
||
([?\s-w] . exwm-workspace-switch)
|
||
|
||
,@(mapcar (lambda (i)
|
||
`(,(kbd (format "s-%d" i)) .
|
||
(lambda ()
|
||
(interactive)
|
||
(exwm-workspace-switch-create ,i))))
|
||
(number-sequence 0 9))
|
||
|
||
;; Switch between char and line mode mode switcher
|
||
;; Char mode allows for practically all keybindings to be passed to the application aside from a few essential keybindings, line mode allows for emacs keybindings
|
||
([?\s-i] . exwm-input-toggle-keyboard)
|
||
|
||
;; Switch one workspace to the left
|
||
([?\M-h] . exwm-switch-workspace-left)
|
||
|
||
;; Switch one workspace to the right
|
||
([?\M-l] . exwm-switch-workspace-right)
|
||
|
||
;; Swap current workspace with one workspace to the left
|
||
([?\M-H] . exwm-swap-workspace-left)
|
||
|
||
;; Swap current workspace with one workspace to the left
|
||
([?\M-L] . exwm-swap-workspace-right)
|
||
|
||
;; Kill current buffer
|
||
([?\M-w] . kill-current-buffer)
|
||
|
||
;; Bindings for Edwina
|
||
|
||
;; Select next window in stack
|
||
;;([?\s-n] . edwina-select-next-window)
|
||
|
||
;; Select previous window in stack
|
||
;;([?\s-p] . edwina-select-previous-window)
|
||
|
||
;; Swap current window with next window in stack
|
||
;; ([?\s-N] . edwina-swap-next-window)
|
||
|
||
;; Swap current window with previous window in stack
|
||
;;([?\s-P] . edwina-swap-previous-window)
|
||
|
||
;; Make a new window in the stack
|
||
;;([?\s-b] . (lambda ()
|
||
;; (interactive)
|
||
;; (edwina-clone-window)
|
||
;; (edwina-select-next-window)))
|
||
|
||
))
|
||
|
||
;; Could not integrate these into the exwm global keys variable, for some reason they do not work in NIXOS
|
||
(exwm-input-set-key (kbd "M-d") 'counsel-linux-app)
|
||
|
||
(exwm-input-set-key (kbd "C-M-p") 'ivy-pass)
|
||
|
||
(exwm-input-set-key (kbd "<M-RET>") 'eshell)
|
||
|
||
(exwm-input-set-key (kbd "M-E") '(start-process-shell-command "pkill" nil "pkill emacs"))
|
||
|
||
;; (exwm-input-set-key (kbd "s-i") 'exwm-input-toggle-keyboard)
|
||
|
||
;; (exwm-input-set-key (kbd "s-h") 'exwm-switch-workspace-left)
|
||
|
||
;; (exwm-input-set-key (kbd "s-l") 'exwm-switch-workspace-right)
|
||
|
||
;; (exwm-input-set-key (kbd "s-H") 'exwm-swap-workspace-left)
|
||
|
||
;; (exwm-input-set-key (kbd "s-L") 'exwm-swap-workspace-right)
|
||
|
||
;; Edwina bindings
|
||
|
||
;; Increase master column size
|
||
;;(exwm-input-set-key (kbd "s-=") 'edwina-inc-mfact)
|
||
|
||
;; Increase master column size
|
||
;;(exwm-input-set-key (kbd "s--") 'edwina-dec-mfact)
|
||
|
||
;; Increase number of windows in master stack
|
||
;;(exwm-input-set-key (kbd "s-+") 'edwina-inc-nmaster)
|
||
|
||
;; Decrease number of windows in master stack
|
||
;;(exwm-input-set-key (kbd "s-_") 'edwina-dec-nmaster)
|
||
|
||
;; Set all X windows to open in char mode by default, allowing to pass through all key combinations
|
||
;;(add-hook 'exwm-manage-finish-hook
|
||
;; (lambda () (call-interactively #'exwm-input-release-keyboard)
|
||
;; ;;(exwm-layout-hide-mode-line)
|
||
;; ))
|
||
|
||
;; Set all X windows to open in line mode by default, allowing emacs to have control over keybinds first
|
||
(add-hook 'exwm-manage-finish-hook
|
||
(lambda () (call-interactively #'exwm-input-grab-keyboard)
|
||
;;(exwm-layout-hide-mode-line)
|
||
))
|
||
|
||
;; Ido mode seems to be enabled in the default configuration, turn it back off as we are using Ivy completion instead.
|
||
(ido-mode -1)
|
||
)
|
||
+END_SRC
|
||
|
||
|
||
*** Counsel Linux Application
|
||
Counsel Linux Application is an application launcher for emacs using counsel (which is ivy).
|
||
|
||
Install the package, enable it and ensure that it always is installed, and then configure:
|
||
#+BEGIN_SRC emacs-lisp
|
||
;; some customization to make the display "nicer" and include any user local .desktop files
|
||
|
||
(push (concat (getenv "HOME") "/.local/share/applications/") counsel-linux-apps-directories)
|
||
(defun ds/counsel-linux-app-format-function (name comment exec)
|
||
"Default Linux application name formatter.
|
||
NAME is the name of the application, COMMENT its comment and EXEC
|
||
the command to launch it."
|
||
(format "% -45s %s"
|
||
(propertize name 'face 'font-lock-builtin-face)
|
||
(or comment "")))
|
||
(setq counsel-linux-app-format-function #'ds/counsel-linux-app-format-function)
|
||
#+END_SRC
|