source: dotfiles/emacs/.emacs.d/nil@ 9bc0481

Last change on this file since 9bc0481 was 9bc0481, checked in by Mikhail Kirillov <w96k@…>, on Dec 12, 2024 at 4:57:35 PM

Update config

  • Property mode set to 100644
File size: 11.5 KB
Line 
1(require 'package)
2
3(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
4 ("melpa" . "http://melpa.org/packages/")))
5
6(when (< emacs-major-version 27)
7 (package-initialize))
8
9(require 'gnutls)
10
11(require 'exwm)
12(require 'exwm-config)
13(exwm-config-example)
14
15(add-hook 'prog-mode-hook 'flymake-mode)
16
17(require 'psalm)
18
19(define-prefix-command 'flymake-map)
20(global-set-key (kbd "C-q") 'flymake-map)
21(define-key flymake-map (kbd "n") 'flymake-goto-next-error)
22(define-key flymake-map (kbd "p") 'flymake-goto-prev-error)
23(define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer)
24(define-key flymake-map (kbd "e") 'flymake-show-diagnostic)
25
26;; (require 'psalm)
27
28(when (package-loaded? "flycheck")
29
30 (defun flycheck-phanclient-start-daemon ()
31 "Start the phan daemon"
32 (interactive)
33 (let* ((default-directory (php-project-get-root-dir))
34 (phan-executable (or flycheck-phanclient--phan-executable
35 (if (file-exists-p "vendor/bin/phan")
36 (concat default-directory "vendor/bin/phan")
37 (executable-find "phan"))))
38 (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick")))
39 (apply #'start-process "PhanDaemon" "*phan daemon*" cmd)))
40
41 (flycheck-define-checker php-phanclient
42 "Phan"
43 :command ("phan_client" "-l" source-original "-f" source)
44 :error-patterns
45 ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end))
46 :modes (php-mode php+-mode))
47
48 (add-to-list 'flycheck-checkers 'php-phanclient)
49
50 (flycheck-add-next-checker 'php '(warning . php-phanclient))
51
52 (add-hook 'prog-mode-hook 'flycheck-mode))
53
54(when (package-loaded? "realgud")
55 (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el"))
56
57(when (package-loaded? "geben")
58 (setq geben-dbgp-default-port 9003))
59
60(when (package-loaded? "corfu")
61 (progn
62 (setq corfu-preview-current 'nil
63 corfu-popupinfo-delay t)
64 (corfu-mode 1)
65 (corfu-popupinfo-mode 1)
66 (defun show-default-completion-buffer ()
67 (interactive)
68 (corfu-quit)
69 (corfu-mode -1)
70 (completion-at-point)
71 (corfu-mode 1)
72 (corfu-popupinfo-mode 1))
73 (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer)
74 (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer)
75 (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer)
76 (corfu-mode -1)
77 (add-hook 'prog-mode-hook 'corfu-mode)
78
79 (defun corfu-send-shell (&rest _)
80 "Send completion candidate when inside comint/eshell."
81 (cond
82 ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
83 (eshell-send-input))
84 ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
85 (comint-send-input))))
86
87 (advice-add #'corfu-insert :after #'corfu-send-shell)
88
89 (add-hook 'eshell-mode-hook 'corfu-mode)))
90
91(setq aggressive-completion-delay 0.5)
92(aggressive-completion-mode t)
93
94(load "deft-autoloads")
95
96(define-key global-map
97 (kbd "C-c n s") 'deft)
98
99(setq deft-recursive t
100 deft-use-filter-string-for-filename t
101 deft-default-extension "org md"
102 deft-directory "~/projects/at-w96k/content/digarden")
103
104(when (package-loaded? "yasnippet")
105 (progn
106 (add-hook 'prog-mode-hook #'yas-minor-mode)))
107
108(defun my-php-mode-setup ()
109 "My PHP-mode hook."
110 (require 'flycheck-phpstan)
111 (flycheck-mode t))
112
113(add-hook 'php-mode-hook 'my-php-mode-setup)
114
115;; (add-hook 'php-mode-hook 'flymake-php-load)
116 ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on)
117
118 ;; (require 'flycheck-phpstan)
119
120
121;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
122
123;; (phps-mode-flycheck-setup)
124
125;; (setq phps-mode-async-process t)
126;; (setq phps-mode-async-process-using-async-el t)
127
128(load "swiper-autoloads")
129(global-set-key (kbd "C-s") 'swiper)
130
131(setq swiper-include-line-number-in-search t
132 swiper-use-visual-line t
133 swiper-stay-on-quit t)
134
135(load "which-key-autoloads")
136(which-key-setup-side-window-right)
137(which-key-mode)
138
139(setq which-key-side-window-max-width 0.5
140 which-key-show-remaining-keys t
141 which-key-max-display-columns 50
142 which-key-max-description-length 35
143 which-key-sort-order 'which-key-local-then-key-order
144 which-key-idle-delay 0.25)
145
146;; (when (package-loaded? "quickrun")
147;; (define-key global-map (kbd "C-c C-c") 'quickrun))
148
149(load "sly-autoloads")
150
151(setq sly-lisp-implementations
152 '((clisp ("clisp"))
153 (cmucl ("cmucl" "-quiet"))
154 (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix)))
155
156(when (package-loaded? "inf-ruby")
157 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode))
158
159(when (package-loaded? "inf-ruby")
160 (add-hook 'ruby-mode-hook 'robe-mode))
161
162(when (package-loaded? "anaconda-mode")
163 (progn
164 (add-hook 'python-mode-hook 'anaconda-mode)
165 (add-hook 'python-mode-hook 'anaconda-eldoc-mode)))
166
167;; (when (load "flymake" t)
168;; (defun flymake-pylint-init ()
169;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
170;; 'flymake-create-temp-inplace))
171;; (local-file (file-relative-name
172;; temp-file
173;; (file-name-directory buffer-file-name))))
174;; (list "epylint" (list local-file))))
175
176;; (add-to-list 'flymake-allowed-file-name-masks
177;; '("\\.py\\'" flymake-pylint-init)))
178
179;; (add-hook 'python-mode-hook 'flymake-mode)
180
181(add-hook 'sml-mode-hook 'sml-mode)
182
183;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
184;; (require 'realgud-xdebug)
185
186;; (defun init-php-mode ()
187;; (eglot-ensure))
188
189(use-package php-mode
190 :bind ("C-c h" . 'php-quickhelp-at-point)
191 :config
192
193 (setq php-manual-path
194 "~/projects/php-manual/"
195 php-quickhelp-dir "~/projects/php-manual/"
196 php-quickhelp--dest "~/projects/php-manual/php_manual_en.json"))
197
198
199;; (add-hook 'php-mode-hook
200;; '(lambda ()
201;; ;; (auto-complete-mode t)
202
203;; ;; (require 'ac-php)
204;; (require 'php-quickhelp)
205;; (require 'company)
206;; (company-mode t)
207;; (require 'company-php)
208;; (require 'company-quickhelp)
209
210;; (require 'yasnippet)
211;; (require 'yasnippet-snippets)
212
213;; (set (make-local-variable 'company-backends)
214;; '((company-ac-php-backend company-dabbrev-code)
215;; php-quickhelp-company-php
216;; company-capf company-files))
217
218;; (company-quickhelp-mode t)
219
220;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
221;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
222
223;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
224;; ;; (setq eldoc-documentation-function
225;; ;; 'php-quickhelp-eldoc-func)
226
227;; (yas-minor-mode t)
228
229;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
230;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
231
232;; (define-key php-mode-map (kbd "C-c H")
233;; 'php-local-manual-search)
234
235;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
236;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
237
238;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
239
240;; ;; Jump to definition (optional)
241;; (define-key php-mode-map
242;; (kbd "M-.") 'ac-php-find-symbol-at-point)
243
244;; ;; Return back (optional)
245;; (define-key php-mode-map
246;; (kbd "M-,") 'ac-php-location-stack-back)))
247))
248
249(setq phpactor-executable "~/.bin/phpactor")
250(custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
251
252(use-package phpactor :ensure t)
253(use-package company-phpactor :ensure t)
254
255
256
257;; (with-eval-after-load 'php-mode
258;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
259;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
260
261(require 'transient)
262(define-transient-command php-menu ()
263 "Php"
264 [["Class"
265 ("cc" "Copy" phpactor-copy-class)
266 ("cn" "New" phpactor-create-new-class)
267 ("cr" "Move" phpactor-move-class)
268 ("ci" "Inflect" phpactor-inflect-class)
269 ("n" "Namespace" phpactor-fix-namespace)]
270 ["Properties"
271 ("a" "Accessor" phpactor-generate-accessors)
272 ("pc" "Constructor" phpactor-complete-constructor)
273 ("pm" "Add missing props" phpactor-complete-properties)
274 ("r" "Rename var locally" phpactor-rename-variable-local)
275 ("R" "Rename var in file" phpactor-rename-variable-file)]
276 ["Extract"
277 ("ec" "constant" phpactor-extract-constant)
278 ("ee" "expression" phpactor-extract-expression)
279 ("em" "method" phpactor-extract-method)]
280 ["Methods"
281 ("i" "Implement Contracts" phpactor-implement-contracts)
282 ("m" "Generate method" phpactor-generate-method)]
283 ["Navigate"
284 ("x" "List refs" phpactor-list-references)
285 ("X" "Replace refs" phpactor-replace-references)
286 ("." "Goto def" phpactor-goto-definition)]
287 ["Phpactor"
288 ("s" "Status" phpactor-status)
289 ("u" "Install" phpactor-install-or-update)]])
290
291;; Empty for now (was using emacsql)
292(setq lsp-sqls-server "~/go/bin/sqls")
293
294;; (setq lsp-sqls-workspace-config-path nil)
295
296(setq lsp-sqls-connections
297 '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
298
299(when (package-loaded? "org-sql")
300 (setq org-sql-files "~/projects/profile24/org"))
301
302(add-hook 'sql-interactive-mode-hook
303 (lambda ()
304 (sql-connect "profile24")
305 (toggle-truncate-lines t)))
306
307(setq sql-connection-alist
308 '((profile24
309 (sql-product 'mysql)
310 (sql-server "localhost")
311 (sql-user "dbuser")
312 (sql-password "123456")
313 (sql-database "testdb")
314 (sql-port 3306))))
315
316(load "org-ref-autoloads")
317
318(setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
319
320;; see org-ref for use of these variables
321(setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
322 org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
323 org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
324
325(global-hl-line-mode t)
326
327(setq exec-path-from-shell-variables
328 '("PATH" "MANPATH"))
329
330(when (and (memq window-system '(mac ns x))
331 (not (eq system-type 'berkeley-unix)))
332 (exec-path-from-shell-initialize))
333
334(define-key global-map (kbd "C-q C-q") 'previous-buffer)
335(define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
336
337(define-key global-map (kbd "C-h") 'delete-backward-char)
338(define-key global-map (kbd "C-c h") 'help-command)
339
340(setq browse-url-browser-function #'eww-browse-url)
341
342(add-hook 'eww-mode-hook
343 (lambda ()
344 (set-fill-column 80)
345 (display-fill-column-indicator-mode)
346 (visual-fill-column-mode)))
347
348(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
349
350(load "debian-el-autoloads")
351(load "dpkg-dev-el-autoloads")
352
353(when (package-loaded? "direnv")
354 (direnv-mode))
355
356(defun zoom-in ()
357 (interactive)
358 (let ((x (+ (face-attribute 'default :height)
359 10)))
360 (set-face-attribute 'default nil :height x)
361 (set-face-attribute 'mode-line nil :height x)
362 (set-face-attribute 'mode-line-inactive nil :height x)
363 (set-face-attribute 'mode-line-position-face nil :height x)))
364
365(defun zoom-out ()
366 (interactive)
367 (let ((x (- (face-attribute 'default :height)
368 10)))
369 (set-face-attribute 'default nil :height x)
370 (set-face-attribute 'mode-line nil :height x)
371 (set-face-attribute 'mode-line-inactive nil :height x)
372 (set-face-attribute 'mode-line-position-face nil :height x)))
373
374(define-key global-map (kbd "C-=") 'zoom-in)
375(define-key global-map (kbd "C-+") 'zoom-out)
376
377(add-to-list 'default-frame-alist '(fullscreen . maximized))
378
379(toggle-frame-fullscreen)
380
381(defun fullscreen ()
382"Fullscreen."
383(interactive)
384(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
385 ;; if first parameter is '1', can't toggle fullscreen status
386 '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
387
388;; Better support for files with long lines
389(setq-default bidi-paragraph-direction 'left-to-right)
390(setq-default bidi-inhibit-bpa t)
391(global-so-long-mode 1)
Note: See TracBrowser for help on using the repository browser.