emacs.d

bloated emacs configuration
git clone git://git.ckyln.com/~cem/emacs.d.git
Log | Files | Refs | README

commit 635c5ec691ce076d8ede6ca2159c6806afdd6b17
parent 62f3404403c361c8c7efa5456c5a30e5e0b6feea
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  2 Mar 2020 22:56:15 +0300

move configuration to init.org

Diffstat:
AREADME.org | 2++
Minit.el | 43+++++++++++++------------------------------
Ainit.org | 349+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dlisp.d/10-format.el | 4----
Dlisp.d/20-company.el | 12------------
Dlisp.d/20-evil.el | 15---------------
Dlisp.d/20-extra.el | 12------------
Dlisp.d/20-flycheck.el | 7-------
Dlisp.d/20-magit.el | 12------------
Dlisp.d/20-markdown.el | 3---
Dlisp.d/20-orgmode.el | 31-------------------------------
Dlisp.d/20-yasnippet.el | 10----------
Dlisp.d/30-dired.el | 4----
Dlisp.d/40-filetype.el | 15---------------
Dlisp.d/99-settings.el | 12------------
15 files changed, 364 insertions(+), 167 deletions(-)

diff --git a/README.org b/README.org @@ -0,0 +1 @@ +init.org+ \ No newline at end of file diff --git a/init.el b/init.el @@ -1,30 +1,13 @@ -;;; init.el -;;; Cem Keylan - -;; Disable the clutter -(menu-bar-mode 0) -(when (display-graphic-p) - (tool-bar-mode 0) - (scroll-bar-mode 0) -) - -;; move custom-file -(setq custom-file "~/.emacs.d/lisp.d/01-custom.el") - -;; Line number binding -(global-set-key (kbd "C-c r") 'linum-relative-mode) - -;; Packages - -(require 'package) -(add-to-list 'package-archives - '("melpa" . "https://melpa.org/packages/")) -(package-initialize) -(unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package)) - -(setq use-package-compute-statistics t) - -(dolist (file (directory-files (expand-file-name "lisp.d" user-emacs-directory) t "\.el$" nil)) - (load file)) +;; This file replaces itself with the actual configuration at first run. +;; Originally from github.com/larstvei/dot-emacs + +;; We can't tangle without org! +(require 'org) +;; Open the configuration +(find-file (concat user-emacs-directory "init.org")) +;; tangle it +(org-babel-tangle) +;; load it +(load-file (concat user-emacs-directory "init.el")) +;; finally byte-compile it +(byte-compile-file (concat user-emacs-directory "init.el")) diff --git a/init.org b/init.org @@ -0,0 +1,349 @@ +#+TITLE: Emacs Configuration +#+AUTHOR: Cem Keylan +#+BABEL: :cache yes +#+PROPERTY: header-args :tangle yes + +* Intro +This is my emacs configuration file, I used to have a big +directory of lisp code but it became harder to maintain +and keep track of. That's way I have created this org-mode +init file. + +** Installation Instructions + +If you want to use my emacs configuration, it is pretty simple +to get started. Simply clone the repository and start emacs! + +#+BEGIN_SRC sh :tangle no +# Move your old configuration (if you have one) +mv $HOME/.emacs.d $HOME/.emacs.d.bak + +# Clone the repository +git clone git://git.ckyln.com/emacs.d $HOME/.emacs.d + +# Start emacs +emacs +#+END_SRC + +This will probably take a while, especially because it is +setting up for the first time. You might need to restart +emacs after the initial configuration is done. + +** Meta + +To load init.el properly we run a function such as this. + +#+BEGIN_SRC emacs-lisp + (defun tangle-init () + "If the current buffer is 'init.org' the code-blocks are + tangled, and the tangled file is compiled." + (when (equal (buffer-file-name) + (expand-file-name (concat user-emacs-directory "init.org"))) + ;; Avoid running hooks when tangling. + (let ((prog-mode-hook nil)) + (org-babel-tangle) + (byte-compile-file (concat user-emacs-directory "init.el"))))) + + (add-hook 'after-save-hook 'tangle-init) +#+END_SRC + +* Startup Settings + +The most important stuff are (for me) is =use-package= and +disabling the clutter as soon as possible. By clutter, I mean +bars and menus. + + +#+BEGIN_SRC emacs-lisp +(menu-bar-mode 0) +#+END_SRC + +I also want to disable tool-bar and scrollbar but that will +give an error on emacs-nox. This is a workaround. + + +#+BEGIN_SRC emacs-lisp +(when (display-graphic-p) + (tool-bar-mode 0) + (scroll-bar-mode 0) +) +#+END_SRC + +** Packages + +We need use-package for maintaining other packages. + + +#+BEGIN_SRC emacs-lisp +(require 'package) +(add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/")) +(package-initialize) +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) +#+END_SRC + +I also want to see use-package stats, but feel free to disable. + + +#+BEGIN_SRC emacs-lisp +;; (defvar use-package-compute-statistics) +;; (setq use-package-compute-statistics t) +#+END_SRC + +** Custom-file + +I don't like custom variables on my init.el, I prefer having it on +my cache folder. + +#+BEGIN_SRC emacs-lisp +(setq custom-file "~/.cache/emacs-custom.el") +#+END_SRC + +* Packages + +Now we can continue by loading our packages, those are listed according +to how important they are to me. + +** Evil-mode + +I am an old vim user, and I do not want to miss out on the beauty of vim +while I am using Emacs. Let's begin with the evil-mode itself. + + +#+BEGIN_SRC emacs-lisp +(use-package evil + :ensure t + :init + (setq evil-want-keybinding nil) + :config + (evil-mode 1)) +#+END_SRC + +We didn't ask for the keybindings yet, because we are going to get the +=evil-collection= package now. + +#+BEGIN_SRC emacs-lisp +(use-package evil-collection + :after evil + :ensure t + :config + (evil-collection-init)) +#+END_SRC + + +** Org-mode + +Org mode is one of the biggest reasons I am using Emacs, and it is a must +for me. These are my configurations. Starting with the obvious here. + +#+BEGIN_SRC emacs-lisp +(use-package org :ensure t) +#+END_SRC + +*** evil-org + +I am quite serious on this vim stuff now. I want it everywhere. + +#+BEGIN_SRC emacs-lisp +(use-package evil-org + :ensure t + :after org + :config + (add-hook 'org-mode-hook 'evil-org-mode) + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) +#+END_SRC + +Now that we have initialized those packages, let's configure them some +further. + +#+BEGIN_SRC emacs-lisp +;; Keybindings +(global-set-key (kbd "C-c l") 'org-store-link) +(global-set-key (kbd "C-c a") 'org-agenda) +(global-set-key (kbd "C-c c") 'org-capture) + +(setq org-directory "~/.org/") +(setq org-agenda-include-diary t) + +(setq org-default-notes-file "~/.notes.org") +#+END_SRC + +** Magit + +I like magit, it is quite useful when you don't want to leave emacs and +you have to manually edit hunks for specific commits. I use evil-magit +along with it. + +#+BEGIN_SRC emacs-lisp +(use-package magit + :ensure t + :config + (global-set-key (kbd "C-x g") 'magit-status)) +(use-package evil-magit + :ensure evil + :ensure magit + :after magit + :init (evil-magit-init)) +#+END_SRC + +** Flycheck + +I use flycheck for async syntax and error checking. It can be really useful +and adds to the IDE-likeness of Emacs. I find things like these to be really +hacky and buggy on Vim. + +#+BEGIN_SRC emacs-lisp +(use-package flycheck + :ensure t + :config + (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) + :init (global-flycheck-mode)) +#+END_SRC + +** Company Mode + +Company is a tool that I am still very unfamiliar with. I used to +have completion tools on Vim, but I don't understand company that +much yet. Pretty simple config. + +#+BEGIN_SRC emacs-lisp +(use-package company + :ensure t + :init (global-company-mode 1)) +#+END_SRC + +*** Company LSP + +I am using Company's own Language Server Protocol. It is good as +far as I can wrap my head-around. + +#+BEGIN_SRC emacs-lisp +(use-package company-lsp + :ensure t + :after company + :config + (push 'company-lsp company-backends)) +#+END_SRC + +** Extras + +These don't really deserve their own sections, but I prefer to use them. + +*** sudo-edit + +This is a package for re-initiating a file as root. + +#+BEGIN_SRC emacs-lisp +(use-package sudo-edit :ensure t) +#+END_SRC + +*** linum-relative +I just like seeing the current line number and the relatives of +the other lines. + +#+BEGIN_SRC emacs-lisp +(use-package linum-relative + :ensure t + :config + (setq linum-relative-current-symbol "") + :init (linum-relative-mode 1)) +#+END_SRC + +*** elfeed + +I have elfeed which I have connected to my Nextcloud account, it +is nice to have something synced. + +#+BEGIN_SRC emacs-lisp +(use-package elfeed :ensure t) +#+END_SRC + +*** markdown-mode + +I sometimes use this to test the HTML output of markdown documents +that I write. + +#+BEGIN_SRC emacs-lisp +(use-package markdown-mode + :ensure t + :config (setq markdown-command "/usr/bin/markdown")) +#+END_SRC + +* Filetype Configurations + +I would like to have some different configurations for filetypes. Those +are for indents and spaces, mostly. + +** Default Formatting + +Here is the default formatting for most files. I don't like tabs as indents +so I avoid them wherever I can. + +#+BEGIN_SRC emacs-lisp +(setq-default indent-tabs-mode nil + tab-width 8 + fill-column 80) +#+END_SRC + +** Markdown + +For markdown, I want to have 4 spaces as an indentation. + +#+BEGIN_SRC emacs-lisp +(defvar md-indent-tabs-mode) +(defvar md-tab-width) +(setq md-indent-tabs-mode nil) +(setq md-tab-width 4) +#+END_SRC + +** Shell + +For shell, I want to have 4 spaces as an indentation. + +#+BEGIN_SRC emacs-lisp +(defvar sh-indent-tabs-mode) +(defvar sh-tab-width) +(setq sh-indent-tabs-mode nil) +(setq sh-tab-width 4) +#+END_SRC + +* Other Settings + +Those are small settings for emacs that I cannot categorize but have importance +for me. + +** Dired -- ls dired + +I use suckless.org's =sbase= as my coreutils. The =ls= program that I use does +not have a =--dired= option. Let's disable it. + +#+BEGIN_SRC emacs-lisp +(defvar dired-use-ls-dired) +(setq dired-use-ls-dired nil) +#+END_SRC + +** Backup Options + +#+BEGIN_SRC emacs-lisp +(setq backup-directory-alist `(("." . "~/.cache/emacs/saves"))) +#+END_SRC + +** Enable diary appointment alarms + +#+BEGIN_SRC emacs-lisp +(appt-activate 1) +#+END_SRC + +** Set Browser + +I am setting the default browser from the BROWSER environment variable +so that I don't have to keep track of it in case I ever change my browser. + +#+BEGIN_SRC emacs-lisp +(setq browse-url-generic-program + (executable-find (getenv "BROWSER")) + browse-url-browser-function 'browse-url-generic) +#+END_SRC diff --git a/lisp.d/10-format.el b/lisp.d/10-format.el @@ -1,4 +0,0 @@ -;; Indentation -(setq-default indent-tabs-mode nil - tab-width 8 - fill-column 80) diff --git a/lisp.d/20-company.el b/lisp.d/20-company.el @@ -1,12 +0,0 @@ -;; company.el - -(use-package company - :ensure t - :init (company-mode)) - -(use-package company-lsp - :ensure t - :after company - :config - (push 'company-lsp company-backends) - ) diff --git a/lisp.d/20-evil.el b/lisp.d/20-evil.el @@ -1,15 +0,0 @@ -;; evil.el - -(use-package evil - :ensure t - :init - (setq evil-want-integration t) ;; This is optional since it's already set to t by default. - (setq evil-want-keybinding nil) - :config - (evil-mode 1)) - -(use-package evil-collection - :after evil - :ensure t - :config - (evil-collection-init)) diff --git a/lisp.d/20-extra.el b/lisp.d/20-extra.el @@ -1,12 +0,0 @@ -;; Extra packages - -(use-package sudo-edit :ensure t) -(use-package aggressive-indent :ensure t) -(use-package linum-relative - ;; Use relative numbers but - ;; keep the current line's - ;; absolute number. - :ensure t - :config - (setq linum-relative-current-symbol "") - :init (linum-relative-mode 1)) diff --git a/lisp.d/20-flycheck.el b/lisp.d/20-flycheck.el @@ -1,7 +0,0 @@ -;; Flycheck -(use-package flycheck - :ensure t - :config - (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) - :init (global-flycheck-mode)) - diff --git a/lisp.d/20-magit.el b/lisp.d/20-magit.el @@ -1,12 +0,0 @@ -;; Magit - -(use-package magit :ensure t) -(use-package evil-magit - :ensure evil - :ensure t - :after evil - :init (evil-magit-init)) - -;; Magit bindings -(global-set-key (kbd "C-x g") 'magit-status) - diff --git a/lisp.d/20-markdown.el b/lisp.d/20-markdown.el @@ -1,3 +0,0 @@ -(use-package markdown-mode - :ensure t - :config (setq markdown-command "/usr/bin/markdown")) diff --git a/lisp.d/20-orgmode.el b/lisp.d/20-orgmode.el @@ -1,31 +0,0 @@ -;;orgmode.el - -(use-package org :ensure t) -(use-package evil-org - :ensure t - :after org - :config - (add-hook 'org-mode-hook 'evil-org-mode) - (require 'evil-org-agenda) - (evil-org-agenda-set-keys)) - -;; Options -;; (defvar org-directory) -;; (defvar org-mobile-directory) -;; (defvar org-mobile-inbox-for-pull) -;; (defvar org-default-notes-file) -;;(list 'org-agenda-files) -(setq org-directory "~/.org/") -(setq org-mobile-inbox-for-pull "~/.org/inbox.org") -(setq org-mobile-directory "~/orgmode/") -(setq org-agenda-include-diary t) - -(add-to-list 'org-agenda-files - '"/home/cem/.notes.org") - -(setq org-default-notes-file "~/.notes.org") - -;; Keybindings -(global-set-key (kbd "C-c l") 'org-store-link) -(global-set-key (kbd "C-c a") 'org-agenda) -(global-set-key (kbd "C-c c") 'org-capture) diff --git a/lisp.d/20-yasnippet.el b/lisp.d/20-yasnippet.el @@ -1,10 +0,0 @@ -(use-package yasnippet - :ensure t - :init - (yas-global-mode 1)) - -(use-package yasnippet-snippets - :ensure yasnippet - :after yasnippet - :ensure t ) - diff --git a/lisp.d/30-dired.el b/lisp.d/30-dired.el @@ -1,4 +0,0 @@ -;; Dired -(defvar dired-use-ls-dired) -(setq dired-use-ls-dired nil) - diff --git a/lisp.d/40-filetype.el b/lisp.d/40-filetype.el @@ -1,15 +0,0 @@ -;;; filetype.el - -;; Markdown -;; 4 Spaces for indentation -(defvar md-indent-tabs-mode) -(defvar md-tab-width) -(setq md-indent-tabs-mode nil) -(setq md-tab-width 4) - -;; Shell -;; 4 Spaces for indentation -(defvar sh-indent-tabs-mode) -(defvar sh-tab-width) -(setq sh-indent-tabs-mode nil) -(setq sh-tab-width 4) diff --git a/lisp.d/99-settings.el b/lisp.d/99-settings.el @@ -1,12 +0,0 @@ -;; settings.el - -;; Backup options -(setq backup-directory-alist `(("." . "~/.cache/emacs/saves"))) - -;; Cal/Diary -(appt-activate 1) - -;; Browser -(setq browse-url-generic-program - (executable-find (getenv "BROWSER")) - browse-url-browser-function 'browse-url-generic)