(require 'package) (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "http://melpa.org/packages/"))) (when (< emacs-major-version 27) (package-initialize)) (require 'gnutls) (progn (package-refresh-contents) (package-install 'avy) (package-install 'php-mode) (package-install 'phps-mode) ;; (package-install 'anzu) (package-install 'anaconda-mode) (package-install 'auctex) ;; (package-install 'rmsbolt) ;; (package-install 'beginend) ;; (package-install 'composer) (package-install 'cinspect) (package-install 'debian-el) (package-install 'dpkg-dev-el) (package-install 'edebug-inline-result) ;;(package-install 'haskell-mode) ;;(package-install 'idris-mode) (package-install 'magit) (package-install 'git-timemachine) (package-install 'git-dwim) (package-install 'gitpatch) (package-install 'goto-chg) (package-install 'debbugs) ;;(package-install 'deft) ;; (package-install 'direnv) (package-install 'dumb-jump) (package-install 'docker) (package-install 'docker-cli) (package-install 'docker-tramp) (package-install 'docker-compose-mode) (package-install 'org-sql) ;;(package-install 'eglot) ;; (package-install 'eglot-java) ;; (package-install 'mastodon) ;; (package-install 'exec-path-from-shell) (package-install 'expand-region) ;; (package-install 'flymake-php) (package-install 'flycheck) (package-install 'flycheck-phpstan) (package-install 'phpactor) ;;(package-install 'robe) (package-install 'geiser) (package-install 'geiser-guile) (package-install 'guix) ;; (package-install 'git-gutter) ;; (package-install 'gnuplot) ;;(package-install 'swiper) ;;(package-install 'sqlite3) (package-install 'org-roam) ;; (package-install 'org-roam-ui) ;; (package-install 'org-download) ;; (package-install 'org-babel-eval-in-repl) ;;(package-install 'ob-php) ;; (package-install 'on-screen) ;;(package-install 'nix-mode) (package-install 'pdf-tools) ;;(package-install 'phpactor) ;; (package-install 'company-quickhelp) ;;(package-install 'ac-php) (package-install 'php-mode) (package-install 'php-quickhelp) (package-install 'phan) ;;(package-install 'php-cs-fixer) ;; (package-install 'company-php) ;;(package-install 'php-eldoc) ;;(package-install 'phps-mode) (package-install 'realgud) ;; (package-install 'realgud-xdebug) ;; (package-install 'kiwix) ;;(package-install 'sml-mode) (package-install 'sly) (package-install 'simple-httpd) (package-install 'sudo-edit) ;;(package-install 'treemacs) (package-install 'undo-tree) ;; (package-install 'yasnippet) ;; (package-install 'yasnippet-snippets) ;; (package-install 'vimrc-mode) ;; (package-install 'flymake-phpcs) ;; (package-install 'flymake-phpstan) ;; (package-install 'no-littering) (package-install 'web-mode) ;; (package-install 'which-key) ;; (package-install 'reverse-im) (package-install 'imenu-list) ;; (package-install 'isearch-mb) (package-install 'visual-fill-column) ;; (package-install 'browse-kill-ring) (package-install 'corfu) ;; (package-install 'inf-ruby) (package-install 'yaml-mode) ;; (package-install 'geben) (package-install 'link-hint) (package-install 'whole-line-or-region) (package-install 'quickrun) ;; (package-install 'psysh) ;; (package-install 'restclient) ) (when (eq window-system 'pgtk) (pgtk-use-im-context t)) (when (fboundp 'native-compile-async) (setq comp-async-compilation t package-native-compile t native-comp-speed 2 native-comp-async-jobs-number 1 comp-num-cpus 2 ;; JIT Compilation native-comp-deferred-compilation t ;; AOT Compilation package-native-compile t comp-async-report-warnings-errors nil)) ;; (native-compile-async "~/.emacs.d/elpa/" 'recursively) (native-compile-async "~/.guix-profile/share/emacs/site-lisp" 'recursively) ;; block until native compilation has finished (while (or comp-files-queue (> (comp-async-runnings) 0)) ;; Disable guix autoloading and x resources loading (setq site-run-file nil) (require 'exwm) (require 'exwm-config) (exwm-config-example) ;; Change mode-line-modes to show only major mode (defvar mode-line-major-mode (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out")) (list (propertize "%[" 'help-echo recursive-edit-help-echo) `(:propertize ("" mode-name) help-echo "Major mode\n\ mouse-1: Display major mode menu\n\ mouse-2: Show help for major mode\n\ mouse-3: Toggle minor modes" mouse-face mode-line-highlight local-map ,mode-line-major-mode-keymap) '("" mode-line-process) (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer" 'mouse-face 'mode-line-highlight 'local-map (make-mode-line-mouse-map 'mouse-2 #'mode-line-widen)) (propertize "%]" 'help-echo recursive-edit-help-echo) " ")) "Mode line construct for displaying major and minor modes.") (put 'mode-line-major-mode 'risky-local-variable t) ;; Change mode-line-format (setq-default mode-line-format '("%e" mode-line-front-space mode-line-mule-info mode-line-client mode-line-modified mode-line-remote mode-line-frame-identification ;; long-path mode-line-buffer-identification mode-line-misc-info " " mode-line-major-mode " " vc-mode " " mode-line-position mode-line-end-spaces )) ;; Do not resize the frame at this early stage. (setq frame-inhibit-implied-resize t) (setq use-dialog-box nil) ;;; Disable some gui (scroll-bar-mode -1) (tool-bar-mode -1) (menu-bar-mode -1) ;;(tooltip-mode -1) ;;; Changing emacs default setting through customize (custom-set-variables '(fill-column 72) '(git-gutter:added-sign " ") '(git-gutter:deleted-sign " ") '(git-gutter:modified-sign " ") '(git-gutter:unchanged-sign " ") '(lsp-headerline-breadcrumb-enable nil) '(scroll-bar-mode 'nil) '(scroll-bar-adjust-thumb-portion nil) '(tool-bar-position 'bottom) '(tool-bar-style 'both-horiz)) (custom-set-faces '(default ((t (:height 140 :family "Jetbrains Mono" :embolden t)))) '(region ((t (:background "gray85")))) '(mode-line ((t (:background "grey70" :foreground "grey10")))) '(mode-line-inactive ((t (:inherit mode-line :background "grey90" :foreground "grey20" :box (:line-width (-2 . -2) :color "grey85") :weight light)))) '(mode-line-buffer-id ((t (:weight bold)))) '(mode-line-emphasis ((t (:weight bold)))) '(lsp-modeline-code-actions-face ((t :inherit mode-line :height 100))) '(tool-bar ((t (:background "grey80" :foreground "grey10")))) '(fill-column-indicator ((t (:foreground "grey95")))) '(hl-line ((t (:background "gray95")))) '(fringe ((t (:background "grey87")))) '(header-line ((t (:inherit mode-line :background "grey90")))) '(vertical-border ((t (:foreground "grey90")))) '(window-divider ((t (:foreground "gray90"))))) (set-fringe-style (cons 7 7)) (defun switch-gui () "Disable/enable menu-bar and tool-bar." (interactive) (if menu-bar-mode (progn (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1)) (progn (menu-bar-mode 1) (tool-bar-mode 1) (scroll-bar-mode 1)))) (defun switch-scroll-bar () "Disable/enable scroll-bar." (interactive) (if scroll-bar-mode (scroll-bar-mode -1) (scroll-bar-mode))) (define-key global-map (kbd "") 'switch-gui) (define-key global-map (kbd "") 'switch-scroll-bar) (provide 'early-init) ;;; early-init.el ends here ;;(add-hook 'prog-mode-hook 'flymake-mode) (require 'psalm) (define-prefix-command 'flymake-map) (global-set-key (kbd "C-q") 'flymake-map) (define-key flymake-map (kbd "n") 'flymake-goto-next-error) (define-key flymake-map (kbd "p") 'flymake-goto-prev-error) (define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer) (define-key flymake-map (kbd "e") 'flymake-show-diagnostic) ;; (require 'psalm) (when (package-loaded? "flycheck") (defun flycheck-phanclient-start-daemon () "Start the phan daemon" (interactive) (let* ((default-directory (php-project-get-root-dir)) (phan-executable (or flycheck-phanclient--phan-executable (if (file-exists-p "vendor/bin/phan") (concat default-directory "vendor/bin/phan") (executable-find "phan")))) (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick"))) (apply #'start-process "PhanDaemon" "*phan daemon*" cmd))) (flycheck-define-checker php-phanclient "Phan" :command ("phan_client" "-l" source-original "-f" source) :error-patterns ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end)) :modes (php-mode php+-mode)) (add-to-list 'flycheck-checkers 'php-phanclient) (flycheck-add-next-checker 'php '(warning . php-phanclient)) (add-hook 'prog-mode-hook 'flycheck-mode)) (when (package-loaded? "treemacs") (progn (setq treemacs-width 50 treemacs-show-cursor t treemacs-position 'right treemacs-indentation 1 treemacs-tag-follow-mode t treemacs-fringe-indicator-mode nil) (define-key global-map (kbd "C-x C-d") 'treemacs))) (when (package-loaded? "isearch-mb") (progn (isearch-mb-mode t) (global-set-key (kbd "C-s") 'isearch-forward-regexp) (global-set-key (kbd "C-r") 'isearch-backward-regexp))) (when (package-loaded? "browse-kill-ring") (define-key global-map (kbd "C-M-y") 'browse-kill-ring)) (setq path-to-ctags "~/.guix-profile/bin/ctags") (defun tags-create (dir-name) "Create tags file." (interactive "DDirectory: ") (shell-command (format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name)))) (defun tags-create-python (dir-name) "Create tags with python interpreter" (interactive "DDirectory: ") (shell-command (format "%s -f TAGS -e -R --fields=+l --languages=python --python-kinds=-iv $(python -c \"import os, sys; print(' '.join('{}'.format(d) for d in sys.path if os.path.isdir(d)))\") %s" path-to-ctags (directory-file-name dir-name)))) (when (package-loaded? "realgud") (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el")) (when (package-loaded? "geben") (setq geben-dbgp-default-port 9003)) (when (package-loaded? "corfu") (progn (setq corfu-preview-current 'nil corfu-popupinfo-delay t) (corfu-mode 1) (corfu-popupinfo-mode 1) (defun show-default-completion-buffer () (interactive) (corfu-quit) (corfu-mode -1) (completion-at-point) (corfu-mode 1) (corfu-popupinfo-mode 1)) (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer) (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer) (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer) (corfu-mode -1) (add-hook 'prog-mode-hook 'corfu-mode) (defun corfu-send-shell (&rest _) "Send completion candidate when inside comint/eshell." (cond ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input)) (eshell-send-input)) ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input)) (comint-send-input)))) (advice-add #'corfu-insert :after #'corfu-send-shell) (add-hook 'eshell-mode-hook 'corfu-mode))) (setq completion-styles '(basic partial-completion substring flex emacs22) completion-ignore-case t read-buffer-completion-ignore-case t read-file-name-completion-ignore-case t) (setq aggressive-completion-delay 0.5) (aggressive-completion-mode t) (load "deft-autoloads") (define-key global-map (kbd "C-c n s") 'deft) (setq deft-recursive t deft-use-filter-string-for-filename t deft-default-extension "org md" deft-directory "~/projects/at-w96k/content/digarden") (when (package-loaded? "yasnippet") (progn (add-hook 'prog-mode-hook #'yas-minor-mode))) (defun my-php-mode-setup () "My PHP-mode hook." (require 'flycheck-phpstan) (flycheck-mode t)) (add-hook 'php-mode-hook 'my-php-mode-setup) ;; (add-hook 'php-mode-hook 'flymake-php-load) ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on) ;; (require 'flycheck-phpstan) ;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode)) ;; (phps-mode-flycheck-setup) ;; (setq phps-mode-async-process t) ;; (setq phps-mode-async-process-using-async-el t) (desktop-save-mode 1) (global-anzu-mode t) (load "swiper-autoloads") (global-set-key (kbd "C-s") 'swiper) (setq swiper-include-line-number-in-search t swiper-use-visual-line t swiper-stay-on-quit t) (load "which-key-autoloads") (which-key-setup-side-window-right) (which-key-mode) (setq which-key-side-window-max-width 0.5 which-key-show-remaining-keys t which-key-max-display-columns 50 which-key-max-description-length 35 which-key-sort-order 'which-key-local-then-key-order which-key-idle-delay 0.25) (add-hook 'prog-mode-hook 'rmsbolt-mode) ;; (when (package-loaded? "quickrun") ;; (define-key global-map (kbd "C-c C-c") 'quickrun)) (load "sly-autoloads") (setq sly-lisp-implementations '((clisp ("clisp")) (cmucl ("cmucl" "-quiet")) (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix))) (load "erlang-autoloads") (when (package-loaded? "inf-ruby") (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)) (when (package-loaded? "inf-ruby") (add-hook 'ruby-mode-hook 'robe-mode)) (when (package-loaded? "anaconda-mode") (progn (add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'anaconda-eldoc-mode))) ;; (when (load "flymake" t) ;; (defun flymake-pylint-init () ;; (let* ((temp-file (flymake-init-create-temp-buffer-copy ;; 'flymake-create-temp-inplace)) ;; (local-file (file-relative-name ;; temp-file ;; (file-name-directory buffer-file-name)))) ;; (list "epylint" (list local-file)))) ;; (add-to-list 'flymake-allowed-file-name-masks ;; '("\\.py\\'" flymake-pylint-init))) ;; (add-hook 'python-mode-hook 'flymake-mode) (add-hook 'sml-mode-hook 'sml-mode) ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/") ;; (require 'realgud-xdebug) ;; (defun init-php-mode () ;; (eglot-ensure)) (with-eval-after-load 'php-mode ;; (add-hook 'php-mode-hook #'init-php-mode) ) (when (package-loaded? "php-mode") (progn (add-hook 'php-mode-hook 'php-enable-symfony2-coding-style) (setq lsp-intelephense-php-version "8.1.16") (defvar phpactor-executable "~/.bin/phpactor") (custom-set-variables '(lsp-phpactor-path "~/usr/local/bin/phpactor")) (add-hook 'php-mode-hook '(lambda () ;; (require 'yasnippet) ;; (require 'yasnippet-snippets) (set-fill-column 120) ;; (make-local-variable 'eldoc-documentation-function) ;; (setq eldoc-documentation-function ;; 'phpactor-hover) ;; (yas-minor-mode t) (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point))) (setq php-manual-path "~/php/php-manual/" php-quickhelp-dir "~/php/php-manual/" php-quickhelp--dest "~/.emacs.d/php-manual/php_manual_en.json") ;; (add-hook 'php-mode-hook ;; '(lambda () ;; ;; (auto-complete-mode t) ;; ;; (require 'ac-php) ;; (require 'php-quickhelp) ;; (require 'company) ;; (company-mode t) ;; (require 'company-php) ;; (require 'company-quickhelp) ;; (require 'yasnippet) ;; (require 'yasnippet-snippets) ;; (set (make-local-variable 'company-backends) ;; '((company-ac-php-backend company-dabbrev-code) ;; php-quickhelp-company-php ;; company-capf company-files)) ;; (company-quickhelp-mode t) ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete) ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete) ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php)) ;; ;; (setq eldoc-documentation-function ;; ;; 'php-quickhelp-eldoc-func) ;; (yas-minor-mode t) ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete) ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete) ;; (define-key php-mode-map (kbd "C-c H") ;; 'php-local-manual-search) ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point) ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point) ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip) ;; ;; Jump to definition (optional) ;; (define-key php-mode-map ;; (kbd "M-.") 'ac-php-find-symbol-at-point) ;; ;; Return back (optional) ;; (define-key php-mode-map ;; (kbd "M-,") 'ac-php-location-stack-back))) )) (setq phpactor-executable "~/.bin/phpactor") (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor")) (use-package phpactor :ensure t) (use-package company-phpactor :ensure t) ;; (with-eval-after-load 'php-mode ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition) ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references)) (require 'transient) (define-transient-command php-menu () "Php" [["Class" ("cc" "Copy" phpactor-copy-class) ("cn" "New" phpactor-create-new-class) ("cr" "Move" phpactor-move-class) ("ci" "Inflect" phpactor-inflect-class) ("n" "Namespace" phpactor-fix-namespace)] ["Properties" ("a" "Accessor" phpactor-generate-accessors) ("pc" "Constructor" phpactor-complete-constructor) ("pm" "Add missing props" phpactor-complete-properties) ("r" "Rename var locally" phpactor-rename-variable-local) ("R" "Rename var in file" phpactor-rename-variable-file)] ["Extract" ("ec" "constant" phpactor-extract-constant) ("ee" "expression" phpactor-extract-expression) ("em" "method" phpactor-extract-method)] ["Methods" ("i" "Implement Contracts" phpactor-implement-contracts) ("m" "Generate method" phpactor-generate-method)] ["Navigate" ("x" "List refs" phpactor-list-references) ("X" "Replace refs" phpactor-replace-references) ("." "Goto def" phpactor-goto-definition)] ["Phpactor" ("s" "Status" phpactor-status) ("u" "Install" phpactor-install-or-update)]]) ;; Empty for now (was using emacsql) (setq lsp-sqls-server "~/go/bin/sqls") ;; (setq lsp-sqls-workspace-config-path nil) (setq lsp-sqls-connections '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24")))) (when (package-loaded? "org-sql") (setq org-sql-files "~/projects/profile24/org")) (add-hook 'sql-interactive-mode-hook (lambda () (sql-connect "profile24") (toggle-truncate-lines t))) (setq sql-connection-alist '((profile24 (sql-product 'mysql) (sql-server "localhost") (sql-user "dbuser") (sql-password "123456") (sql-database "testdb") (sql-port 3306)))) (load "org-ref-autoloads") (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib")) ;; see org-ref for use of these variables (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org" org-ref-default-bibliography '("~/Documents/Bibliography/references.bib") org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/") (when (package-loaded? "mastodon") (setq mastodon-active-user "w96k" mastodon-instance-url "https://fosstodon.org/")) (global-hl-line-mode 1) (add-to-list 'special-display-buffer-names "*Buffer List*") (setq Buffer-menu-files-only t) (setq exec-path-from-shell-variables '("PATH" "MANPATH")) (when (and (memq window-system '(mac ns x)) (not (eq system-type 'berkeley-unix))) (exec-path-from-shell-initialize)) (define-key global-map (kbd "C-q C-q") 'previous-buffer) (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer) (define-key global-map (kbd "C-h") 'delete-backward-char) (define-key global-map (kbd "C-c h") 'help-command) (setq browse-url-browser-function #'eww-browse-url) (add-hook 'eww-mode-hook (lambda () (set-fill-column 80) (display-fill-column-indicator-mode) (visual-fill-column-mode))) (add-to-list 'tramp-remote-path 'tramp-own-remote-path) (load "debian-el-autoloads") (load "dpkg-dev-el-autoloads") (package-loaded? "nix") (when (package-loaded? "direnv") (direnv-mode)) (defun zoom-in () (interactive) (let ((x (+ (face-attribute 'default :height) 10))) (set-face-attribute 'default nil :height x) (set-face-attribute 'mode-line nil :height x) (set-face-attribute 'mode-line-inactive nil :height x) (set-face-attribute 'mode-line-position-face nil :height x))) (defun zoom-out () (interactive) (let ((x (- (face-attribute 'default :height) 10))) (set-face-attribute 'default nil :height x) (set-face-attribute 'mode-line nil :height x) (set-face-attribute 'mode-line-inactive nil :height x) (set-face-attribute 'mode-line-position-face nil :height x))) (define-key global-map (kbd "C-=") 'zoom-in) (define-key global-map (kbd "C-+") 'zoom-out) (add-to-list 'default-frame-alist '(fullscreen . maximized)) (toggle-frame-fullscreen) (defun fullscreen () "Fullscreen." (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 ;; if first parameter is '1', can't toggle fullscreen status '(1 "_NET_WM_STATE_FULLSCREEN" 0))) ;; Better support for files with long lines (setq-default bidi-paragraph-direction 'left-to-right) (setq-default bidi-inhibit-bpa t) (global-so-long-mode 1)