From 63c0eee5367a548dfbfb29cb75275dd7c8595a2f Mon Sep 17 00:00:00 2001 From: Taryel Hlontsi Date: Sat, 17 Jun 2023 14:25:11 +0200 Subject: [PATCH] Initial commit --- init.el | 279 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 init.el diff --git a/init.el b/init.el new file mode 100644 index 0000000..998858d --- /dev/null +++ b/init.el @@ -0,0 +1,279 @@ +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(package-initialize) + +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(use-package which-key + :ensure t + :config (which-key-mode)) + +(set-face-attribute 'default nil :font "JetBrains Mono" :height 130) + +(set-default-coding-systems 'utf-8) + +(setq ring-bell-function 'ignore) + +(setq inhibit-startup-message t) + +(setq backup-directory-alist '(("." . "~/.saves"))) + +(setq auto-save-default nil) + +(setq-default indent-tabs-mode nil) + +;;(setq ido-everywhere t) + +;;(setq ido-enable-flex-matching t) + +(ido-mode) + +(setq show-paren-delay 0) + +(delete-selection-mode 1) + +(show-paren-mode 1) + +(require 'paren) +(set-face-background 'show-paren-match (face-background 'default)) +(set-face-foreground 'show-paren-match "#def") +(set-face-attribute 'show-paren-match nil :weight 'extra-bold) + +(add-hook 'before-save-hook 'whitespace-cleanup) + +(use-package elpy + :ensure t) + +(use-package flycheck + :ensure t) + +(use-package exec-path-from-shell + :ensure t) + +(elpy-enable) + +(exec-path-from-shell-copy-env "PATH") + +(when (require 'flycheck nil t) + (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) + (add-hook 'elpy-mode-hook 'flycheck-mode)) + +(add-hook 'elpy-mode-hook (lambda () + (add-hook 'before-save-hook + 'elpy-format-code nil t))) +(add-hook 'python-mode-hook + (lambda () (setq gud-pdb-command-name "python3 -m pdb"))) + +(use-package pyenv-mode + :ensure t) + +(pyenv-mode) + +;; setup dired +(put 'dired-find-alternate-file 'disabled nil) + +(add-hook 'dired-mode-hook + (lambda () + (define-key dired-mode-map (kbd "RET") + (lambda () (interactive) (find-alternate-file (dired-get-file-for-visit)))))) + +;; my keybindings + +(defun revert-buffer-no-confirm () + (interactive) + (revert-buffer :ignore-auto :noconfirm)) + +(defun list-buffers-please () + (interactive) + (list-buffers) + (other-window 1) + (delete-other-windows)) + +(defun make-json-great-again () + (interactive) + (when (string-match-p ".json\\'" (buffer-name)) + (mark-whole-buffer) + (json-pretty-print (region-beginning) (region-end)))) + +(global-unset-key (kbd "C-z")) +(global-unset-key (kbd "C-v")) +(global-unset-key (kbd "C-f")) +(global-unset-key (kbd "C-b")) +(global-unset-key (kbd "C-n")) +(global-unset-key (kbd "C-p")) +(global-unset-key (kbd "M-v")) + +(global-set-key (kbd "") 'list-buffers-please) +(global-set-key (kbd "") 'revert-buffer-no-confirm) + +(add-hook 'elpy-mode-hook + (lambda () (local-set-key [f2] 'elpy-refactor-rename))) + +(add-hook 'typescript-mode-hook + (lambda () (local-set-key [f2] 'tide-rename-symbol))) + +(add-hook 'typescript-mode-hook + (lambda () (local-set-key [f7] 'tide-references))) + +(add-hook 'hs-minor-mode-hook + (lambda () (local-set-key (kbd "C-") 'hs-toggle-hiding))) + +(add-hook 'mhtml-mode-hook + (lambda () (local-set-key (kbd "C-f") 'prettier-js))) + +(add-hook 'typescript-mode-hook + (lambda () (local-set-key (kbd "C-f") 'prettier-js))) + +(add-hook 'js-mode-hook + (lambda () (local-set-key (kbd "C-f") 'make-json-great-again))) + +;; (add-hook 'prog-mode-hook +;; (lambda () (local-set-key (kbd "C-;") 'comment-or-uncomment-region))) + +;; stuff for folding html +(defun mhtml-forward (arg) + (interactive "P") + (pcase (get-text-property (point) 'mhtml-submode) + ('nil (sgml-skip-tag-forward 1)) + (submode (forward-sexp)))) + +(add-to-list 'hs-special-modes-alist + '(mhtml-mode + "{\\|<[^/>]+?" + "}\\|]*[^/]>" + "