485 lines
15 KiB
Org Mode
485 lines
15 KiB
Org Mode
#+AUTHOR: qorg11
|
|
#+TITLE: emacs config
|
|
|
|
* qorg's Emacs config
|
|
|
|
This is my Emacs configuration. Hope you like it.
|
|
|
|
** Installation
|
|
|
|
Just copy this repository to your .emacs.d. Nothing else is needed.
|
|
|
|
** Why?
|
|
* I can
|
|
* I don't like doom emacs
|
|
* I don't like spacemacs
|
|
* I don't want to learn doom emacs
|
|
* I don't want to learn spacemacs
|
|
* I don't like Vim
|
|
** About me
|
|
Here I set variables about personal information i'll use later in
|
|
this config.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq name "qorg11")
|
|
(setq email "qorg@vxempire.xyz")
|
|
(setq website "qorg11.net")
|
|
#+END_SRC
|
|
** Dependencies
|
|
The only no emacs related dependence in this configuration is the
|
|
IBM Plex Mono font. Install it from your distribution packages.
|
|
You can change it before opening Emacs with this configuration for
|
|
the first time.
|
|
|
|
For irony-mode (C autocompletion) irony-sever must be
|
|
installed. You can install it with M-x irony-install-server or via
|
|
distribution's packages, in Debian case, apt install irony-server.
|
|
Using M-x irony-install-server requires cmake and a lot of
|
|
dependences I'm to lazy to install.
|
|
|
|
* melpa crap, and basic packages installation
|
|
melpa, where you get the packages. This also installs use-package,
|
|
and other packages I use.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(require 'package)
|
|
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
|
|
(not (gnutls-available-p))))
|
|
(proto (if no-ssl "http" "https")))
|
|
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
|
|
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
|
|
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
|
|
(when (< emacs-major-version 24)
|
|
;; For important compatibility libraries like cl-lib
|
|
(add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
|
|
|
|
(if (< emacs-major-version 27)
|
|
(package-initialize))
|
|
(unless (package-installed-p 'use-package)
|
|
(package-refresh-contents)
|
|
(package-install 'use-package))
|
|
#+END_SRC
|
|
** Generic packages
|
|
Here I install some packages that don't need configuration.
|
|
Remember to run M-x all-the-icons-install-fonts after the first
|
|
init to install the fonts.
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package markdown-mode
|
|
:ensure t)
|
|
(use-package web-mode
|
|
:ensure t)
|
|
(use-package magit
|
|
:ensure t)
|
|
(use-package all-the-icons
|
|
:ensure t)
|
|
(use-package which-key
|
|
:ensure t
|
|
:init (which-key-mode))
|
|
#+END_SRC
|
|
* Autoindentation
|
|
C-c n for indent-buffer. I don't use the rest.
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defun untabify-buffer ()
|
|
(interactive)
|
|
(untabify (point-min) (point-max)))
|
|
|
|
(defun indent-buffer ()
|
|
(interactive)
|
|
(indent-region (point-min) (point-max)))
|
|
|
|
(defun cleanup-buffer ()
|
|
"Perform a bunch of operations on the whitespace content of a buffer.
|
|
Including indent-buffer, which should not be called automatically on save."
|
|
(interactive)
|
|
(untabify-buffer)
|
|
(delete-trailing-whitespace)
|
|
(indent-buffer))
|
|
#+END_SRC
|
|
|
|
* Shorcuts
|
|
Probably this overwrites another keybinding. But since I overwrited
|
|
it. I don't think i'd ever use the overwritten.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(global-set-key (kbd "C-c n") 'cleanup-buffer)
|
|
(global-set-key (kbd "M-m") 'mark-whole-buffer)
|
|
(use-package sudo-edit
|
|
:ensure t
|
|
:init
|
|
(global-set-key (kbd "C-x C-r") 'sudo-edit-find-file))
|
|
#+END_SRC
|
|
|
|
* No idea
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq package-enable-at-startup nil) (package-initialize)
|
|
|
|
(setq make-backup-files nil) ; stop creating backup~ files
|
|
(setq auto-save-default nil) ; stop creating #autosave# files
|
|
(put 'upcase-region 'disabled nil)
|
|
|
|
|
|
(defun contextual-menubar (&optional frame)
|
|
"Display the menubar in FRAME (default: selected frame) if on a
|
|
graphical display, but hide it if in terminal."
|
|
(interactive)
|
|
(set-frame-parameter frame 'menu-bar-lines
|
|
(if (display-graphic-p frame)
|
|
1 0)))
|
|
|
|
(add-hook 'after-make-frame-functions 'contextual-menubar)
|
|
(use-package zencoding-mode
|
|
:ensure t
|
|
:init
|
|
(add-hook 'sgml-mode-hook 'zencoding-mode))
|
|
(setq-default dired-details-hidden-string "---- ")
|
|
|
|
;; (icomplete-mode 1) Deprecated, used ido-mode instead
|
|
#+END_SRC
|
|
|
|
* customization
|
|
Emacs customization, Here is where most of the configuration is.
|
|
** Disable bars font and pandoc export optxions.
|
|
Basic customization. I also use smex instead of default M-x. I
|
|
don't like heml
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(scroll-bar-mode -1)
|
|
(tool-bar-mode -1)
|
|
(menu-bar-mode -1)
|
|
(set-frame-font "Terminus 14" nil t)
|
|
(load-file "~/.emacs.d/markup.el")
|
|
(use-package smex
|
|
:ensure t
|
|
:init
|
|
(global-set-key (kbd "M-x") 'smex))
|
|
|
|
(setq-default major-mode 'text-mode)
|
|
#+END_SRC
|
|
*** Space to - (Like normal M-x)
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defadvice smex (around space-inserts-hyphen activate compile)
|
|
|
|
(let ((ido-cannot-complete-command
|
|
`(lambda ()
|
|
(interactive)
|
|
(if (string= " " (this-command-keys))
|
|
(insert ?-)
|
|
(funcall ,ido-cannot-complete-command)))))
|
|
ad-do-it))
|
|
#+END_SRC
|
|
|
|
** Highlight matching parentheses
|
|
#+BEGIN_SRC emacs-lisp
|
|
(show-paren-mode 1)
|
|
(setq show-paren-style 'mixed)
|
|
|
|
(setq startup/gc-cons-threshold gc-cons-threshold)
|
|
(setq gc-cons-threshold most-positive-fixnum)
|
|
(defun startup/reset-gc () (setq gc-cons-threshold startup/gc-cons-threshold))
|
|
(add-hook 'emacs-startup-hook 'startup/reset-gc)
|
|
#+END_SRC
|
|
** Open pdf using zathura
|
|
I don't know how necessary this is. But I use it when working with
|
|
pandoc and that kind of crap.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(defun open-pdf()
|
|
(interactive)
|
|
(setq file (buffer-substring (mark) (point)))
|
|
(shell-command (concat "zathura " file "&")
|
|
))
|
|
;; Borders
|
|
(set-face-attribute 'fringe nil
|
|
:foreground (face-foreground 'default)
|
|
:background (face-background 'default))
|
|
#+END_SRC
|
|
** org-mode
|
|
org-mode is a markup language which has a lot of stuff (This config
|
|
file is written in org-mode.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package org-bullets
|
|
:ensure t
|
|
:init
|
|
(if (display-graphic-p)
|
|
(add-hook 'org-mode-hook 'org-bullets-mode))
|
|
(setq org-hide-emphasis-markers t)
|
|
(setq org-src-window-setup 'current-window))
|
|
#+END_SRC
|
|
|
|
** Relative lines
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package linum-relative
|
|
:ensure t
|
|
:init
|
|
(setq-default display-line-numbers-type 'relative
|
|
display-line-numbers-current-relative t
|
|
display-line-numbers-width 1
|
|
display-line-numbers-widen t)
|
|
|
|
(add-hook 'text-mode-hook #'display-line-numbers-mode)
|
|
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
|
|
(column-number-mode 1))
|
|
#+END_SRC
|
|
** Flycheck
|
|
Flycheck is a syntax validator or somehting like that
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package flycheck
|
|
:ensure t
|
|
:init
|
|
(add-hook 'after-init-hook #'global-flycheck-mode))
|
|
#+END_SRC
|
|
** theme
|
|
Emacs theme, among other things.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package laguna-theme
|
|
:ensure t
|
|
:init
|
|
(load-theme 'laguna t))
|
|
|
|
|
|
(custom-set-faces
|
|
'(org-block
|
|
((t (:background "#333")))))
|
|
|
|
;; Org mode fixes
|
|
(let* ((variable-tuple (cond ((x-list-fonts "Terminus") '(:font "Terminus"))
|
|
((x-list-fonts "Terminus") '(:font "Terminus"))
|
|
((x-list-fonts "Terminus") '(:font "Terminus"))
|
|
((x-family-fonts "Terminus") '(:family "Terminus"))
|
|
(nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro."))))
|
|
(base-font-color (face-foreground 'default nil 'default))
|
|
(headline `(:inherit default :weight bold :foreground ,base-font-color)))
|
|
|
|
(custom-theme-set-faces 'user
|
|
`(org-level-8 ((t (,@headline ,@variable-tuple))))
|
|
`(org-level-7 ((t (,@headline ,@variable-tuple))))
|
|
`(org-level-6 ((t (,@headline ,@variable-tuple))))
|
|
`(org-level-5 ((t (,@headline ,@variable-tuple))))
|
|
`(org-level-4 ((t (,@headline ,@variable-tuple :height 1))))
|
|
`(org-level-3 ((t (,@headline ,@variable-tuple :height 1.1))))
|
|
`(org-level-2 ((t (,@headline ,@variable-tuple :height 1.3))))
|
|
`(org-level-1 ((t (,@headline ,@variable-tuple :height 1.5))))
|
|
`(org-document-title ((t (,@headline ,@variable-tuple :height 1.5 :underline nil))))))
|
|
#+END_SRC
|
|
** AucTeX
|
|
This basically opens zathura when compiling with auctex (C-c C-a)
|
|
#+BEGIN_SRC emacs-lisp
|
|
(with-eval-after-load 'tex
|
|
(setq TeX-source-correlate-method 'synctex)
|
|
(TeX-source-correlate-mode)
|
|
(setq TeX-source-correlate-start-server t)
|
|
|
|
(add-to-list 'TeX-view-program-selection
|
|
'(output-pdf "Zathura")))
|
|
#+END_SRC
|
|
** Shell
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq shell "/bin/bash")
|
|
(defadvice ansi-term (before force-bash)
|
|
(interactive (list shell)))
|
|
(ad-activate 'ansi-term)
|
|
|
|
#+END_SRC
|
|
** Swiper
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package swiper
|
|
:ensure t
|
|
:init
|
|
(global-set-key "\C-s" 'swiper))
|
|
|
|
#+END_SRC
|
|
** Company and Irony
|
|
Some shit for autocompletion and that kind of shit.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package company
|
|
:ensure t
|
|
:config
|
|
(setq company-idle-delay 0)
|
|
(setq company-minimum-prefix-length 3)
|
|
(global-company-mode))
|
|
(with-eval-after-load 'company
|
|
(define-key company-active-map (kbd "M-n") nil)
|
|
(define-key company-active-map (kbd "M-p") nil)
|
|
(define-key company-active-map (kbd "C-n") #'company-select-next)
|
|
(define-key company-active-map (kbd "C-p") #'company-select-previous))
|
|
|
|
(use-package company-irony
|
|
:ensure t
|
|
:config
|
|
(require 'company)
|
|
(add-to-list 'company-backends 'company-irony))
|
|
|
|
(use-package irony
|
|
:ensure t
|
|
:config
|
|
(add-hook 'c-mode-hook 'irony-mode)
|
|
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
|
|
(with-eval-after-load 'company
|
|
(add-hook 'c-mode-hook 'company-mode))
|
|
#+END_SRC
|
|
** Yasnippet
|
|
Sometimes i'm just to lazy to write.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package yasnippet
|
|
:ensure t
|
|
:init
|
|
(yas-global-mode 1))
|
|
(use-package yasnippet-snippets
|
|
:ensure t)
|
|
#+END_SRC
|
|
** Idk what to name this
|
|
Here I put things you can do in M-x or something idk
|
|
#+BEGIN_SRC emacs-lisp
|
|
(blink-cursor-mode 0)
|
|
(global-hl-line-mode 1)
|
|
(setq-default cursor-type 'bar)
|
|
#+END_SRC
|
|
** Programming language things
|
|
*** Lisp
|
|
Parentheses highlight in lisp modes. So you can easily identify
|
|
them.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package rainbow-delimiters
|
|
:ensure t
|
|
:init
|
|
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
|
|
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
|
|
(add-hook 'scheme-mode-hook 'rainbow-delimiters-mode))
|
|
|
|
#+END_SRC
|
|
*** Perl
|
|
Cperl-mode is better than perl-mode. You can't change my mind.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(defalias 'perl-mode 'cperl-mode)
|
|
|
|
#+END_SRC
|
|
*** C*
|
|
This use c-eldoc mode so it prints the function's prototype in the
|
|
minibuffer. Which is very useful since Irony works when it wants
|
|
to.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package c-eldoc
|
|
:ensure t
|
|
:init
|
|
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode))
|
|
|
|
#+END_SRC
|
|
|
|
** Beacon mode
|
|
's cool
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package beacon
|
|
:ensure t
|
|
:init(beacon-mode 1))
|
|
#+END_SRC
|
|
** erc
|
|
Erc is an irc client that is used inside emacs.
|
|
Here I configure it.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq erc-default-server website)
|
|
(setq erc-nick name)
|
|
|
|
#+END_SRC
|
|
** Extra functions
|
|
Here I put functions I won't bother to document because they're so
|
|
simple.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(defun git-pushall ()
|
|
(interactive)
|
|
(shell-command "git pushall"))
|
|
|
|
(defun kill-inner-word ()
|
|
(interactive)
|
|
(forward-word 1)
|
|
(backward-word)
|
|
(kill-word 1))
|
|
(global-set-key (kbd "M-C-k") 'kill-inner-word)
|
|
#+END_SRC
|
|
** Weechat
|
|
erc sucks, irc sucks, weechat does not. (see [[https://github.com/bqv/weechat.el/tree/rx-range][this]])
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq directory "~/.emacs.d/elpa/weechat-20190520.1551/Makefile")
|
|
|
|
(if (file-exists-p directory)
|
|
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/weechat/weechat-20190520.1551")(require 'weechat)))
|
|
#+END_SRC
|
|
** Tree
|
|
Emacs sidebar. soykafy but it works
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package treemacs
|
|
:ensure t
|
|
:init
|
|
(global-set-key [f8] 'treemacs))
|
|
#+END_SRC
|
|
** C-2 to matching parentheses
|
|
This make the C-2 show the matching parenthesis. like % in Vi.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(global-set-key (kbd "C-2") 'match-paren)
|
|
|
|
(defun match-paren (arg)
|
|
"Go to the matching paren if on a paren; otherwise insert %."
|
|
(interactive "p")
|
|
(cond ((looking-at "\\s(") (forward-list 1) (backward-char 1))
|
|
((looking-at "\\s)") (forward-char 1) (backward-list 1))
|
|
(t (self-insert-command (or arg 1)))))
|
|
|
|
|
|
#+END_SRC
|
|
** Hunspell
|
|
For some reason, there is no ispell spanish in void linux. so i had
|
|
to fallback to hunspell. which does the same.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(defvar ispell-program-name "hunspell") ;; Or whatever you use
|
|
;; (ispell, aspell...)
|
|
|
|
#+END_SRC
|
|
* ido
|
|
Ido is a replacement for keybindings such as C-x C-f and C-x b. Here
|
|
I rebinded C-x C-b to ido-switch-buffer because I always press C-x
|
|
C-b instead of C-x b
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package ido-vertical-mode
|
|
:ensure t
|
|
:init
|
|
(setq ido-enable-flex-matching nil)
|
|
(setq ido-create-new-buffer 'always)
|
|
(setq ido-everywhere t)
|
|
(ido-mode 1)
|
|
(ido-vertical-mode 1)
|
|
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
|
|
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer))
|
|
|
|
|
|
#+END_SRC
|
|
|
|
* Dashboard
|
|
Dashboard. You can change
|
|
~/.emacs.d/img/logo.png
|
|
own logo instead of Lain.
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package dashboard
|
|
:ensure t
|
|
:init
|
|
(dashboard-setup-startup-hook)
|
|
(setq dashboard-items '((recents . 5)
|
|
(bookmarks . 5)))
|
|
(setq dashboard-startup-banner 'logo)
|
|
(setq dashboard-banner-logo-title "Welcome to Editor MACroS")
|
|
(setq dashboard-startup-banner "~/.emacs.d/img/logo.png")
|
|
(setq dashboard-set-heading-icons t)
|
|
(setq dashboard-set-file-icons t))
|
|
#+END_SRC
|
|
* Doom Emacs line
|
|
Doom-modeline, because emacs default bar sucks
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package doom-modeline
|
|
:ensure t
|
|
:init(doom-modeline-mode 1))
|
|
#+END_SRC
|
|
|
|
* Screenshot
|
|
|
|
[[./screenshot.png]]
|
|
|
|
|