Skip to content

Commit 3cdbf76

Browse files
committed
bunch of emacs tweaks
1 parent 316004a commit 3cdbf76

File tree

7 files changed

+346
-304
lines changed

7 files changed

+346
-304
lines changed

modules/home/emacs/android.nix

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
{
22
programs.emacs = {
33
init = {
4-
kotlin-ts-mode.enable = true;
5-
lsp-dart.enable = true;
6-
flutter.enable = true;
4+
usePackage = {
5+
kotlin-ts-mode = {
6+
enable = true;
7+
defer = true;
8+
};
9+
lsp-dart = {
10+
enable = true;
11+
defer = true;
12+
command = [ "lsp-dart-setup" ];
13+
};
14+
flutter = {
15+
enable = true;
16+
defer = true;
17+
command = [
18+
"flutter-run"
19+
"flutter-hot-reload"
20+
];
21+
};
22+
};
723
};
824
};
925
}

modules/home/emacs/consult.nix

Lines changed: 40 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"C-c M-x" = "consult-mode-command";
1313
"C-c h" = "consult-history";
1414
"C-c k" = "consult-kmacro";
15-
"C-c m" = "consult-man";
1615
"C-c i" = "consult-info";
1716
# ([remap Info-search] = "consult-info";
1817
# C-x bindings (ctl-x-map)
@@ -67,63 +66,37 @@
6766
};
6867

6968
init = ''
70-
(require 'consult-xref)
71-
(require 'consult-org)
72-
73-
;; Optionally configure the register formatting. This improves the register
74-
;; preview for `consult-register', `consult-register-load',
75-
;; `consult-register-store' and the Emacs built-ins.
76-
(setq register-preview-delay 0.5
77-
register-preview-function #'consult-register-format)
78-
79-
;; Optionally tweak the register preview window.
80-
;; This adds thin lines, sorting and hides the mode line of the window.
81-
(advice-add #'register-preview :override #'consult-register-window)
82-
83-
;; Use Consult to select xref locations with preview
84-
(setq xref-show-xrefs-function #'consult-xref
85-
xref-show-definitions-function #'consult-xref)
86-
87-
;; Configure other variables and modes in the :config section,
88-
;; after lazily loading the package.
89-
:config
90-
91-
;; Optionally configure preview. The default value
92-
;; is 'any, such that any key triggers the preview.
93-
;; (setq consult-preview-key 'any)
94-
;; (setq consult-preview-key "M-.")
95-
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
96-
;; For some commands and buffer sources it is useful to configure the
97-
;; :preview-key on a per-command basis using the `consult-customize' macro.
98-
(consult-customize
99-
consult-theme :preview-key '(:debounce 0.2 any)
100-
consult-ripgrep consult-git-grep consult-grep
101-
consult-bookmark consult-recent-file consult-xref
102-
;; :preview-key "M-."
103-
:preview-key '(:debounce 0.4 any))
104-
105-
;; Optionally configure the narrowing key.
106-
;; Both < and C-+ work reasonably well.
107-
(setq consult-narrow-key "<") ;; "C-+"
108-
109-
;; Optionally make narrowing help available in the minibuffer.
110-
;; You may want to use `embark-prefix-help-command' or which-key instead.
111-
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
112-
113-
;; By default `consult-project-function' uses `project-root' from project.el.
114-
;; Optionally configure a different project root function.
115-
;;;; 1. project.el (the default)
116-
;; (setq consult-project-function #'consult--default-project--function)
117-
;;;; 2. vc.el (vc-root-dir)
118-
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
119-
;;;; 3. locate-dominating-file
120-
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
121-
;;;; 4. projectile.el (projectile-project-root)
122-
;; (autoload 'projectile-project-root "projectile")
123-
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
124-
;;;; 5. No project support
125-
;; (setq consult-project-function nil)
69+
;; These settings can be applied before consult loads since they
70+
;; configure built-in Emacs variables, not consult functions.
71+
(setq register-preview-delay 0.5
72+
register-preview-function #'consult-register-format)
12673
74+
;; Optionally tweak the register preview window.
75+
(advice-add #'register-preview :override #'consult-register-window)
76+
77+
;; Use Consult to select xref locations with preview
78+
(setq xref-show-xrefs-function #'consult-xref
79+
xref-show-definitions-function #'consult-xref)
80+
81+
;; org clock (can be set before consult loads)
82+
(setq org-clock-persist t)
83+
(with-eval-after-load 'org
84+
(org-clock-persistence-insinuate))
85+
'';
86+
87+
config = ''
88+
(require 'consult-xref)
89+
(require 'consult-org)
90+
91+
;; Configure preview keys per-command
92+
(consult-customize
93+
consult-theme :preview-key '(:debounce 0.2 any)
94+
consult-ripgrep consult-git-grep consult-grep
95+
consult-bookmark consult-recent-file consult-xref
96+
:preview-key '(:debounce 0.4 any))
97+
98+
;; Configure the narrowing key.
99+
(setq consult-narrow-key "<")
127100
128101
(defvar consult--previous-point nil
129102
"Location of point before entering minibuffer.
@@ -158,12 +131,6 @@
158131
(length vertico--candidates))))))
159132
(setq consult--previous-point nil))
160133
161-
;; org clock
162-
163-
(setq org-clock-persist t)
164-
(with-eval-after-load 'org
165-
(org-clock-persistence-insinuate))
166-
167134
(defun consult-clock-in (&optional match scope resolve)
168135
"Clock into an Org heading."
169136
(interactive (list nil nil current-prefix-arg))
@@ -220,17 +187,16 @@
220187
# };
221188
# };
222189

223-
# embark-consult = {
224-
# enable = true;
225-
# after = [
226-
# "embark"
227-
# "consult"
228-
# ];
229-
# hook = [
230-
# "(embark-collect-mode . consult-preview-at-point-mode)"
231-
# # "(prog-mode . lsp)"
232-
# ];
233-
# };
190+
embark-consult = {
191+
enable = true;
192+
after = [
193+
"embark"
194+
"consult"
195+
];
196+
hook = [
197+
"(embark-collect-mode . consult-preview-at-point-mode)"
198+
];
199+
};
234200
};
235201
};
236202
};

0 commit comments

Comments
 (0)