Skip to content

Commit 6ad0bd8

Browse files
committed
Massive refactoring and some new modules.
1 parent 0d2c6e9 commit 6ad0bd8

File tree

31 files changed

+697
-34
lines changed

31 files changed

+697
-34
lines changed

init.el

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
;; directory (for easy access to its source code).
2121

2222
(doom! :input
23+
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
2324
;;chinese
2425
;;japanese
2526
;;layout ; auie,ctsrnm is the superior home row
2627

2728
:completion
28-
(company +childframe) ; the ultimate code completion backend
29+
;;(company +childframe) ; the ultimate code completion backend
30+
;;(corfu +icons +orderless)
2931
;;helm ; the *other* search engine for love and life
3032
;;ido ; the other *other* search engine...
3133
;;ivy ; a search engine for love and life
@@ -59,7 +61,7 @@
5961
zen ; distraction-free coding or writing
6062

6163
:editor
62-
(evil +everywhere); come to the dark side, we have cookies
64+
;;(evil +everywhere); come to the dark side, we have cookies
6365
file-templates ; auto-snippets for empty files
6466
fold ; (nigh) universal code folding
6567
format ; automated prettiness
@@ -101,7 +103,7 @@
101103
(eval +overlay) ; run code, run (also, repls)
102104
gist ; interacting with github gists
103105
(lookup +dictionary +docsets) ; navigate your code and its documentation
104-
(lsp +peek) ; M-x vscode
106+
;;(lsp +peek) ; M-x vscode
105107
(magit +forge) ; a git porcelain for Emacs
106108
make ; run make tasks from Emacs
107109
pass ; password manager for nerds
@@ -112,6 +114,7 @@
112114
;;terraform ; infrastructure as code
113115
;;tmux ; an API for interacting with tmux
114116
upload ; map local to remote projects via ssh/ftp
117+
tree-sitter
115118

116119
:os
117120
(:if IS-MAC macos) ; improve compatibility with macOS
@@ -120,7 +123,7 @@
120123
:lang
121124
;;agda ; types of types of types of types...
122125
;;beancount ; mind the GAAP
123-
(cc +lsp) ; C > C++ == 1
126+
(cc +lsp +tree-sitter) ; C > C++ == 1
124127
;;clojure ; java with a lisp
125128
;;common-lisp ; if you've seen one lisp, you've seen them all
126129
;;coq ; proofs-as-programs
@@ -140,11 +143,11 @@
140143
;;fsharp ; ML stands for Microsoft's Language
141144
;;fstar ; (dependent) types and (monadic) effects and Z3
142145
;;gdscript ; the language you waited for
143-
;;(go +lsp) ; the hipster dialect
146+
(go +lsp +tree-sitter) ; the hipster dialect
144147
;;(haskell +lsp) ; a language that's lazier than I am
145148
;;hy ; readability of scheme w/ speed of python
146149
;;idris ; a language you can depend on
147-
(json +lsp) ; At least it ain't XML
150+
(json +lsp +tree-sitter) ; At least it ain't XML
148151
;;(java +lsp) ; the poster child for carpal tunnel syndrome
149152
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
150153
;;julia ; a better, faster MATLAB
@@ -181,7 +184,7 @@
181184
;;rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
182185
;;scala ; java, but good
183186
;;(scheme +guile) ; a fully conniving family of lisps
184-
(sh +lsp) ; she sells {ba,z,fi}sh shells on the C xor
187+
(sh +lsp +tree-sitter) ; she sells {ba,z,fi}sh shells on the C xor
185188
;;sml
186189
;;solidity ; do you need a blockchain? No.
187190
;;swift ; who asked for emoji variables?
@@ -209,14 +212,23 @@
209212

210213
:h-cheung
211214
chinese
212-
(telega ; telegram
213-
+auto-im) ; auto toggle input method
215+
;;(telega ; telegram
216+
;; +auto-im) ; auto toggle input method
214217
tools
215218
ui
216219
(:if (featurep! :lang cc) cc-extra)
220+
(:if (featurep! :lang go) go-extra)
217221
;;(:if (featurep! :lang python) python-extra)
218222
systemd
223+
rpmspec
219224
pkgbuild
220225
(:if (featurep! :term eshell) eshell-extra)
221226
fish
222-
(:if (featurep! :editor evil) evil-hybird))
227+
(:if (featurep! :editor evil) evil-hybird)
228+
ement
229+
copilot
230+
;;tabnine
231+
lsp-bridge
232+
;;lspce
233+
eaf
234+
netease-music)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
;;; completion/corfu/autoload/corfu.el -*- lexical-binding: t; -*-
2+
;;;###if (featurep! :completion corfu +minibuffer)
3+
4+
;;;###autoload
5+
(defun +corfu--enable-in-minibuffer ()
6+
(unless (or (bound-and-true-p mct--active)
7+
(bound-and-true-p vertico--input)
8+
(memq this-command '(evil-ex
9+
evil-ex-search-forward
10+
evil-ex-search-backward))
11+
(and (featurep! :completion helm)
12+
(helm--alive-p))
13+
(corfu-mode +1))))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
;;; completion/corfu/autoload/extra.el -*- lexical-binding: t; -*-
2+
3+
;;;###autoload
4+
(defun +corfu-complete-file-at-point ()
5+
"Complete a file path from scratch at point"
6+
(interactive)
7+
(completion-in-region (point) (point) #'read-file-name-internal))
8+
9+
;;;###autoload
10+
(defun +corfu-files ()
11+
"Complete using files source"
12+
(interactive)
13+
(let ((completion-at-point-functions (list #'+file-completion-at-point-function)))
14+
(completion-at-point)))
15+
16+
;;;###autoload
17+
(defun +corfu-dabbrev ()
18+
"Complete using dabbrev source"
19+
(interactive)
20+
(let ((completion-at-point-functions (list #'+dabbrev-completion-at-point-function)))
21+
(completion-at-point)))
22+
23+
;;;###autoload
24+
(defun +corfu-ispell ()
25+
"Complete using ispell source.
26+
27+
See `ispell-lookup-words' for more info"
28+
(interactive)
29+
(let ((completion-at-point-functions (list #'+ispell-completion-at-point-function)))
30+
(completion-at-point)))
31+
32+
;;;###autoload
33+
(defun +corfu-dict ()
34+
"Complete using dict source.
35+
36+
See `+dict--words' for extra words, and `+dict-file' for a wordslist source "
37+
(interactive)
38+
(let ((completion-at-point-functions (list #'+dict-completion-at-point-function)))
39+
(completion-at-point)))
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
;; Daniel "minad" Mendler extra capfs -*- lexical-binding: t -*-
2+
;; Source : https://github.com/minad/corfu/issues/9#issuecomment-945090516
3+
4+
(require 'dabbrev)
5+
6+
;;;###autoload
7+
(defun +file-completion-at-point-function ()
8+
"File name completion-at-point-function."
9+
(when-let (bounds (bounds-of-thing-at-point 'filename))
10+
(list (car bounds) (cdr bounds)
11+
'read-file-name-internal
12+
:exclusive 'no
13+
:annotation-function (lambda (_) " (File)"))))
14+
15+
;;;###autoload
16+
(defun +dabbrev-completion-at-point-function ()
17+
(let ((dabbrev-check-all-buffers nil)
18+
(dabbrev-check-other-buffers nil))
19+
(dabbrev--reset-global-variables))
20+
(let ((abbrev (ignore-errors (dabbrev--abbrev-at-point))))
21+
(when (and abbrev (not (string-match-p "[ \t]" abbrev)))
22+
(pcase ;; Interruptible scanning
23+
(while-no-input
24+
(let ((inhibit-message t)
25+
(message-log-max nil))
26+
(or (dabbrev--find-all-expansions
27+
abbrev (dabbrev--ignore-case-p abbrev))
28+
t)))
29+
('nil (keyboard-quit))
30+
('t nil)
31+
(words
32+
;; Ignore completions which are too short
33+
(let ((min-len (+ 4 (length abbrev))))
34+
(setq words (seq-remove (lambda (x) (< (length x) min-len)) words)))
35+
(when words
36+
(let ((beg (progn (search-backward abbrev) (point)))
37+
(end (progn (search-forward abbrev) (point))))
38+
(unless (string-match-p "\n" (buffer-substring beg end))
39+
(list beg end words
40+
:exclusive 'no
41+
:annotation-function (lambda (_) " (Dabbrev)"))))))))))
42+
43+
(autoload 'ispell-lookup-words "ispell")
44+
45+
;;;###autoload
46+
(defun +ispell-completion-at-point-function ()
47+
(when-let* ((bounds (bounds-of-thing-at-point 'word))
48+
(table (with-demoted-errors
49+
(let ((message-log-max nil)
50+
(inhibit-message t))
51+
(ispell-lookup-words
52+
(format "*%s*"
53+
(buffer-substring-no-properties (car bounds) (cdr bounds))))))))
54+
(list (car bounds) (cdr bounds) table
55+
:exclusive 'no
56+
:annotation-function (lambda (_) " (Ispell)"))))
57+
58+
(defun +word-completion-at-point-function (words)
59+
(when-let (bounds (bounds-of-thing-at-point 'word))
60+
(list (car bounds) (cdr bounds) words
61+
:exclusive 'no
62+
:annotation-function (lambda (_) " (Words)"))))
63+
64+
(defvar +dict--words nil)
65+
(defvar +dict-file "/etc/dictionaries-common/words")
66+
67+
;;;###autoload
68+
(defun +dict-completion-at-point-function ()
69+
(+word-completion-at-point-function
70+
(or +dict--words
71+
(setq +dict--words
72+
(split-string (with-temp-buffer
73+
(insert-file-contents-literally +dict-file)
74+
(buffer-string))
75+
"\n")))))

modules/completion/corfu/config.el

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
;;; completion/corfu/config.el -*- lexical-binding: t; -*-
2+
3+
(use-package! corfu
4+
:custom
5+
(corfu-separator ?\s)
6+
(corfu-auto t)
7+
(corfu-auto-delay 0.0)
8+
(corfu-on-exact-match nil)
9+
(corfu-quit-no-match t)
10+
(corfu-cycle t)
11+
(corfu-auto-prefix 2)
12+
(completion-cycle-threshold 1)
13+
(tab-always-indent 'complete)
14+
:hook
15+
(doom-first-buffer . global-corfu-mode)
16+
:config
17+
(when (featurep! +minibuffer)
18+
(add-hook 'minibuffer-setup-hook #'+corfu--enable-in-minibuffer))
19+
20+
;; Dirty hack to get c completion running
21+
;; Discussion in https://github.com/minad/corfu/issues/34
22+
(when (and (featurep! :lang cc)
23+
(equal tab-always-indent 'complete))
24+
(map! :map c-mode-base-map
25+
:i [remap c-indent-line-or-region] #'completion-at-point))
26+
27+
;; Reset lsp-completion provider
28+
(add-hook 'doom-init-modules-hook
29+
(lambda ()
30+
(after! lsp-mode
31+
(setq lsp-completion-provider :none))))
32+
33+
;; Set orderless filtering for LSP-mode completions
34+
(add-hook 'lsp-completion-mode-hook
35+
(lambda ()
36+
(setf (alist-get 'lsp-capf completion-category-defaults) '((styles . (orderless flex))))))
37+
38+
(map! :map corfu-map
39+
"C-SPC" #'corfu-insert-separator
40+
"C-n" #'corfu-next
41+
"C-p" #'corfu-previous
42+
(:prefix "C-x"
43+
"C-k" #'cape-dict
44+
"C-f" #'cape-file))
45+
(after! evil
46+
(advice-add 'corfu--setup :after 'evil-normalize-keymaps)
47+
(advice-add 'corfu--teardown :after 'evil-normalize-keymaps)
48+
(evil-make-overriding-map corfu-map))
49+
50+
(defadvice! +corfu--org-return (orig) :around '+org/return
51+
(if (and (featurep! :completion corfu)
52+
corfu-mode
53+
(>= corfu--index 0))
54+
(corfu-insert)
55+
(funcall orig)))
56+
57+
(unless (display-graphic-p)
58+
(corfu-doc-terminal-mode)
59+
(corfu-terminal-mode)))
60+
61+
62+
(use-package! corfu-doc
63+
:hook (corfu-mode . corfu-doc-mode)
64+
:custom
65+
(corfu-doc-delay 0)
66+
:bind (:map corfu-map
67+
("M-n" . corfu-doc-scroll-down)
68+
("M-p" . corfu-doc-scroll-up)
69+
("M-d" . corfu-doc-toggle)))
70+
71+
72+
(use-package! orderless
73+
:when (featurep! +orderless)
74+
:init
75+
(setq completion-styles '(orderless partial-completion)
76+
completion-category-defaults nil
77+
completion-category-overrides '((file (styles . (partial-completion))))))
78+
79+
80+
(use-package! kind-icon
81+
:after corfu
82+
:when (featurep! +icons)
83+
:custom
84+
(kind-icon-default-face 'corfu-default)
85+
:config
86+
(setq kind-icon-use-icons t
87+
svg-lib-icons-dir (expand-file-name "svg-lib" doom-cache-dir)
88+
kind-icon-mapping
89+
'((array "a" :icon "code-brackets" :face font-lock-variable-name-face)
90+
(boolean "b" :icon "circle-half-full" :face font-lock-builtin-face)
91+
(class "c" :icon "view-grid-plus-outline" :face font-lock-type-face)
92+
(color "#" :icon "palette" :face success)
93+
(constant "co" :icon "pause-circle" :face font-lock-constant-face)
94+
(constructor "cn" :icon "table-column-plus-after" :face font-lock-function-name-face)
95+
(enum "e" :icon "format-list-bulleted-square" :face font-lock-builtin-face)
96+
(enum-member "em" :icon "format-list-checks" :face font-lock-builtin-face)
97+
(event "ev" :icon "lightning-bolt-outline" :face font-lock-warning-face)
98+
(field "fd" :icon "application-braces-outline" :face font-lock-variable-name-face)
99+
(file "f" :icon "file" :face font-lock-string-face)
100+
(folder "d" :icon "folder" :face font-lock-doc-face)
101+
(function "f" :icon "sigma" :face font-lock-function-name-face)
102+
(interface "if" :icon "video-input-component" :face font-lock-type-face)
103+
(keyword "kw" :icon "image-filter-center-focus" :face font-lock-keyword-face)
104+
(macro "mc" :icon "lambda" :face font-lock-keyword-face)
105+
(method "m" :icon "sigma" :face font-lock-function-name-face)
106+
(module "{" :icon "view-module" :face font-lock-preprocessor-face)
107+
(numeric "nu" :icon "numeric" :face font-lock-builtin-face)
108+
(operator "op" :icon "plus-circle-outline" :face font-lock-comment-delimiter-face)
109+
(param "pa" :icon "cog" :face default)
110+
(property "pr" :icon "tune-vertical" :face font-lock-variable-name-face)
111+
(reference "rf" :icon "bookmark-box-multiple" :face font-lock-variable-name-face)
112+
(snippet "S" :icon "text-short" :face font-lock-string-face)
113+
(string "s" :icon "sticker-text-outline" :face font-lock-string-face)
114+
(struct "%" :icon "code-braces" :face font-lock-variable-name-face)
115+
(t "." :icon "crosshairs-question" :face shadow)
116+
(text "tx" :icon "script-text-outline" :face shadow)
117+
(type-parameter "tp" :icon "format-list-bulleted-type" :face font-lock-type-face)
118+
(unit "u" :icon "ruler-square" :face shadow)
119+
(value "v" :icon "numeric-1-box-multiple-outline" :face font-lock-builtin-face)
120+
(variable "va" :icon "adjust" :face font-lock-variable-name-face))
121+
kind-icon-default-style '(:padding 0 :stroke 0 :margin 0 :radius 0 :height 0.95 :scale 0.95))
122+
(add-hook 'doom-load-theme-hook #'kind-icon-reset-cache)
123+
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
124+
125+
126+
(use-package! cape
127+
:defer t
128+
:init
129+
(map!
130+
[remap dabbrev-expand] 'cape-dabbrev)
131+
(add-hook! 'latex-mode-hook (defun +corfu--latex-set-capfs ()
132+
(add-to-list 'completion-at-point-functions #'cape-tex)))
133+
(when (featurep! :checkers spell)
134+
(add-to-list 'completion-at-point-functions #'cape-dict)
135+
(add-to-list 'completion-at-point-functions #'cape-ispell))
136+
(add-to-list 'completion-at-point-functions #'cape-file)
137+
(add-to-list 'completion-at-point-functions #'cape-keyword t)
138+
(add-to-list 'completion-at-point-functions #'cape-dabbrev t))
139+
140+
141+
(use-package! corfu-history
142+
:after corfu
143+
:hook (corfu-mode . (lambda ()
144+
(corfu-history-mode 1)
145+
(savehist-mode 1)
146+
(add-to-list 'savehist-additional-variables 'corfu-history))))
147+
148+
149+
(use-package! corfu-quick
150+
:after corfu
151+
:bind (:map corfu-map
152+
("M-q" . corfu-quick-complete)
153+
("C-q" . corfu-quick-insert)))
154+
155+
156+
;; TODO This doesn't _quite_ work
157+
(use-package! evil-collection-corfu
158+
:when (featurep! :editor evil +everywhere)
159+
:defer t
160+
:init (setq evil-collection-corfu-key-themes '(default magic-return))
161+
:config
162+
(evil-collection-corfu-setup))

0 commit comments

Comments
 (0)