diff options
Diffstat (limited to 'config')
| -rw-r--r-- | config/emacs/default.nix | 13 | ||||
| -rw-r--r-- | config/emacs/init.el | 109 | ||||
| -rw-r--r-- | config/emacs/modeline/simple-modeline-core.el | 102 | ||||
| -rw-r--r-- | config/emacs/modeline/simple-modeline-segments.el | 92 | ||||
| -rw-r--r-- | config/emacs/modeline/simple-modeline.el | 73 | 
5 files changed, 389 insertions, 0 deletions
| diff --git a/config/emacs/default.nix b/config/emacs/default.nix new file mode 100644 index 0000000..ef721af --- /dev/null +++ b/config/emacs/default.nix @@ -0,0 +1,13 @@ +{ pkgs, config, ... }: + +{ +  programs.emacs = { +    enable = true; +    package = pkgs.emacs; +  }; + +  home.file = { +    ".emacs.d/init.el".source = ./init.el; +    ".emacs.d/modeline".source = ./modeline; +  }; +} diff --git a/config/emacs/init.el b/config/emacs/init.el new file mode 100644 index 0000000..bc05039 --- /dev/null +++ b/config/emacs/init.el @@ -0,0 +1,109 @@ +(require 'package) +(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) +(package-initialize) +(custom-set-variables + '(package-selected-packages '(fzf kaolin-themes evil flycheck lsp-mode cmake-mode))) + +(global-flycheck-mode 1) +(add-hook 'python-mode-hook #'lsp-deferred) +(add-hook 'c-mode-hook #'lsp-deferred) +(add-hook 'c++-mode-hook #'lsp-deferred) + +(setq evil-want-C-u-scroll t) +(setq evil-undo-system 'undo-redo) +(require 'evil) +(evil-mode 1) + +(set-fontset-font t nil "UbuntuMono Nerd Font Mono" nil 'append) + +(setq make-backup-files nil) +(setq auto-save-default nil) + +(setq-default cursor-type 'bar) + +(setq scroll-step 1) + +(menu-bar-mode -1) +(tool-bar-mode -1) +(scroll-bar-mode -1) +(blink-cursor-mode -1) +(global-goto-address-mode 1) +(global-visual-line-mode 1) +(delete-selection-mode 1) +(save-place-mode 1) + +(global-set-key (kbd "M-o") 'other-window) +(global-set-key (kbd "M-z") 'ibuffer) +(global-set-key (kbd "M-d") 'dired-jump) +(global-set-key (kbd "M-k") 'kill-buffer) +(global-set-key (kbd "M-t") 'eshell) +(global-set-key (kbd "M-c") 'comment-line) + +(global-set-key (kbd "M-RET") 'compile) + +(defun display-flycheck-errors-bottom (buffer _action) +  (let ((window (display-buffer-in-side-window +                 buffer '((side . bottom) (slot . 0) (window-height . 0.25))))) +    (select-window window) +    window)) + +(add-to-list 'display-buffer-alist +             '("^\\*Flycheck errors\\*$" . (display-flycheck-errors-bottom))) + +(global-set-key (kbd "M-e") 'flycheck-list-errors) + +(fset 'yes-or-no-p 'y-or-n-p) + +(setq initial-scratch-message "") +(defun remove-scratch-buffer () +  (if (get-buffer "*scratch*") +      (kill-buffer "*scratch*"))) +(add-hook 'after-change-major-mode-hook 'remove-scratch-buffer) + +(defun remove-native-compile-buffer () +  (if (get-buffer "*Async-native-compile-log*") +      (kill-buffer "*Async-native-compile-log*"))) +(add-hook 'after-change-major-mode-hook 'remove-native-compile-buffer) + +(setq-default message-log-max nil) +(kill-buffer "*Messages*") + +(add-hook 'minibuffer-exit-hook +      #'(lambda () +         (let ((buffer "*Completions*")) +           (and (get-buffer buffer) +                (kill-buffer buffer))))) + +(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter) + +(setq dired-listing-switches "-lah --group-directories-first") +(setq dired-recursive-copies 'always) +(setq dired-recursive-deletes 'always) + +(setq sentence-end-double-space nil) + +(setq ring-bell-function 'ignore) + +(global-display-line-numbers-mode 1) + +(electric-pair-mode 1) + +(savehist-mode 1) +(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) + +(require 'kaolin-themes) +(load-theme 'kaolin-dark t) + +(add-to-list 'load-path (concat user-emacs-directory "/modeline")) +(require 'simple-modeline) +(simple-modeline-mode) + +(require 'fzf) +(setq fzf/args "-x --color bw --print-query --margin=1,0 --no-hscroll --no-unicode" +    fzf/executable "fzf" +    fzf/git-grep-args "-i --line-number %s" +    fzf/grep-command "rg --no-heading -nH" +    fzf/position-bottom t +    fzf/window-height 15) + +(global-set-key (kbd "C-SPC") 'fzf-directory) diff --git a/config/emacs/modeline/simple-modeline-core.el b/config/emacs/modeline/simple-modeline-core.el new file mode 100644 index 0000000..03df894 --- /dev/null +++ b/config/emacs/modeline/simple-modeline-core.el @@ -0,0 +1,102 @@ +;;; simple-modeline-core.el --- The core libraries for simple-modeline -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2021  Eder Elorriaga + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program.  If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; The core libraries for simple-modeline. + +;;; Code: + +(defgroup simple-modeline nil +  "A simple mode line." +  :prefix "simple-modeline-" +  :group 'mode-line) + +(defvar simple-modeline--default-mode-line mode-line-format +  "The former value of `mode-line-format'.") + +;; +;; Options +;; + +(defcustom simple-modeline-segments +  '((simple-modeline-segment-modified +     simple-modeline-segment-buffer-name) +    (simple-modeline-segment-vc +     simple-modeline-segment-major-mode)) +  "Simple modeline segments." +  :type '(list (repeat :tag "Left aligned" function) +               (repeat :tag "Right aligned" function)) +  :package-version '(simple-modeline . "1.2")) + +;; +;; Faces +;; + +(defface simple-modeline-space +  '((t)) +  "Face for space used to alight the right segments in the mode-line.") + +(defface simple-modeline-unimportant +  '((t (:inherit (shadow)))) +  "Face for less important mode-line elements.") + +(defface simple-modeline-status-modified +  '((t (:inherit (font-lock-variable-name-face)))) +  "Face for the 'modified' indicator symbol in the mode-line.") + +(defface simple-modeline-status-info +  '((t (:inherit (font-lock-string-face)))) +  "Face for generic status indicators in the mode-line.") + +(defface simple-modeline-status-success +  '((t (:inherit (success)))) +  "Face used for success status indicators in the mode-line.") + +(defface simple-modeline-status-warning +  '((t (:inherit (warning)))) +  "Face for warning status indicators in the mode-line.") + +(defface simple-modeline-status-error +  '((t (:inherit (error)))) +  "Face for error status indicators in the mode-line.") + +;; +;; Helpers +;; + +(defun simple-modeline--format (left-segments right-segments) +  "Return a string of `window-width' length containing LEFT-SEGMENTS and RIGHT-SEGMENTS, aligned respectively." +  (let* ((left (simple-modeline--format-segments left-segments)) +         (right (simple-modeline--format-segments right-segments)) +         (reserve (length right))) +    (concat +     left +     (propertize " " +                 'display `((space :align-to (- right ,reserve))) +                 'face '(:inherit simple-modeline-space)) +     right))) + +(defun simple-modeline--format-segments (segments) +  "Return a string from a list of SEGMENTS." +  (format-mode-line (mapcar +                     (lambda (segment) +                       `(:eval (,segment))) +                     segments))) + +(provide 'simple-modeline-core) +;;; simple-modeline-core.el ends here diff --git a/config/emacs/modeline/simple-modeline-segments.el b/config/emacs/modeline/simple-modeline-segments.el new file mode 100644 index 0000000..9a5c2e5 --- /dev/null +++ b/config/emacs/modeline/simple-modeline-segments.el @@ -0,0 +1,92 @@ +;;; simple-modeline-segments.el --- The segments for simple-modeline -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2021  Eder Elorriaga + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program.  If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; The segments for simple-modeline + +;;; Code: + +(require 'subr-x) + +(defun simple-modeline-make-mouse-map (mouse function) +  "Return a keymap with single entry for mouse key MOUSE on the mode line. +MOUSE is defined to run function FUNCTION with no args in the buffer +corresponding to the mode line clicked." +  (let ((map (make-sparse-keymap))) +    (define-key map (vector 'mode-line mouse) function) +    map)) + +(defun simple-modeline-segment-modified () +  "Displays a color-coded buffer modification/read-only indicator in the mode-line." +  (if (not (string-match-p "\\*.*\\*" (buffer-name))) +      (let* ((read-only (and buffer-read-only (buffer-file-name))) +             (modified (buffer-modified-p))) +        (propertize +         (if read-only " " (if modified " ●" " ○")) +         'face `(:inherit +                 ,(if modified 'simple-modeline-status-modified +                    (if read-only 'simple-modeline-status-error +                      'simple-modeline-unimportant))) +         'help-echo (format +                     "Buffer is %s and %smodified\nmouse-1: Toggle read-only status." +                     (if read-only "read-only" "writable") +                     (if modified "" "not ")) +         'local-map (purecopy (simple-modeline-make-mouse-map +                               'mouse-1 +                               (lambda (event) +                                 (interactive "e") +                                 (with-selected-window (posn-window (event-start event)) +                                   (read-only-mode 'toggle))))) +         'mouse-face 'mode-line-highlight)))) + +(defun simple-modeline-segment-buffer-name () + "Displays the name of the current buffer in the mode-line." + (propertize " %b" 'face 'mode-line-buffer-id)) + +(defun simple-modeline-segment-vc () + "Displays color-coded version control information in the mode-line." + '(:eval (when vc-mode (concat "" (substring vc-mode 5))))) + +(defvar simple-modeline-segment-encoding-map +  (let ((map (make-sparse-keymap))) +    (define-key map [mode-line mouse-1] +      (lambda (e) +	(interactive "e") +	(with-selected-window (posn-window (event-start e)) +	  (when (and enable-multibyte-characters +		     buffer-file-coding-system) +	    (describe-coding-system buffer-file-coding-system))))) +    (define-key map [mode-line mouse-3] +      (lambda (e) +	(interactive "e") +	(with-selected-window (posn-window (event-start e)) +	  (call-interactively #'set-buffer-file-coding-system)))) +    (purecopy map)) +  "Local keymap for the coding-system part of the simple-modeline.") + +(defun simple-modeline-segment-major-mode () + "Displays the current major mode in the mode-line." + (propertize +  (concat " " +          (or (and (boundp 'delighted-modes) +                   (cadr (assq major-mode delighted-modes))) +              (format-mode-line mode-name))) +  'face 'bold)) + +(provide 'simple-modeline-segments) +;;; simple-modeline-segments.el ends here diff --git a/config/emacs/modeline/simple-modeline.el b/config/emacs/modeline/simple-modeline.el new file mode 100644 index 0000000..7e90389 --- /dev/null +++ b/config/emacs/modeline/simple-modeline.el @@ -0,0 +1,73 @@ +;;; simple-modeline.el --- A simple mode-line configuration for Emacs -*- lexical-binding: t; -*- + +;; Copyright (C) 2019-2021  Eder Elorriaga + +;; Author: Eder Elorriaga <gexplorer8@gmail.com> +;; URL: https://github.com/gexplorer/simple-modeline +;; Keywords: mode-line faces +;; Version: 1.4 +;; Package-Requires: ((emacs "26.1")) + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program.  If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; A simple mode-line configuration for Emacs. +;; To enable, put this code in your init file: +;; (require 'simple-modeline) +;; (simple-modeline-mode 1) +;; or +;; (use-package simple-modeline +;;   :ensure t +;;   :hook (after-init . simple-modeline-mode)) +;; + +;;; Code: + +(require 'simple-modeline-core) +(require 'simple-modeline-segments) + +(defvar simple-modeline--mode-line +  '((:eval +     (simple-modeline--format +      (car simple-modeline-segments) +      (cadr simple-modeline-segments))))) + +;;;###autoload +(define-minor-mode simple-modeline-mode +  "Minor mode to get a simple mode line. + +When called interactively, toggle +`simple-modeline-mode'.  With prefix ARG, enable +`simple-modeline--mode' if ARG is positive, otherwise +disable it. + +When called from Lisp, enable `simple-modeline-mode' if ARG is omitted, +nil or positive.  If ARG is `toggle', toggle `simple-modeline-mode'. +Otherwise behave as if called interactively." +  :init-value nil +  :keymap nil +  :lighter "" +  :group 'simple-modeline +  :global t +  (if simple-modeline-mode +      (progn +        ;; Set the new mode-line-format +        (setq-default mode-line-format '(:eval simple-modeline--mode-line))) +    (progn +      ;; Restore the original mode-line format +      (setq-default mode-line-format simple-modeline--default-mode-line)))) + +(provide 'simple-modeline) +;;; simple-modeline.el ends here | 
