(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) ;(define-key key-translation-map (kbd "ESC") (kbd "C-g")) ;(global-set-key [escape] 'keyboard-quit) ;(setq w32-quit-key 27) (blink-cursor-mode 0) (setq visible-cursor nil) (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) (setq evil-want-C-u-scroll t) (require 'evil) (evil-mode 1) (evil-select-search-module 'evil-search-module 'evil-search) (setq-default evil-cross-lines t) (global-set-key (kbd "C-l") 'evil-ex-nohighlight) (setq evil-echo-state nil) (setq evil-vimish-fold-target-modes '(prog-mode conf-mode text-mode)) (global-evil-vimish-fold-mode 1) (add-hook 'evil-vimish-fold-mode-hook #'evil-close-folds) (setq-default vimish-fold-persist-on-saving nil) (defun vimish-fold--save-folds (&optional buffer-or-name)) (global-display-line-numbers-mode) (setq-default display-line-numbers-width 6) (setq-default display-line-numbers-grow-only t) (setq scroll-margin 0) ;; https://zhangda.wordpress.com/2009/05/21/customize-emacs-automatic-scrolling-and-stop-the-cursor-from-jumping-around-as-i-move-it/ ;; https://www.emacswiki.org/emacs/SmoothScrolling (setq scroll-conservatively 10000) ;(setq auto-window-vscroll nil) (setq linum-delay t) (setq show-paren-delay 0) (show-paren-mode) (electric-indent-mode 0) (setq-default c-electric-flag nil) (setq-default indent-tabs-mode nil) (evil-define-key 'insert prog-mode-map (kbd "TAB") (lambda () (interactive) (insert (make-string (- 4 (mod (- (point) (save-excursion (beginning-of-line) (point))) 4)) ? )))) ;(normal-erase-is-backspace-mode 1) (evil-define-key 'insert prog-mode-map (kbd "\C-?") (lambda () (interactive) (let ((bol (save-excursion (beginning-of-line) (point)))) (delete-backward-char (if (string-match "^\\s-+$" (buffer-substring bol (point))) (+ (mod (- (point) bol 1) 4) 1) 1))))) (evil-define-key 'insert prog-mode-map (kbd "RET") #'newline-and-indent) (defun newline-and-indent () (interactive) (evil-maybe-remove-spaces t) (newline) (indent-relative-first-indent-point)) (defun evil-maybe-remove-spaces (&optional do-remove) (when (and evil-maybe-remove-spaces do-remove (save-excursion (beginning-of-line) (looking-at "^\\s-*$"))) (delete-region (line-beginning-position) (line-end-position))) (setq evil-maybe-remove-spaces (memq this-command '( evil-open-above evil-open-below evil-append evil-append-line newline newline-and-indent indent-and-newline )))) ;; black red green yellow blue magenta cyan white ;(defface evil-ex-search '((t :inherit isearch)) "" :group 'evil) (defface srk-whitespace '((t :background "blue")) "") ; font-lock-builtin-face (set-face-attribute 'font-lock-comment-face nil :foreground "blue" :weight 'bold) ; font-lock-comment-delimiter-face (set-face-attribute 'font-lock-constant-face nil :foreground "white" :weight 'normal) ; font-lock-doc-face (set-face-attribute 'font-lock-function-name-face nil :foreground "white" :weight 'normal) (set-face-attribute 'font-lock-keyword-face nil :foreground "yellow" :weight 'normal) ; font-lock-negation-char-face (set-face-attribute 'font-lock-preprocessor-face nil :foreground "purple" :weight 'normal) (set-face-attribute 'font-lock-string-face nil :foreground "red" :weight 'normal) (set-face-attribute 'font-lock-type-face nil :foreground "green" :weight 'normal) (set-face-attribute 'font-lock-variable-name-face nil :foreground "white" :weight 'normal) (set-face-attribute 'font-lock-warning-face nil :foreground "black" :background "red" :weight 'normal) (set-face-attribute 'isearch nil :foreground "black" :background "purple") (set-face-attribute 'lazy-highlight nil :foreground "black" :background "yellow") (global-font-lock-mode t) (setq font-lock-maximum-decoration 1) ;; If `override` is `t`, this element can override existing fontification made by previous elements of `font-lock-keywords`. If it is `keep`, then each character is fontified if it has not been fontified already by some other element. If it is `prepend`, the face facename is added to the beginning of the face property. If it is `append`, the face facename is added to the end of the face property. (add-hook 'c-mode-common-hook (lambda () (font-lock-add-keywords nil '( (" *$" 0 font-lock-warning-face append) ; trailing whitespace ("::\\<" 0 font-lock-preprocessor-face append) ; scope resolution ("\\<\\(bool\\|char\\|double\\|float\\|int\\|unsigned\\|void\\)\\>" 0 font-lock-type-face append) ; builtin types ("\\" 0 font-lock-type-face append) ; stdint typedefs ("\\" 0 font-lock-type-face append) ; posix typedefs ("\\<\\(static_assert\\)\\>" 0 font-lock-keyword-face append) ; c++ structure ("\\<\\(const\\|static\\|reinterpret\\)_cast\\>" 0 font-lock-keyword-face append) ; c++ casts ("\\<\\(private\\|protected\\|public\\)\\>" 0 font-lock-keyword-face append) ; accessibility ("\\<\\(auto\\|const\\|constexpr\\|inline\\|static\\|volatile\\)\\>" 0 font-lock-type-face append) ; type modifiers ("\\<\\(explicit\\|final\\|typename\\|virtual\\)\\>" 0 font-lock-type-face append) ; mode modififiers ("\\<\\(class\\|namespace\\|struct\\|template\\|typedef\\|using\\)\\>" 0 font-lock-type-face append) ; definitions ("\\<\\(orc_assert\\|orc_catch\\|orc_insist\\)\\>" 0 font-lock-keyword-face append) ; orchid support ("\\<\\(catch\\|do\\|else\\|for\\|if\\|try\\|return\\|while\\)\\>" 1 font-lock-keyword-face append) ; flow control ("\\<\\(co_await\\|co_return\\|co_yield\\)\\>" 0 font-lock-keyword-face append) ; coroutine control ("\\<\\(operator\\|this\\)\\>" 0 font-lock-keyword-face append) ; special names ("\\<\\(decltype\\|sizeof\\|typeid\\)\\>" 0 font-lock-keyword-face append) ; meta operators ("\\<\\(NULL\\|nullptr\\|std::nullopt\\)\\>" 0 font-lock-string-face append) ; null constants ("\\<\\(std::move\\)\\>" 0 font-lock-builtin-face append) ; null constants ("\\" 0 font-lock-warning-face t) ; comment notices ("\\<\\(0\\|[1-9][0-9]*\\)\\.\\([0-9]+\\>\\)?\\|\\.[0-9]+[fF]?\\>" 0 font-lock-string-face append) ; floating point ("\\<\\(0\\|[1-9][0-9]*\\|0[xX][0-9a-fA-F]+\\)[uU]?[lL]\\{0,2\\}\\>" 0 font-lock-string-face append) ; integers )))) (setq require-final-newline t) (setq next-line-add-newlines nil) (add-hook 'post-command-hook (lambda () (when (and (equal (point) (point-max)) (looking-back "\n")) (previous-line)) ) t nil) (setq inhibit-startup-message t) (menu-bar-mode -1) (setq-default mode-line-format nil) ;; (require 'auto-save) ;; (setq auto-save-directory (expand-file-name "~/.emacs-save/") ;; auto-save-directory-fallback auto-save-directory ;; auto-save-hash-p nil ;; auto-save-interval 2000) (setq delete-auto-save-files t) (setq make-backup-files nil) (auto-save-mode 0) (save-place-mode 1) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages (quote (evil-vimish-fold evil)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. )