update emacs config and add wakatime

This commit is contained in:
Hedy Li 2021-08-16 13:32:18 +08:00
parent 62919b0a86
commit 515353207a
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
5 changed files with 162 additions and 36 deletions

12
.config/emacsd/custom.el Normal file
View File

@ -0,0 +1,12 @@
(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.
'(safe-local-variable-values '((git-commit-major-mode . git-commit-elisp-text-mode))))
(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.
)

View File

@ -0,0 +1 @@
(setq package-enable-at-startup nil)

View File

@ -1,42 +1,43 @@
;;; I don't use emacs built-in manager anymore but keeping it here just in case
;;(package-initialize)
;;(require 'package)
;;(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;;(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;;(setq package-archives '(
;; ("gnu" . "http://elpa.gnu.org/packages/")
;; ("melpa" . "http://melpa.milkbox.net/packages/")
;; )
;;)
(setq create-lockfiles nil)
;;; straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; I think this saves the last cursor pos or something
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory))
(straight-use-package 'use-package)
(straight-use-package 'zenburn-theme)
(use-package evil
:straight t)
;; Some better defaults?
(setq make-backup-files nil)
(setq auto-save-default nil)
;;(setq dracula-use-24-bit-colors-on-256-colors-terms t)
;;(load-theme 'dracula t)
;;(unless (display-graphic-p)
;; (set-face-background 'default "black" nil))
(setq-default major-mode 'text-mode)
(setq sentence-end-double-space nil)
(load-theme 'zenburn t)
;; Always tabs except for *.go?
;; TODO: set up language mode packages
(setq-default c-basic-offset 4
tab-width 4
indent-tabs-mode nil)
(global-hl-line-mode 1)
(set-face-background hl-line-face "gray13")
;; Some modes
(recentf-mode 1)
(show-paren-mode 1)
(setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)
(electric-pair-mode 1)
(require 'evil)
(evil-mode 1)
;; IDK
(add-hook 'prog-mode-hook #'subword-mode)
(add-hook 'minibuffer-setup-hook #'subword-mode)
;; elisp
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-x") #'ielm)
(local-set-key (kbd "C-c C-c") #'eval-defun)
(local-set-key (kbd "C-c C-b") #'eval-buffer)))
;; customize shits in separate file, thanks
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
;; Packages
(load (expand-file-name "packages.el" user-emacs-directory))

104
.config/emacsd/packages.el Normal file
View File

@ -0,0 +1,104 @@
;; I don't use emacs built-in manager anymore but keeping it here just in case
;;(package-initialize)
;;(require 'package)
;;(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;;(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;;(setq package-archives '(
;; ("gnu" . "http://elpa.gnu.org/packages/")
;; ("melpa" . "http://melpa.milkbox.net/packages/")
;; )
;;)
;;; straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(straight-use-package 'zenburn-theme)
(use-package evil
:straight t)
(straight-use-package 'elpher)
(straight-use-package 'eww)
(straight-use-package 'wakatime-mode)
;; vertico
;; Enable vertico
(use-package vertico
:straight t
:init
(vertico-mode)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
)
;; Use the `orderless' completion style. Additionally enable
;; `partial-completion' for file path expansion. `partial-completion' is
;; important for wildcard support. Multiple files can be opened at once
;; with `find-file' if you enter a wildcard. You may also give the
;; `initials' completion style a try.
(use-package orderless
:straight t
:init
(setq completion-styles '(orderless)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:straight t
:init
(savehist-mode))
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; Alternatively try `consult-completing-read-multiple'.
(defun crm-indicator (args)
(cons (concat "[CRM] " (car args)) (cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t))
;; End of straight?
(global-wakatime-mode)
;;(setq dracula-use-24-bit-colors-on-256-colors-terms t)
;;(load-theme 'dracula t)
;;(unless (display-graphic-p)
;; (set-face-background 'default "black" nil))
(load-theme 'zenburn t)
(global-hl-line-mode 1)
(set-face-background hl-line-face "gray13")
;; Sometimes I disable this so I can experience how inefficient emacs's default
;; editting experience.
(require 'evil)
(evil-mode 1)

8
bin/wakatime Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/bash
# Remember to install wakatime-cli first
# This is to fix some odd or legacy behaviour of the emacs wakatime plugin
args=$(echo "$@" | sed 's/--file/--entity/')
wakatime-cli $args