X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/blobdiff_plain/26c4576481564334570a4216fa432093e926d4cd..54512e45bc980154f8d3d799b1974f0652246c7b:/init.org?ds=inline diff --git a/init.org b/init.org index b04e5f6..7ae419d 100644 --- a/init.org +++ b/init.org @@ -44,7 +44,6 @@ byte-compiled the packages. Something along these lines should work: git clone https://github.com/aminb/dotfiles ~/.emacs.d cd ~/.emacs.d make bootstrap-borg -make tangle-init make bootstrap make build #+end_src @@ -168,10 +167,6 @@ done initializing. (add-hook 'after-init-hook (lambda () - (let ((elapsed (float-time (time-subtract (current-time) - ab--before-user-init-time)))) - (message "Loading %s...done (%.3fs) [after-init]" - user-init-file elapsed)) (setq gc-cons-threshold ab--gc-cons-threshold gc-cons-percentage ab--gc-cons-percentage file-name-handler-alist ab--file-name-handler-alist))) @@ -339,6 +334,44 @@ See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.htm :config (or (server-running-p) (server-mode))) #+end_src +** Unicode support + +Font stack with better unicode support, around =Ubuntu Mono= and +=Hack=. + +#+begin_src emacs-lisp +(dolist (ft (fontset-list)) + (set-fontset-font + ft + 'unicode + (font-spec :name "Ubuntu Mono")) + (set-fontset-font + ft + 'unicode + (font-spec :name "DejaVu Sans Mono") + nil + 'append) + ;; (set-fontset-font + ;; ft + ;; 'unicode + ;; (font-spec + ;; :name "Symbola monospacified for DejaVu Sans Mono") + ;; nil + ;; 'append) + ;; (set-fontset-font + ;; ft + ;; #x2115 ; ℕ + ;; (font-spec :name "DejaVu Sans Mono") + ;; nil + ;; 'append) + (set-fontset-font + ft + (cons ?Α ?ω) + (font-spec :name "DejaVu Sans Mono" :size 14) + nil + 'prepend)) +#+end_src + * Core :PROPERTIES: :CUSTOM_ID: core @@ -507,7 +540,7 @@ Roll your own modal mode *** [[https://github.com/ch11ng/exwm][EXWM]] (window manager) -#+begin_src emacs-lisp +#+begin_src emacs-lisp :tangle no (use-package exwm :demand t :config @@ -535,13 +568,13 @@ Roll your own modal mode (exwm-input-set-key (kbd (format "s-%d" i)) (lambda () (interactive) - (exwm-workspace-switch-create ,i)))) + (exwm-workspace-switch-create i)))) ;; 's-SPC': Launch application - (exwm-input-set-key - (kbd "s-SPC") - (lambda (command) - (interactive (list (read-shell-command "➜ "))) - (start-process-shell-command command nil command))) + ;; (exwm-input-set-key + ;; (kbd "s-SPC") + ;; (lambda (command) + ;; (interactive (list (read-shell-command "➜ "))) + ;; (start-process-shell-command command nil command))) (exwm-input-set-key (kbd "M-s-SPC") #'counsel-linux-app) @@ -563,8 +596,8 @@ Roll your own modal mode ([?\C-v] . [next]) ([?\C-d] . [delete]) ([?\C-k] . [S-end delete]) - ;; cut/paste - ([?\C-w] . [?\C-x]) + ;; cut/copy/paste + ;; ([?\C-w] . [?\C-x]) ([?\M-w] . [?\C-c]) ([?\C-y] . [?\C-v]) ;; search @@ -581,11 +614,154 @@ Roll your own modal mode (require 'exwm-randr) (exwm-randr-enable) + ;; (exwm-input-set-key + ;; (kbd "s-") + ;; (lambda () + ;; (interactive) + ;; (start-process "urxvt" nil "urxvt"))) + + ;; (exwm-input-set-key + ;; (kbd "s-SPC") ;; rofi doesn't properly launch programs when started from emacs + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "rofi-run" nil "rofi -show run -display-run '> ' -display-window ' 🗔 '"))) + + ;; (exwm-input-set-key + ;; (kbd "s-/") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "rofi-win" nil "rofi -show window -display-run '> ' -display-window ' 🗔 '"))) + + ;; (exwm-input-set-key + ;; (kbd "M-SPC") + ;; (lambda () + ;; (interactive) + ;; (start-process "rofi-pass" nil "rofi-pass"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "pamixer" nil "pamixer --toggle-mute"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --decrease 5"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "pamixer" nil "pamixer --allow-boost --increase 5"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "mpc" nil "mpc toggle"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "mpc" nil "mpc prev"))) + + ;; (exwm-input-set-key + ;; (kbd "") + ;; (lambda () + ;; (interactive) + ;; (start-process-shell-command "mpc" nil "mpv next"))) + + (defun ab--exwm-pasystray () + "A command used to start pasystray." + (interactive) + (if (executable-find "pasystray") + (progn + (message "EXWM: starting pasystray ...") + (start-process-shell-command "pasystray" nil "pasystray --notify=all")) + (message "EXWM: pasystray is not installed, abort!"))) + + (add-hook 'exwm-init-hook #'ab--exwm-pasystray) + + (exwm-input-set-key + (kbd "s-t") + (lambda () + (interactive) + (exwm-floating-toggle-floating))) + (exwm-input-set-key - (kbd "M-SPC") + (kbd "s-f") (lambda () (interactive) - (start-process "rofi-pass" nil "rofi-pass")))) + (exwm-layout-toggle-fullscreen))) + + (exwm-input-set-key + (kbd "s-w") + (lambda () + (interactive) + (kill-buffer (current-buffer)))) + + (exwm-input-set-key + (kbd "s-q") + (lambda () + (interactive) + (exwm-manage--kill-client)))) +#+end_src + +**** sxhkdrc +:PROPERTIES: +:header-args+: :tangle ~/.config/sxhkd/sxhkdrc :mkdirp yes +:END: + +#+begin_src conf :tangle no +# terminal emulator +super + Return + urxvt + +# program launcher +super + space + rofi -show run -display-run '> ' -display-window ' 🗔 ' + +# window finder +super + slash + rofi -show window -display-run '> ' -display-window ' 🗔 ' + +# password manager +alt + space + rofi-pass + +# make sxhkd reload its configuration files: +super + Escape + pkill -USR1 -x sxhkd + +# volume {up,down} +XF86Audio{Raise,Lower}Volume + pamixer --allow-boost --{in,de}crease 5 + +# mute +XF86AudioMute + pamixer --toggle-mute + +# playback control +XF86Audio{Play,Prev,Next} + mpc {toggle,prev,next} + +# Toggle keyboard layout +# super + F7 +# toggle-layout + +# Toggle Xfce presentation mode +# XF86LaunchB +# toggle-presentation-mode + +# monitor brightness +XF86MonBrightness{Up,Down} + light -{A,U} 5 + +super + apostrophe + rofi-light #+end_src *** [[https://orgmode.org/][Org mode]] @@ -641,12 +817,13 @@ There's no way I could top that, so I won't attempt to. :bind (:map ivy-minibuffer-map ([escape] . keyboard-escape-quit) - ("C-j" . ivy-next-line) - ("C-k" . ivy-previous-line) + ;; ("C-j" . ivy-next-line) + ;; ("C-k" . ivy-previous-line) ([S-up] . ivy-previous-history-element) ([S-down] . ivy-next-history-element) ("DEL" . ivy-backward-delete-char)) :config + (setq ivy-wrap t) (ivy-mode 1)) #+end_src @@ -662,7 +839,7 @@ There's no way I could top that, so I won't attempt to. #+begin_src emacs-lisp (use-package counsel - :defer 1.5 + :defer 1 :bind (([remap execute-extended-command] . counsel-M-x) ([remap find-file] . counsel-find-file) ("s-r" . counsel-recentf) @@ -754,6 +931,245 @@ TODO: break this giant source block down into individual org sections. (setq undo-tree-mode-lighter "")) #+end_src +* Editing + +** Company + +#+begin_src emacs-lisp +(use-package company + :defer 5 + :bind + (:map company-active-map + ([tab] . company-complete-common-or-cycle)) + :custom + (company-idle-delay 0.3) + (company-minimum-prefix-length 1) + (company-selection-wrap-around t) + (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") + :config + (global-company-mode t)) +#+end_src + +* Syntax and spell checking +#+begin_src emacs-lisp +(use-package flycheck + :hook (prog-mode . flycheck-mode) + :config + ;; Use the load-path from running Emacs when checking elisp files + (setq flycheck-emacs-lisp-load-path 'inherit) + + ;; Only flycheck when I actually save the buffer + (setq flycheck-check-syntax-automatically '(mode-enabled save))) +#+end_src +* Programming modes + +** [[https://github.com/leanprover/lean-mode][Lean]] + +#+begin_src emacs-lisp +(use-package lean-mode + :bind (:map lean-mode-map + ("S-SPC" . company-complete))) +#+end_src + +** Haskell + +*** [[https://github.com/haskell/haskell-mode][haskell-mode]] + +#+begin_src emacs-lisp +(use-package haskell-mode + :config + (setq haskell-indentation-layout-offset 4 + haskell-indentation-left-offset 4 + flycheck-checker 'haskell-hlint + flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc))) +#+end_src + +*** [[https://github.com/jyp/dante][dante]] + +#+begin_src emacs-lisp +(use-package dante + :after haskell-mode + :commands dante-mode + :hook (haskell-mode . dante-mode)) +#+end_src + +*** [[https://github.com/mpickering/hlint-refactor-mode][hlint-refactor]] + +Emacs bindings for [[https://github.com/ndmitchell/hlint][hlint]]'s refactor option. This requires the refact +executable from [[https://github.com/mpickering/apply-refact][apply-refact]]. + +#+begin_src emacs-lisp +(use-package hlint-refactor + :bind (:map hlint-refactor-mode-map + ("C-c l b" . hlint-refactor-refactor-buffer) + ("C-c l r" . hlint-refactor-refactor-at-point)) + :hook (haskell-mode . hlint-refactor-mode)) +#+end_src + +*** [[https://github.com/flycheck/flycheck-haskell][flycheck-haskell]] + +#+begin_src emacs-lisp +(use-package flycheck-haskell) +#+end_src + +*** [[https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el][hs-lint.el]] +:PROPERTIES: +:header-args+: :tangle lisp/hs-lint.el :mkdirp yes +:END: + +Currently using =flycheck-haskell= with the =haskell-hlint= checker +instead. + +#+begin_src emacs-lisp :tangle no +;;; hs-lint.el --- minor mode for HLint code checking + +;; Copyright 2009 (C) Alex Ott +;; +;; Author: Alex Ott +;; Keywords: haskell, lint, HLint +;; Requirements: +;; Status: distributed under terms of GPL2 or above + +;; Typical message from HLint looks like: +;; +;; /Users/ott/projects/lang-exp/haskell/test.hs:52:1: Eta reduce +;; Found: +;; count1 p l = length (filter p l) +;; Why not: +;; count1 p = length . filter p + + +(require 'compile) + +(defgroup hs-lint nil + "Run HLint as inferior of Emacs, parse error messages." + :group 'tools + :group 'haskell) + +(defcustom hs-lint-command "hlint" + "The default hs-lint command for \\[hlint]." + :type 'string + :group 'hs-lint) + +(defcustom hs-lint-save-files t + "Save modified files when run HLint or no (ask user)" + :type 'boolean + :group 'hs-lint) + +(defcustom hs-lint-replace-with-suggestions nil + "Replace user's code with suggested replacements" + :type 'boolean + :group 'hs-lint) + +(defcustom hs-lint-replace-without-ask nil + "Replace user's code with suggested replacements automatically" + :type 'boolean + :group 'hs-lint) + +(defun hs-lint-process-setup () + "Setup compilation variables and buffer for `hlint'." + (run-hooks 'hs-lint-setup-hook)) + +;; regex for replace suggestions +;; +;; ^\(.*?\):\([0-9]+\):\([0-9]+\): .* +;; Found: +;; \s +\(.*\) +;; Why not: +;; \s +\(.*\) + +(defvar hs-lint-regex + "^\\(.*?\\):\\([0-9]+\\):\\([0-9]+\\): .*[\n\C-m]Found:[\n\C-m]\\s +\\(.*\\)[\n\C-m]Why not:[\n\C-m]\\s +\\(.*\\)[\n\C-m]" + "Regex for HLint messages") + +(defun make-short-string (str maxlen) + (if (< (length str) maxlen) + str + (concat (substring str 0 (- maxlen 3)) "..."))) + +(defun hs-lint-replace-suggestions () + "Perform actual replacement of suggestions" + (goto-char (point-min)) + (while (re-search-forward hs-lint-regex nil t) + (let* ((fname (match-string 1)) + (fline (string-to-number (match-string 2))) + (old-code (match-string 4)) + (new-code (match-string 5)) + (msg (concat "Replace '" (make-short-string old-code 30) + "' with '" (make-short-string new-code 30) "'")) + (bline 0) + (eline 0) + (spos 0) + (new-old-code "")) + (save-excursion + (switch-to-buffer (get-file-buffer fname)) + (goto-char (point-min)) + (forward-line (1- fline)) + (beginning-of-line) + (setf bline (point)) + (when (or hs-lint-replace-without-ask + (yes-or-no-p msg)) + (end-of-line) + (setf eline (point)) + (beginning-of-line) + (setf old-code (regexp-quote old-code)) + (while (string-match "\\\\ " old-code spos) + (setf new-old-code (concat new-old-code + (substring old-code spos (match-beginning 0)) + "\\ *")) + (setf spos (match-end 0))) + (setf new-old-code (concat new-old-code (substring old-code spos))) + (remove-text-properties bline eline '(composition nil)) + (when (re-search-forward new-old-code eline t) + (replace-match new-code nil t))))))) + +(defun hs-lint-finish-hook (buf msg) + "Function, that is executed at the end of HLint execution" + (if hs-lint-replace-with-suggestions + (hs-lint-replace-suggestions) + (next-error 1 t))) + +(define-compilation-mode hs-lint-mode "HLint" + "Mode for check Haskell source code." + (set (make-local-variable 'compilation-process-setup-function) + 'hs-lint-process-setup) + (set (make-local-variable 'compilation-disable-input) t) + (set (make-local-variable 'compilation-scroll-output) nil) + (set (make-local-variable 'compilation-finish-functions) + (list 'hs-lint-finish-hook)) + ) + +(defun hs-lint () + "Run HLint for current buffer with haskell source" + (interactive) + (save-some-buffers hs-lint-save-files) + (compilation-start (concat hs-lint-command " \"" buffer-file-name "\"") + 'hs-lint-mode)) + +(provide 'hs-lint) +;;; hs-lint.el ends here +#+end_src + +#+begin_src emacs-lisp :tangle no +(use-package hs-lint + :load-path "lisp/" + :bind (:map haskell-mode-map + ("C-c l l" . hs-lint))) +#+end_src +* Emacs Enhancements + +** [[https://github.com/justbur/emacs-which-key][which-key]] + +#+begin_quote +Emacs package that displays available keybindings in popup +#+end_quote + +#+begin_src emacs-lisp +(use-package which-key + :defer 1 + :config (which-key-mode)) +#+end_src + * Post initialization :PROPERTIES: :CUSTOM_ID: post-initialization