Coder Social home page Coder Social logo

dotemacs's Introduction

DotEmacs

Requirements

  • emacs 26+
  • universal-ctags

The very basics

Packages bootstrap

Set up package repositories

(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org"   . "https://orgmode.org/elpa/") t)    ;; Org-mode repo
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)  ;; MELPA
(add-to-list 'package-archives '("gnu"   . "https://elpa.gnu.org/packages/")) ;; GNU ELPA

use-package

The one package loader: it’s awesome and it will take care of everything from this point onwards.

(when (not (package-installed-p 'use-package))
    (package-refresh-contents)      ;; Initialize package index
    (package-install 'use-package)) ;; Install use-package

;; use-package: the only thing that is really needed
(eval-when-compile
    (require 'use-package)
    (setq use-package-always-ensure t)
    (setq use-package-verbose t))

which-key

Package configuration

(use-package which-key
:demand t
:config
(which-key-mode)
(setq which-key-idle-delay 0.25))

The evil Section

Let the EVIL begin! :)

(use-package evil
:demand t
:config (evil-mode 1))

Leader key setup via general.el

Define leader keys

General leader key

The general leader key is used for setting up prefixed key bindings that are going to be set globally in every evil state.

(defconst axltxl/leader-key "SPC")
axltxl/general-leader-def

Through general.el, a prefixed key binding definer is generated. This is useful for key binding definitions without having to specify a prefix every time.

(use-package general
    :demand t
    :after (evil which-key)
    :config
    (general-evil-setup t)
    (general-create-definer axltxl/general-leader-def :prefix axltxl/leader-key))
axltxl/define-key

This function relies on a key binding generator axltxl/general-leader-def and it’s ultimately used to create prefixed key bindings all throughout the configuration.

(defun axltxl/define-key (key ecmd &rest keydefs)
(axltxl/general-leader-def
    :keymaps 'override
    :states '(normal visual motion emacs)
    key ecmd)
(if keydefs (apply 'axltxl/define-key keydefs)))
Label all subprefixes

All prefixed key combinations are relabeled on which-key via general.el

(general-define-key
  :prefix axltxl/leader-key
  :keymaps 'override
  :states '(normal visual motion emacs)
  "p"  '(nil :which-key "project")
  "pc" '(nil :which-key "ctags")
  "f"  '(nil :which-key "file")
  "e"  '(nil :which-key "emacs")
  "ep" '(nil :which-key "packages")
  "b"  '(nil :which-key "buffer")
  "h"  '(nil :which-key "help")
  "hd" '(nil :which-key "describe")
  "w"  '(nil :which-key "window")
  "g"  '(nil :which-key "git")
  "j"  '(nil :which-key "jump")
  "t"  '(nil :which-key "toggle")
  "o"  '(nil :which-key "org")
  "oa" '(nil :which-key "org-agenda")
  "oc" '(nil :which-key "org-capture"))

Major mode leader key

Major mode prefixed key bindings are meant to be bound only on buffers where these major modes are applied. The bindings are usually by general as soon as a package has been loaded by use-package.

(defconst axltxl/major-mode-leader-key ",")

Configuration Workflow

Main constants

(defconst axltxl/emacs-init-file          (concat user-emacs-directory "init.el"))
(defconst axltxl/emacs-org-file           (concat user-emacs-directory "README.org"))
(defconst axltxl/emacs-org-rendered-file  (concat user-emacs-directory "README.el"))

Reload main configuration

(defun axltxl/config-restart ()
    (interactive)
    (load-file axltxl/emacs-init-file))

Prefixed Key Bindings

(axltxl/define-key "er" 'axltxl/config-restart)

Edit init.el

(defun axltxl/init-edit ()
    (interactive)
    (find-file axltxl/emacs-init-file))

Prefixed Key Bindings

(axltxl/define-key "ed" 'axltxl/init-edit)

Debug this very file (or the one rendered by org-babel)

(use-package bug-hunter :demand t)
(defun axltxl/init-debug ()
    (interactive)
    (bug-hunter-file axltxl/emacs-init-file)
    (bug-hunter-file axltxl/emacs-org-rendered-file))

Prefixed Key Bindings

(axltxl/define-key "ex" 'axltxl/init-debug)

Edit this very file

(defun axltxl/org-edit ()
    (interactive)
    (find-file axltxl/emacs-org-file))

Prefixed Key Bindings

(axltxl/define-key "eo" 'axltxl/org-edit)

Private configuration

Private configuration snippets can be loaded from a directory specified at axltxl/emacs-private-dir There, things like trying new packages or secrets and/or sensitive information can be thrown without risk of any “undesired disclosure”.

Private configuration directory
(defconst axltxl/emacs-private-dir (concat user-emacs-directory "private.d"))
Load all files in private configuration directory
(if (file-directory-p axltxl/emacs-private-dir)
    (apply 'load-file (directory-files axltxl/emacs-private-dir t "\.el$")))

Packages

auto-package-update

auto-package-udpate makes sure packages are updated as soon as there are new versions of them.

Package configuration

(use-package auto-package-update
   :config
   (setq auto-package-update-interval 7)
   (setq auto-package-update-prompt-before-update t)
   (setq auto-package-update-delete-old-versions t)
   (auto-package-update-maybe))

Prefixed key bindings

Update packages at will
(axltxl/define-key "epu" 'auto-package-update-now)

M-x

The one binding where everything begins

(axltxl/define-key "SPC" 'execute-extended-command)

Text Editing

Auto completion (company-mode)

Package configuration

(use-package company
:config
;; Let company act immediately
(setq company-idle-delay 0)

;; company-mode should be ready at all times
(add-hook 'after-init-hook 'global-company-mode)

;; Key bindings for this one
:general
( :states '(insert)
    "TAB"   'company-complete
    "M-k"   'company-select-previous
    "M-j"   'company-select-next))

flyspell-mode

flyspell-mode is used for spell checking on the fly while typing

(add-hook 'prog-mode-hook (lambda () (flyspell-prog-mode 1)))
(add-hook 'org-mode-hook (lambda () (flyspell-mode 1)))
(add-hook 'text-mode-hook (lambda () (flyspell-mode 1)))

flycheck

Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs, intended as replacement for the older Flymake extension which is part of GNU Emacs.

Package configuration

(use-package flycheck
    :config (global-flycheck-mode))

editorconfig

Package configuration

(use-package editorconfig :config (editorconfig-mode 1))

Replace yes/no prompts with y/n

(fset 'yes-or-no-p 'y-or-n-p)

Automatically revert buffers

Automatically update a buffer if a file changes on disk

(global-auto-revert-mode 1)

Show line numbers

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

No tabs

(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)

autopair

This makes sure that brace structures (), [], {}, etc. are closed as soon as the opening character is typed.

Package configuration

(use-package autopair :config (autopair-global-mode))

No blinking cursor

(blink-cursor-mode 0)

No wordwrap

No nothing, me no likey

(setq-default truncate-lines 1)

Turn on highlight matching brackets when cursor is on one

(show-paren-mode 1)

evil-unimpaired

unimpaired.vim in emacs! :)

Package configuration

(use-package evil-unimpaired
:after general
:load-path "local"
:config
(evil-unimpaired-mode))

evil-surround

vim-surround in emacs :)

Package configuration

(use-package evil-surround
:after general
:config
(global-evil-surround-mode 1))

highlight-indent-guides

Package configuration

(use-package highlight-indent-guides
:config
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
(setq highlight-indent-guides-method 'fill))

Backup files management

All backups go to a single dedicated directory

(setq backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups"))))

real-auto-save

Package configuration

(use-package real-auto-save
:config
(add-hook 'prog-mode-hook 'real-auto-save-mode)
(add-hook 'org-mode-hook 'real-auto-save-mode)
(setq real-auto-save-interval 10))

evil-nerd-commenter

Comment all the things a la nerd commenter

Package configuration

(use-package evil-nerd-commenter :after general)

Prefixed key bindings

<axltxl/leader-key> ;; does the magic

(axltxl/define-key ";" 'evilnc-comment-operator)

Text scaling

Increase/decrease font size

Prefixed Key Bindings

(use-package general
  :config
  (general-define-key
      :maps 'override
      :states '(normal visual insert motion)
      "C-}" 'text-scale-increase
      "C-{" 'text-scale-decrease))

Quite useful to know where a buffer ends

(setq-default indicate-empty-lines t)

Remove trailing whitespace upon saving a buffer

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Always write a newline at the end of a file

(setq-default require-final-newline t)

NO MOUSE via disable-mouse

Yep, that’s right!. No mouse means no mouse at all …

Package configuration

(use-package disable-mouse
:after (evil general)
:config
(global-disable-mouse-mode)
(mapc #'disable-mouse-in-keymap
(list evil-motion-state-map
        evil-normal-state-map
        evil-visual-state-map
        evil-insert-state-map)))

custom-set-variables

custom-set-variables is set on another file

(setq custom-file (concat user-emacs-directory "custom.el"))

Load custom-set-variables file

(load custom-file 'noerror)

ctags

universal-ctags configuration file location

(setq axltxl/ctags-options-file (concat user-emacs-directory "ctags.conf"))

counsel-etags

(use-package counsel-etags :after counsel
:ensure t
:bind (("C-]" . counsel-etags-find-tag-at-point))
:init
;; Don't ask before rereading the TAGS files if they have changed
(setq tags-revert-without-query t)

;; Don't warn when TAGS files are large
(setq large-file-warning-threshold nil)

;; Autoupdate tags file
(add-hook 'prog-mode-hook
    (lambda ()
    (add-hook 'after-save-hook
        'counsel-etags-virtual-update-tags 'append 'local)))
:config
(setq counsel-etags-update-interval 60)
(push "build" counsel-etags-ignore-directories)

;;Set custom configuration file
(setq counsel-etags-ctags-options-file axltxl/ctags-options-file))
(axltxl/define-key "pcf" 'counsel-etags-find-tag)
(axltxl/define-key "pcl" 'counsel-etags-list-tag)
(axltxl/define-key "pcu" 'counsel-etags-update-tags-force)
(axltxl/define-key "pcs" 'counsel-etags-scan-code)

Help

Prefixed Key Bindings

(axltxl/define-key
    "hdf" 'describe-function
    "hdb" 'general-describe-keybindings
    "hdm" 'describe-mode)

User Interface

Window Management

Windows

Enable winner-mode

(use-package winner :ensure nil :config (winner-mode))

Manipulation

Split windows
(axltxl/define-key "wv" 'split-window-right)
(axltxl/define-key "ws" 'split-window-below)
Delete window
(axltxl/define-key "wd" 'delete-window)
Balance windows
(axltxl/define-key "w=" 'balance-windows)
Maximize window
(axltxl/define-key "wm" 'maximize-window)
Use winner to undo/redo window manipulation
(axltxl/define-key "wu" 'winner-undo)
(axltxl/define-key "wr" 'winner-redo)

Navigation

(axltxl/define-key "wk" 'windmove-up)
(axltxl/define-key "wj" 'windmove-down)
(axltxl/define-key "wh" 'windmove-left)
(axltxl/define-key "wl" 'windmove-right)
ace-window

ace-window is pretty useful for quickly switching windows, even across frames!, among other cool things.

(use-package ace-window
  :init

  ;; trigger ace-window always
  (setq aw-dispatch-always t)

  ;; aw-keys are 0-9 by default, which is reasonable,
  ;; but in the setup above, the keys are on the home row.
  (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)))
Prefixed Key bindings
Turn on ace-window mode
(axltxl/define-key "ww" 'ace-window)
  

Frames

Create new frame

(axltxl/define-key "wf" 'make-frame)

Jump to frame

(axltxl/define-key "wo" 'other-frame)

Buffer Management

Files

Find a file

(axltxl/define-key "ff" 'find-file)

Save buffer to a file

(axltxl/define-key "fs" 'save-buffer)

Buffers

History

(axltxl/define-key "bp" 'previous-buffer)
(axltxl/define-key "bn" 'next-buffer)

Switching

Switch to buffer
(axltxl/define-key "bb" 'counsel-switch-buffer)
Switch to messages
(axltxl/define-key "bm" (lambda () (interactive)(switch-to-buffer "*Messages*")))
Switch to scratch
(axltxl/define-key "bs" (lambda () (interactive)(switch-to-buffer "*scratch*")))

Lifecycle

Delete buffer
(axltxl/define-key "bd" 'evil-delete-buffer)
Create buffer
(axltxl/define-key "bN" 'evil-buffer-new)
Revert buffer
(axltxl/define-key "br" 'revert-buffer)

Toggles

Whitespace

Toggle whitespace in current buffer

(axltxl/define-key "tw" 'whitespace-mode)

Display line numbers

Toggle display line numbers

(axltxl/define-key "tl" 'display-line-numbers-mode)

GUI

All GUI elements shall be removed!

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

Start frame in fullscreen mode

(custom-set-variables
'(initial-frame-alist (quote ((fullscreen . maximized)))))

Turn off ringing bells completely!

(setq ring-bell-function 'ignore)

Font settings

See: https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html

(add-to-list 'default-frame-alist
'(font . "Terminus-11"))

Theme settings

Light theme

(if (not (boundp 'axltxl/theme-light))
 (defconst axltxl/theme-light 'doom-solarized-light))

Dark theme (default)

(if (not (boundp 'axltxl/theme-dark))
 (defconst axltxl/theme-dark  'doom-dracula))
(defconst axltxl/theme-default axltxl/theme-dark)

Persistent theme through configuration reload

This will keep the current set theme from changing across configuration reloads via axltxl/config-restart command

(if (not (boundp 'axltxl/theme-current))
 (setq axltxl/theme-current axltxl/theme-default))

Toggle current theme

(defun axltxl/toggle-theme ()
    (interactive)
    (if (eq axltxl/theme-current axltxl/theme-dark)
        (setq axltxl/theme-current axltxl/theme-light)
        (setq axltxl/theme-current axltxl/theme-dark))
        (load-theme axltxl/theme-current t))

;; Key binding for axltxl/toggle-theme
(axltxl/define-key "tt" 'axltxl/toggle-theme)

doom-themes

What can I say?. They look so nice! :).

Package configuration

(use-package doom-themes :after (org neotree)
 :demand 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 current theme
 (load-theme axltxl/theme-current 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)

 ;; Corrects (and improves) org-mode's native fontification.
 (doom-themes-org-config))

doom-modeline

Set the real modeline now :)

Package configuration

(use-package doom-modeline
:demand t
:after doom-themes
:config

;; How tall the mode-line should be. It's only respected in GUI.
;; If the actual char height is larger, it respects the actual height.
(setq doom-modeline-height 32)

;; How wide the mode-line bar should be. It's only respected in GUI.
(setq doom-modeline-bar-width 3)

;; Determines the style used by `doom-modeline-buffer-file-name'.
;;
;; Given ~/Projects/FOSS/emacs/lisp/comint.el
;;   truncate-upto-project => ~/P/F/emacs/lisp/comint.el
;;   truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el
;;   truncate-with-project => emacs/l/comint.el
;;   truncate-except-project => ~/P/F/emacs/l/comint.el
;;   truncate-upto-root => ~/P/F/e/lisp/comint.el
;;   truncate-all => ~/P/F/e/l/comint.el
;;   relative-from-project => emacs/lisp/comint.el
;;   relative-to-project => lisp/comint.el
;;   file-name => comint.el
;;   buffer-name => comint.el<2> (uniquify buffer name)
;;
;; If you are expereicing the laggy issue, especially while editing remote files
;; with tramp, please try `file-name' style.
;; Please refer to https://github.com/bbatsov/projectile/issues/657.
(setq doom-modeline-buffer-file-name-style 'truncate-except-project)

;; Whether display icons in mode-line or not.
(setq doom-modeline-icon t)

;; Whether display the icon for major mode. It respects `doom-modeline-icon'.
(setq doom-modeline-major-mode-icon t)

;; Whether display color icons for `major-mode'. It respects
;; `doom-modeline-icon' and `all-the-icons-color-icons'.
(setq doom-modeline-major-mode-color-icon t)

;; Whether display icons for buffer states. It respects `doom-modeline-icon'.
(setq doom-modeline-buffer-state-icon t)

;; Whether display buffer modification icon. It respects `doom-modeline-icon'
;; and `doom-modeline-buffer-state-icon'.
(setq doom-modeline-buffer-modification-icon t)

;; Whether display minor modes in mode-line or not.
(setq doom-modeline-minor-modes nil)

;; If non-nil, a word count will be added to the selection-info modeline segment.
(setq doom-modeline-enable-word-count nil)

;; Whether display buffer encoding.
(setq doom-modeline-buffer-encoding t)

;; Whether display indentation information.
(setq doom-modeline-indent-info nil)

;; If non-nil, only display one number for checker information if applicable.
(setq doom-modeline-checker-simple-format nil)

;; The maximum displayed length of the branch name of version control.
(setq doom-modeline-vcs-max-length 12)

;; Whether display perspective name or not. Non-nil to display in mode-line.
(setq doom-modeline-persp-name t)

;; Whether display `lsp' state or not. Non-nil to display in mode-line.
(setq doom-modeline-lsp t)

;; Whether display github notifications or not. Requires `ghub` package.
(setq doom-modeline-github nil)

;; The interval of checking github.
(setq doom-modeline-github-interval (* 30 60))

;; Whether display environment version or not
(setq doom-modeline-env-version t)
;; Or for individual languages
(setq doom-modeline-env-enable-python t)
(setq doom-modeline-env-enable-ruby t)
(setq doom-modeline-env-enable-perl t)
(setq doom-modeline-env-enable-go t)
(setq doom-modeline-env-enable-elixir t)
(setq doom-modeline-env-enable-rust t)

;; Change the executables to use for the language version string
(setq doom-modeline-env-python-executable "python")
(setq doom-modeline-env-ruby-executable "ruby")
(setq doom-modeline-env-perl-executable "perl")
(setq doom-modeline-env-go-executable "go")
(setq doom-modeline-env-elixir-executable "iex")
(setq doom-modeline-env-rust-executable "rustc")

;; Whether display mu4e notifications or not. Requires `mu4e-alert' package.
(setq doom-modeline-mu4e nil)

;; Whether display irc notifications or not. Requires `circe' package.
(setq doom-modeline-irc nil)

;; Function to stylize the irc buffer names.
(setq doom-modeline-irc-stylize 'identity)

;; Let the awesomeness begin :)
(doom-modeline-mode 1))

emacs-dashboard

Seed random number generator

This is necessary for the functions that come afterwards.

(random t) ; seed random number

Select a random image

(setq axltxl/emacs-splash-dir (concat user-emacs-directory "splash"))
(setq axltxl/splash-image
(format "%s/splash%s.png" axltxl/emacs-splash-dir
    (random (- (length (directory-files axltxl/emacs-splash-dir nil "\.png$")) 1))))

Select a random title

(setq axltxl/emacs-dashboard-titles
[ "You rock today!"
    "\"Royale with cheese\" - Pulp Fiction, 1994."
    "\"Only dead fish go with the flow\" - Andy Hunt. Pragmatic Thinking and Learning."])

Package configuration

(use-package dashboard
:after general ; this one has key bindings
:demand t
:config
;; Set the title
(setq dashboard-banner-logo-title
    (aref axltxl/emacs-dashboard-titles
    (random (- (length axltxl/emacs-dashboard-titles) 1))))

;; Set the banner images
(setq dashboard-startup-banner axltxl/splash-image)

;; Content is not centered by default.
(setq dashboard-center-content t)

;; Set up agenda items from org-mode
(add-to-list 'dashboard-items '(agenda) t)
(setq show-week-agenda-p t)

;; Widgets
(setq dashboard-set-file-icons t)
(setq dashboard-items '((recents  . 5)
                        (projects . 5)
                        (agenda . 5)))

;; show info about the packages loaded and the init time
(setq dashboard-set-init-info t)

;; No footer
(setq dashboard-set-footer nil)

;; Start it up
(dashboard-setup-startup-hook))

ivy

Package configuration

(use-package wgrep)
(use-package counsel
:demand t
:after (general wgrep projectile)

;; Configuration
:config
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(setq ivy-height 10)

;; integration with projectile
(setq projectile-completion-system 'ivy)

;; start it up
(ivy-mode 1)

;; Key bindings for this layer
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
:general

;; Replace standard vi-style search with swiper
(:states '(normal motion emacs)
 "/" 'swiper)

;; swiper minor modes key bindings
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(:keymaps 'swiper-map
 :prefix axltxl/major-mode-leader-key
 "r"   'swiper-query-replace)

;; Navigation within ivy-based buffers
;; (like counsel for example)
(:keymaps 'ivy-mode-map
    "M-j" 'ivy-next-line
    "M-k" 'ivy-previous-line
    "M-l" 'ivy-alt-done
    "M-h" 'ivy-backward-delete-char))

Prefixed Key Bindings

(axltxl/define-key "p/" 'counsel-git-grep)

neotree

Package configuration

(use-package neotree :after (general projectile)
 :demand t

 ;; Key bindings for this one
 :general
 ( :states '(motion normal)
     :keymaps 'neotree-mode-map
     "ov"  'neotree-enter-vertical-split
     "os"  'neotree-enter-horizontal-split
     "RET" 'neotree-enter
     "c"   'neotree-create-node
     "r"   'neotree-rename-node
     "d"   'neotree-delete-node
     "y"   'neotree-copy-node
     "h"   'neotree-select-up-node
     "gr"  'neotree-refresh
     "C"   'neotree-change-root
     "H"   'neotree-hidden-file-toggle
     "q"   'neotree-hide
     "l"   'neotree-enter)

 ;; Configuration
 :config

 ;; all-the-icons support
 (setq neo-theme (if (display-graphic-p) 'icons 'arrow)))

 ;; Always show hidden files
 (setq neo-show-hidden-files t)

 ;; Hide cursor in NeoTree buffer and turn on line higlight
 (setq neo-hide-cursor t)

 ;; Update neotree buffer automatically
 (setq neo-autorefresh t)

 ;; No modeline for this one
 (setq neo-mode-line-type 'none)

Prefix Key Bindings

Toggle neotree
(axltxl/define-key "TAB" 'neotree-toggle)
Open neotree at project location set by projectile

Similar to find-file-in-project, NeoTree can be opened (toggled) at projectile project root as follows:

(defun neotree/project-dir ()
"Open NeoTree using the git root."
(interactive)
(let ((project-dir (projectile-project-root))
        (file-name (buffer-file-name)))
    (neotree-toggle)
    (if project-dir
    (if (neo-global--window-exists-p)
        (progn
        (neotree-dir project-dir)
        (neotree-find file-name)))
    (message "Could not find git project root."))))
(axltxl/define-key "pt" 'neotree/project-dir)

Org Mode (or how do I organize my life)

Directory locations

(defconst axltxl/org-home "~/org/")
(defconst axltxl/org-journal-dir (concat axltxl/org-home "journal/"))

;; org-capture templates directory
(defconst org-tpl-dir (concat axltxl/org-home "templates/"))
(defconst org-tpl-private-dir (concat org-tpl-dir "private/"))

;; org-capture TODO templates locations
(defconst org-tpl-tasks-dir (concat org-tpl-dir "tasks/"))
(defconst org-tpl-tasks-private-dir (concat org-tpl-private-dir "tasks/"))

;; org-capture templates locations for org-journal
(defconst org-tpl-journal-dir (concat org-tpl-dir "journal/"))
(defconst org-tpl-journal-private-dir (concat org-tpl-private-dir "journal/"))

org-mode

Package configuration

(use-package org
 :pin org
 :after general
 :demand t

 ;; org-mode prefixed key bindings
 :general
 (:states 'normal
  :keymaps 'org-mode-map
  :prefix axltxl/major-mode-leader-key
  "SPC" 'org-toggle-checkbox
  "il"  'org-insert-link
  "t"   'org-todo)

 ;; org-mode non-prefixed key bindings
 (:states '(normal insert)
  :keymaps 'org-mode-map
  "C->" 'org-metaright
  "C-<" 'org-metaleft)

 ;; Configuration
 :config

 ;; TODO lists keywords
 (setq org-todo-keywords
     '((sequence "TODO" "|" "DONE" "CANCELLED"))))

org-bullets

UTF-8 fancy bullets for org-mode

Package configuration

(use-package org-bullets
:after org
:init
;; Custom bullets
(setq org-bullets-bullet-list '("" "" "" ""))

:config
;; Turn on org-mode
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))

org-journal

Package configuration

(use-package org-journal
:after org
:init
(setq
    org-journal-dir axltxl/org-journal-dir
    org-journal-file-format "%Y%m%d.org"
    org-journal-date-prefix "#+TITLE: "
    org-journal-date-format "%Y-%m-%d"
    org-journal-time-prefix "* "
    org-journal-time-format "%H:%M:%S => "
))

Prefixed Key Bindings

Create a new entry in the journal

(axltxl/define-key "oja" 'org-journal-new-entry)

org-agenda

Package configuration

(use-package org-agenda
:after (org general)
:ensure nil ; This is vanilla org-mode

;; Prefixed Key Bindings
:general (
    :states '(normal motion emacs)
    :keymaps 'org-agenda-mode-map
    "j" 'org-agenda-next-line
    "k" 'org-agenda-previous-line
    "s" 'org-agenda-schedule
    "c" 'org-agenda-capture
    "t" 'org-agenda-todo)

:config
;; Initial agenda files
(setq org-agenda-files `(,(concat axltxl/org-home "tasks.org"))))

Prefixed Key Bindings

Open org-agenda menu

(axltxl/define-key "oaa" 'org-agenda)

Open main TODO list

(axltxl/define-key "oat" 'org-todo-list)

org-capture

org-capture + org-journal

This function will allow org-capture to add a new journal entry

(with-eval-after-load 'org-journal
    (defun axltxl/org-journal-find-location ()
        ;; Open today's journal, but specify a non-nil prefix argument in order to
        ;; inhibit inserting the heading; org-capture will insert the heading.
        (org-journal-new-entry t)
        ;; Position point on the journal's top-level heading so that org-capture
        ;; will add the new entry as a child entry.
        (goto-char (point-min))))

Package configuration

(use-package org-capture
:after org-journal
:ensure nil
:config

    ;; Automatically align all tags before finalizing capture
    ;; https://www.reddit.com/r/emacs/comments/93990v/automatically_add_tag_to_capture_in_org_mode/
    (add-hook 'org-capture-before-finalize-hook #'org-align-all-tags)

    ;; org-capture templates
    ;; https://orgmode.org/manual/Capture-templates.html#Capture-templates
    (setq org-capture-templates
    ;; Journal entries
    `(
    ("j" "journal/entry" entry
        (function axltxl/org-journal-find-location)
        (file ,(concat org-tpl-journal-dir "generic.org")))

    ("a" "journal/action" entry
        (function axltxl/org-journal-find-location)
        (file ,(concat org-tpl-journal-dir "actions/generic.org")))

    ("e" "journal/event" entry
        (function axltxl/org-journal-find-location)
        (file ,(concat org-tpl-journal-dir "events/generic.org")))

    ("t" "task" entry
        (file ,(concat axltxl/org-home "tasks.org"))
        (file ,(concat org-tpl-tasks-dir "generic.org")))

    ("G" "journal/entry/github" entry
        (function axltxl/org-journal-find-location)
        (file ,(concat org-tpl-journal-private-dir "events/github.org")))

    ("A" "task/action" entry
        (file ,(concat axltxl/org-home "tasks.org"))
        (file ,(concat org-tpl-tasks-dir "actions/generic.org")))

    ("g" "task/action/github" entry
        (file ,(concat axltxl/org-home "tasks.org"))
        (file ,(concat org-tpl-journal-private-dir "events/github.org"))))))

Prefixed Key Bindings

(axltxl/define-key "oc" 'org-capture)

org-projectile

Package configuration

(use-package org-projectile
    :after (org org-agenda projectile)
    :config
    ;; All project TODOs in one single file
    (setq org-projectile-projects-file (concat axltxl/org-home "projects.org"))

    ;; org-projectile + org-agenda
    (setq org-agenda-files (append org-agenda-files (org-projectile-todo-files)))

    ;; org-projectile + org-capture
    (push (org-projectile-project-todo-entry) org-capture-templates))

    ;; go to TODOs file for project
    (defun org-projectile/goto-todos ()
    (interactive)
    (org-projectile-goto-location-for-project (projectile-project-name)))

Prefixed Key Bindings

Open TODO list for a project

(axltxl/define-key "po" 'org-projectile/goto-todos)

Project management

projectile

Package configuration

(use-package projectile
:demand t
:config (projectile-mode +1))

Prefixed Key Bindings

Switch to project

(axltxl/define-key "pp" 'projectile-switch-project)

Find file in project

(axltxl/define-key "pf" 'projectile-find-file)

git

git-gutter

Package configuration

(use-package git-gutter :config (global-git-gutter-mode t))

magit

Package configuration

(use-package magit :after general)

Key bindings

Gotta be honest. evil-magit does a wonderful job for that

(use-package evil-magit :after magit)

Prefixed Key Bindings

Open up magit-status
(axltxl/define-key "gs" 'magit-status)

File types support

YAML (yaml-mode)

(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))

;; Unlike python-mode, this mode follows the Emacs convention of not
;; binding the ENTER key to `newline-and-indent'.  To get this
;; behavior, add the key definition to `yaml-mode-hook':
(add-hook 'yaml-mode-hook
    '(lambda ()
    (define-key yaml-mode-map "\C-m" 'newline-and-indent))))

JSON

(use-package json-mode)

Terraform

terraform-mode

(use-package terraform-mode
:config
; Format the current buffer with terraform-format-buffer. To always
; format terraform buffers when saving, use:
(add-hook 'terraform-mode-hook #'terraform-format-on-save-mode))

company-terraform for autocompletion

… and we add company autocompletion into the mix

(use-package company-terraform
:after (company terraform-mode)
:config
(company-terraform-init))

Haxe (haxe.org)

battle-haxe

(use-package haxe-mode)

dotemacs's People

Contributors

axltxl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.