initial commit

This commit is contained in:
2023-02-28 01:43:19 +08:00
commit 1597cb420b
30 changed files with 2256 additions and 0 deletions

42
unused/10-ligatures.org Normal file
View File

@@ -0,0 +1,42 @@
#+TITLE: Ligatures
Ligatures in programming fonts can help reading code.
this Config uses the composition table technique.
#+begin_src emacs-lisp
(when (window-system)
(set-frame-font "Fira Code"))
(let ((alist '(
(33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
;; (45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
;; (46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(48 . ".\\(?:x[a-zA-Z]\\)")
(58 . ".\\(?:::\\|[:=]\\)")
(59 . ".\\(?:;;\\|;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
(91 . ".\\(?:]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(119 . ".\\(?:ww\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")
)
))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(add-hook 'eshell-mode-hook (lambda () (setq auto-composition-mode nil)))
#+end_src

View File

@@ -0,0 +1,45 @@
#+TITLE: Completions and Keybinding Help
* Which Key
#+begin_src emacs-lisp
(use-package which-key
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 1))
#+end_src
* Ivy and Counsel
#+begin_src emacs-lisp
(use-package ivy
:diminish
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-n" . ivy-next-line)
("C-p" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-p" . ivy-previous-line)
("C-l" . ivy-done)
("C-k" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-p" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:config
(setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)))
(ivy-mode 1))
(use-package ivy-rich
:init
(ivy-rich-mode 1))
(use-package counsel
:bind (("C-M-j" . 'counsel-switch-buffer)
:map minibuffer-local-map
("C-r" . 'counsel-minibuffer-history))
:config
(counsel-mode 1))
#+end_src

32
unused/20-eaf.org Normal file
View File

@@ -0,0 +1,32 @@
#+TITLE:Emacs Application Framework
Graphical Applications that integrates and extends emacs, so that I don't need to live in emacs
* Load EAF
#+begin_src emacs-lisp
(use-package eaf
:load-path "~/.local/eaf"
:custom
; See https://github.com/emacs-eaf/emacs-application-framework/wiki/Customization
(eaf-browser-continue-where-left-off nil)
(eaf-browser-enable-adblocker t)
(browse-url-browser-function 'eaf-open-browser)
(eaf-browser-download-path "~/dls")
(eaf-browser-default-search-engine "duckduckgo")
:config
(defalias 'browse-web #'eaf-open-browser))
;; (eaf-bind-key nil "M-q" eaf-browser-keybinding)) ;; unbind, see more in the Wiki
#+end_src
* Load Applications
#+begin_src emacs-lisp
(require 'eaf-browser)
(require 'eaf-mindmap)
(require 'eaf-terminal)
#+end_src

192
unused/20-ide.org Normal file
View File

@@ -0,0 +1,192 @@
#+TITLE: IDE Configuration
* Intro
Packages/configurations that makes emacs more IDE-like, such as:
- like popup completions with LSP
- error checking on-the-fly
- tree-view file explorer
- git Integration
- tree-sitter based syntax highlighting
* Tree Sitter
Tree sitter highlighting in emacs.[[https://tree-sitter.github.io/tree-sitter/syntax-highlighting][
Tree-sitter Syntax Highlighting website]]
#+begin_src emacs-lisp
(use-package tree-sitter
:config
(global-tree-sitter-mode))
(use-package tree-sitter-langs
:after tree-sitter)
#+end_src
* Magit
[[https://magit.vc][Git Interface for Emacs]]
#+begin_src emacs-lisp
(use-package magit
:bind
("C-x g" . magit-status)
("C-x M-g" . magit-dispatch))
#+end_src
* Treemacs
#+begin_src emacs-lisp
(use-package treemacs
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(add-hook 'treemacs-mode-hook (lambda ()
(setq mode-line-format nil)
(redraw-display)))
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display t
treemacs-file-event-delay 5000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-indent-guide-style 'line
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-width-is-initially-locked nil
treemacs-width 25
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
(treemacs-resize-icons 16)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-icons-dired
:config (treemacs-icons-dired-mode))
(use-package treemacs-magit
:after (treemacs magit)
:ensure t)
#+end_src
* Flycheck
#+begin_src emacs-lisp
(use-package flycheck
:init
(global-flycheck-mode))
#+end_src
* LSP Mode
This package provides a LSP interface for emacs, for autocompletion
#+begin_src emacs-lisp
(use-package lsp-mode
:init
(setq lsp-keymap-prefix "C-l")
:hook
(lsp-mode . lsp-enable-which-key-integration)
(lsp-mode . lsp-completion-mode)
:custom
(lsp-eldoc-render-all t)
:commands (lsp lsp-mode lsp-deferred))
(use-package lsp-ui
:commands lsp-ui-mode
:custom
(lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-doc-position 'bottom))
(use-package lsp-treemacs
:after lsp-mode
:hook (lsp-mode . lsp-treemacs-symbols))
#+end_src
* Company Mode
#+begin_src emacs-lisp
(use-package company
:after lsp-mode
:hook (lsp-mode . company-mode)
:bind
(:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
(use-package company-box
:after company
:hook (company-mode . company-box-mode))
#+end_src

29
unused/30-other.org Normal file
View File

@@ -0,0 +1,29 @@
#+TITLE: Unused Other Configurations
* Unused Miscellanous Configs
Where config files go unused, but not forgotten.
For may that one day come, where they will be useful again
** Fcitx
#+BEGIN_SRC emacs-lisp
fcitx
(use-package fcitx
:config
(fcitx-aggressive-setup)
(setq fcitx-use-dbus t))
#+END_SRC
** EIN
IPython notebook support mode for emacs
#+begin_src emacs-lisp
(use-package ein
:config
(org-babel-do-load-languages
'org-babel-load-languages '((emacs-lisp . nil) (ein . t))))
#+end_src

34
unused/50-fonts.el Normal file
View File

@@ -0,0 +1,34 @@
;;
;; Fonts/Faces
;;
;; This is where the Emacs fonts, or faces in Emacs' terminology, are configured.
;; org fonts are also configured here
;; this config is based from the Custom setting in Emacs
(custom-set-faces
'(default ((t (:inherit nil :extend nil :stipple nil :background "#ffffc8" :foreground "#282828" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :wenight normal :height 90 :width normal :family "FiraCode Nerd Font"))))
'(fixed-pitch ((t (:family "FiraCode Nerd Font"))))
'(fixed-pitch-serif ((t (:family "FiraCode Nerd Font"))))
'(variable-pitch ((t (:family "Fira Sans" :weight normal)))).
`(org-level-8 ((t (:weight bold))))
`(org-level-7 ((t (:weight bold))))
`(org-level-6 ((t (:weight bold))))
`(org-level-5 ((t (:weight bold))))
`(org-level-4 ((t (:weight bold :height 1.1))))
`(org-level-3 ((t (:weight bold :height 1.25))))
`(org-level-2 ((t (:weight bold :height 1.5))))
`(org-level-1 ((t (:weight bold :height 1.75))))
`(org-document-title ((t (:weight bold :height 2.0 :underline nil))))
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit (shadow fixed-pitch)))))
'(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
'(org-indent ((t (:inherit (org-hide fixed-pitch)))))
'(org-link ((t (:underline t))))
'(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-property-value ((t (:inherit fixed-pitch))) t)
'(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-table ((t (:inherit fixed-pitch))))
'(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
'(org-verbatim ((t (:inherit (shadow fixed-pitch))))))

91
unused/50-lang.org Normal file
View File

@@ -0,0 +1,91 @@
#+TITLE: Languages
* Intro
This is where Programming Language modes are configured.
* Built-in Modes
** C++
#+begin_src emacs-lisp
(add-hook 'c++-mode-hook #'display-line-numbers-mode)
(add-hook 'c++-mode-hook #'lsp-deferred)
#+end_src
** Bash
#+begin_src emacs-lisp
(add-hook 'sh-mode-hook #'display-line-numbers-mode)
(add-hook 'sh-mode-hook #'lsp-deferred)
#+end_src
** HTML
#+begin_src emacs-lisp
(add-hook 'mhtml-mode-hook #'display-line-numbers-mode)
(add-hook 'mhtml-mode-hook #'lsp-deferred)
#+end_src
** TeX/LaTeX
#+begin_src emacs-lisp
(add-hook 'latex-mode-hook #'display-line-numbers-mode)
(add-hook 'latex-mode-hook #'lsp-deferred)
#+end_src
** JavaScript
#+begin_src emacs-lisp
(add-hook 'js-mode-hook #'display-line-numbers-mode)
(add-hook 'js-mode-hook #'lsp-deferred)
#+end_src
* Installed Modes
** Go
#+begin_src emacs-lisp
(use-package go-mode
:hook
go-mode
(go-mode . lsp-deferred)
(before-save . lsp-format-buffer)
(before-save . lsp-organize-imports)
:config
(add-hook 'go-mode-hook #'display-line-numbers-mode))
#+end_src
** TypeScript
#+begin_src emacs-lisp
(use-package typescript-mode
:mode "\\.ts\\'"
:hook
(typescript-mode . lsp-deferred)
(typescript-mode . display-line-numbers-mode))
#+end_src
* LSP ELPA Packages
** Python
#+begin_src emacs-lisp
(use-package lsp-pyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp-deferred)
(display-line-numbers-mode)))) ; or lsp
#+end_src
** Java
#+begin_src emacs-lisp
(use-package lsp-java
:hook
(java-mode-hook . display-line-numbers-mode)
(java-mode-hook . lsp-deferred))
#+end_src

152
unused/99-exwm.org Normal file
View File

@@ -0,0 +1,152 @@
#+TITLE: EXWM Configuration
Using Emacs as a window manager.
* Config Functions
This Config is not actually mine, so I don't fully understand it either
#+begin_src emacs-lisp
(defun exwm-config--fix/ido-buffer-window-other-frame ()
"Fix `ido-buffer-window-other-frame'."
(defalias 'exwm-config-ido-buffer-window-other-frame
(symbol-function #'ido-buffer-window-other-frame))
(defun ido-buffer-window-other-frame (buffer)
"This is a version redefined by EXWM.
You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
(with-current-buffer (window-buffer (selected-window))
(if (and (derived-mode-p 'exwm-mode)
exwm--floating-frame)
;; Switch from a floating frame.
(with-current-buffer buffer
(if (and (derived-mode-p 'exwm-mode)
exwm--floating-frame
(eq exwm--frame exwm-workspace--current))
;; Switch to another floating frame.
(frame-root-window exwm--floating-frame)
;; Do not switch if the buffer is not on the current workspace.
(or (get-buffer-window buffer exwm-workspace--current)
(selected-window))))
(with-current-buffer buffer
(when (derived-mode-p 'exwm-mode)
(if (eq exwm--frame exwm-workspace--current)
(when exwm--floating-frame
;; Switch to a floating frame on the current workspace.
(frame-selected-window exwm--floating-frame))
;; Do not switch to exwm-mode buffers on other workspace (which
;; won't work unless `exwm-layout-show-all-buffers' is set)
(unless exwm-layout-show-all-buffers
(selected-window)))))))))
#+end_src
* Start EXWM
#+begin_src emacs-lisp
(use-package exwm
:config
;; Set the default number of workspaces
(setq exwm-workspace-number 10)
;; When window "class" updates, use it to set the buffer name
(add-hook 'exwm-update-class-hook
(lambda ()
(exwm-workspace-rename-buffer exwm-class-name)))
;; Set the screen resolution (update this to be the correct resolution for your screen!)
(require 'exwm-randr)
;; (setq exwm-randr-workspace-output-plist
;; '(0 "HDMI1" 1 "eDP1" 2 "HDMI1" 3 "eDP1" 4 "HDMI1" 5 "eDP1" 6 "HDMI1" 7 "eDP1" 8 "HDMI1" 9 "eDP1"))
;; (add-hook 'exwm-randr-screen-change-hook
;; (lambda ()
;; (start-process-shell-command
;; "xrandr" nil "xrandr --output HDMI1 --primary --mode 1920x1080 --output eDP1 --left-of HDMI1 --mode 1366x768 --rotate left")))
(exwm-randr-enable)
;; Load the system tray before exwm-init
(require 'exwm-systemtray)
(exwm-systemtray-enable)
;; make emacs input method available to other programs
(require 'exwm-xim)
(exwm-xim-enable)
(require 'org-crypt)
(org-crypt-use-before-save-magic)
;; as the name suggests
;; (exwm-enable-ido-workaround)
;; These keys should always pass through to Emacs
(setq exwm-input-prefix-keys
'(?\C-x
?\C-u
?\C-h
?\M-x
?\M-`
?\M-&
?\M-:
?\C-\\ ;; backslash
?\C-\M-j ;; Buffer list
?\C-\ ;; ctrl-space
?\s-a ;; audio binding
?\s-m )) ;; music binding
;; Set up global key bindippngs. These always work, no matter the input state!
;; Keep in mind that changing this list after EXWM initializes has no effect.
(setq exwm-input-global-keys
`(
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)p
([?\s-w ?\C-r] . exwm-reset)
;; Move between windows
([?\s-w ?\s-b] . windmove-left)
([?\s-w ?\s-f] . windmove-right)
([?\s-w ?\s-p] . windmove-up)
([?\s-w ?\s-n] . windmove-down)
;; Launch applications via shell command
([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))
;; toggle modeline
([?\s-w ?\t] . exwm-layout-toggle-mode-line)
;; Switch workspace
([?\s-w ?\w] . exwm-workspace-switch)
([?\s-w ?\m] . exwm-workspace-move-window)))
;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
;; ,@(mapcar (lambda (i)
;; `(,(kbd (format "s-w %d" i)) .
;; (lambda ()
;; (interactive)
;; (exwm-workspace-switch-create ,i))))
;; (number-sequence 0 9))))
(setq exwm-input-simulation-keys
'(([?\C-b] . [left])
([?\C-f] . [right])
([?\C-p] . [up])
([?\C-n] . [down])
([?\C-a] . [home])
([?\C-e] . [end])
([?\C-\ ] . [?\C-a])
([?\M-v] . [prior])
([?\C-v] . [next])
([?\C-d] . [delete])
([?\C-k] . [S-end delete])
([?\C-s] . [?\C-f])
([?\C-x ?\h] . [?\C-h])
([?\C-y] . [?\C-v])
([?\C-g] . [escape])))
;; (exwm-enable)
(add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame))
#+end_src