From d63f7bc41445474bbcd14715a5672d873327fc40 Mon Sep 17 00:00:00 2001 From: koonwen Date: Fri, 19 Jul 2024 23:05:28 +0200 Subject: [PATCH] some changes --- core/prelude-ui.el | 6 +- personal/0_general_config.el | 144 ++++++++++++++++------------------- personal/9_c_config.el | 33 ++++---- personal/9_ocaml_config.el | 23 +++--- 4 files changed, 99 insertions(+), 107 deletions(-) diff --git a/core/prelude-ui.el b/core/prelude-ui.el index 2948323..eeca6c4 100644 --- a/core/prelude-ui.el +++ b/core/prelude-ui.el @@ -86,9 +86,9 @@ ;; add to hook when running as a daemon as a workaround for a ;; which-key bug ;; https://github.com/justbur/emacs-which-key/issues/306 -(if (daemonp) - (add-hook 'server-after-make-frame-hook 'which-key-mode) - (which-key-mode +1)) +;; (if (daemonp) +;; (add-hook 'server-after-make-frame-hook 'which-key-mode) +;; (which-key-mode +1)) (provide 'prelude-ui) ;;; prelude-ui.el ends here diff --git a/personal/0_general_config.el b/personal/0_general_config.el index 0c96fe3..2007169 100644 --- a/personal/0_general_config.el +++ b/personal/0_general_config.el @@ -4,18 +4,23 @@ (prelude-require-packages '(beacon - multiple-cursors twilight-bright-theme - projectile-ripgrep - helm-swoop - goto-last-change - treemacs treemacs-projectile treemacs-magit)) + helm-swoop)) ;; Default Zoom (set-face-attribute 'default (selected-frame) :height 150) +;; Sane Defaults +(setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) +(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t))) + +(setq delete-old-versions -1) +(setq version-control t) +(setq vc-make-backup-files t) + +(blink-cursor-mode t) (setq prelude-super-keybindings nil) -(setq crux-shell "/bin/fish") +(setq crux-shell "/bin/bash") (defun vsplit-other-window () "Splits the window vertically and switches to that window." @@ -28,6 +33,16 @@ (split-window-horizontally) (other-window 1 nil)) +;; Highlight line on point. +(global-hl-line-mode t) + +;; Show line numbers on left column +(global-display-line-numbers-mode t) + +;; Make sure use-package always downloads the package first +(require 'use-package) +(setq use-package-always-ensure t) + ;; Themes (use-package twilight-bright-theme) (use-package flatland-theme) @@ -42,13 +57,13 @@ (disable-theme 'flatland))) ;; Keybindings -(bind-key "C-c C-\\" #'toggle-themes) -(bind-key "C-c C-\\" #'toggle-themes) -(bind-key "" 'scroll-lock-mode) (bind-key "C-x 2" #'vsplit-other-window) (bind-key "C-x 3" #'hsplit-other-window) -(bind-key "M-" #'er/expand-region) -(bind-key "M-" #'er/contract-region) +(bind-key "M-S-C-" #'shrink-window-horizontally) +(bind-key "M-S-C-" #'enlarge-window-horizontally) +(bind-key "M-S-C-" #'shrink-window) +(bind-key "M-S-C-" #'enlarge-window) +(bind-key "" 'scroll-lock-mode) ;; Automatic reloading of buffers (global-auto-revert-mode t) @@ -76,90 +91,61 @@ (global-ligature-mode 't)) ) -(blink-cursor-mode t) +;; Background modes -;; Start activity-watch-mode -(global-activity-watch-mode t) +(use-package undo-tree + :delight + :config + (global-undo-tree-mode) + (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/backups/undo-tree")))) (use-package beacon - :config (beacon-mode 1) - :bind ("C-*" . beacon-blink) + :delight + :config (beacon-mode t) :custom (beacon-blink-when-focused 1) (beacon-color "#f6aa11")) +(global-set-key [remap crux-smart-open-line] 'ace-window) +(use-package ace-window + :bind ("C-M-o" . ace-swap-window)) + (use-package projectile + :delight :bind ([remap overwrite-mode] . projectile-commander) :custom (projectile-indexing-method 'hybrid)) -(use-package projectile-ripgrep) - (use-package helm-swoop + :delight :bind ("M-s" . helm-swoop) ("M-S" . helm-multi-swoop-projectile) ("M-l" . helm-swoop-back-to-last-point)) -;; (use-package helm-gtags -;; :hook (prog-mode helm-gtags-mode)) +(use-package helm + :delight) -(use-package treemacs - :bind - ("" . treemacs)) - -(use-package goto-last-change) -(global-set-key "\C-x\C-\\" 'goto-last-change) - -(use-package multiple-cursors) -(global-set-key (kbd "C-c m c") 'mc/edit-lines) -(global-set-key (kbd "M-") 'mc/add-cursor-on-click) - -;; https://ebzzry.com/en/emacs-pairs/ -;; (bind-keys -;; :map smartparens-mode-map -;; ("C-M-a" . sp-beginning-of-sexp) -;; ("C-M-e" . sp-end-of-sexp) - -;; ("C-" . sp-down-sexp) -;; ("C-" . sp-up-sexp) -;; ("M-" . sp-backward-down-sexp) -;; ("M-" . sp-backward-up-sexp) - -;; ("C-M-f" . sp-forward-sexp) -;; ("C-M-b" . sp-backward-sexp) - -;; ("C-M-n" . sp-next-sexp) -;; ("C-M-p" . sp-previous-sexp) - -;; ("C-S-f" . sp-forward-symbol) -;; ("C-S-b" . sp-backward-symbol) - -;; ("C-" . sp-forward-slurp-sexp) -;; ("M-" . sp-forward-barf-sexp) -;; ("C-" . sp-backward-slurp-sexp) -;; ("M-" . sp-backward-barf-sexp) - -;; ("C-M-t" . sp-transpose-sexp) -;; ("C-M-k" . sp-kill-sexp) -;; ("C-k" . sp-kill-hybrid-sexp) -;; ("M-k" . sp-backward-kill-sexp) -;; ("C-M-w" . sp-copy-sexp) -;; ("C-M-d" . delete-sexp) - -;; ("M-" . backward-kill-word) -;; ("C-" . sp-backward-kill-word) -;; ([remap sp-backward-kill-word] . backward-kill-word) - -;; ("M-[" . sp-backward-unwrap-sexp) -;; ("M-]" . sp-unwrap-sexp) - -;; ("C-x C-t" . sp-transpose-hybrid-sexp) - -;; ("C-c (" . wrap-with-parens) -;; ("C-c [" . wrap-with-brackets) -;; ("C-c {" . wrap-with-braces) -;; ("C-c '" . wrap-with-single-quotes) -;; ("C-c \"" . wrap-with-double-quotes) -;; ("C-c _" . wrap-with-underscores) -;; ("C-c `" . wrap-with-back-quotes)) +(use-package move-text + :config (move-text-default-bindings)) + +(use-package iedit + :bind* + ("C-c e" . iedit-mode) + (:map iedit-mode-keymap + ("M-h" . 'iedit-show/hide-context-lines)) + (:map iedit-mode-occurrence-keymap + ("M-F" . 'iedit-restrict-function))) + +(use-package expand-region + :bind ("M-=" . er/expand-region)) + +(use-package paren + ;; "Highlighting for parens" + :custom + (show-paren-delay 0.3) + (blink-matching-paren t) + (blink-matching-paren-on-screen t) + (show-paren-style 'expression) + (blink-matching-paren-dont-ignore-comments t) + :config (show-paren-mode)) diff --git a/personal/9_c_config.el b/personal/9_c_config.el index 51fe62c..446ef93 100644 --- a/personal/9_c_config.el +++ b/personal/9_c_config.el @@ -1,18 +1,19 @@ -(setq read-process-output-max (* 1024 1024)) ;; 1mb +;; sample `helm' configuration use https://github.com/emacs-helm/helm/ for details +(use-package helm-xref) -(use-package lsp-mode - :ensure t - :defer t - :hook (lsp-mode . (lambda () - (let ((lsp-keymap-prefix "C-c l")) - (lsp-enable-which-key-integration)))) - :init - (setq lsp-keep-workspace-alive nil - lsp-signature-doc-lines 5 - lsp-idle-delay 0.5 - lsp-prefer-capf t - lsp-client-packages nil) - :config - (define-key lsp-mode-map (kbd "C-c l") lsp-command-map)) -;; if you want to change prefix for lsp-mode keybindings. +(helm-descbinds-mode -1) +(which-key-mode) (add-hook 'c-mode-hook 'lsp) +(add-hook 'c++-mode-hook 'lsp) +(use-package yasnippet + :config (yas-global-mode t)) + +(setq gc-cons-threshold (* 100 1024 1024) + read-process-output-max (* 1024 1024) + treemacs-space-between-root-nodes nil + company-idle-delay 0.0 + company-minimum-prefix-length 1 + lsp-idle-delay 0.1) ;; clangd is fast + +(use-package lsp-mode + :bind-keymap ("C-c l" . lsp-command-map)) diff --git a/personal/9_ocaml_config.el b/personal/9_ocaml_config.el index 00e075d..ffb7d08 100644 --- a/personal/9_ocaml_config.el +++ b/personal/9_ocaml_config.el @@ -1,15 +1,9 @@ (prelude-require-packages '(utop - opam-switch-mode ocp-indent ocamlformat dune dune-format merlin merlin-company merlin-eldoc merlin-iedit)) -;; (use-package ocp-index -;; :config (unbind-key "C-c C-t" ocp-index-keymap) -;; :bind (:map ocp-index-keymap -;; ("C-c t" . ocp-index-print-info-at-point))) - (use-package merlin :bind (:map merlin-mode-map ("C-c m d" . merlin-document) @@ -17,15 +11,26 @@ ("M-," . merlin-pop-stack)) :config (setq merlin-error-after-save t) :custom - (merlin-error-after-save t) (merlin-completion-with-doc t) (merlin-locate-preference 1) (merlin-type-after-locate 1)) +(use-package merlin-eldoc + :after merlin + :ensure t + :custom + (eldoc-echo-area-use-multiline-p t) ; use multiple lines when necessary + (merlin-eldoc-max-lines 8) ; but not more than 8 + (merlin-eldoc-type-verbosity 'min) ; don't display verbose types + (merlin-eldoc-function-arguments nil) ; don't show function arguments + (merlin-eldoc-doc nil) ; don't show the documentation + :bind (:map merlin-mode-map + ("C-c m p" . merlin-eldoc-jump-to-prev-occurrence) + ("C-c m n" . merlin-eldoc-jump-to-next-occurrence)) + :hook ((tuareg-mode reason-mode) . merlin-eldoc-setup)) + (use-package ocamlformat :bind ("" . ocamlformat)) (use-package dune-format :hook (dune-mode . dune-format-on-save-mode)) - -(use-package dune-watch)