Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
5fc5e30044 |
|
@ -3,5 +3,3 @@
|
|||
!/.gitignore
|
||||
!/init.el
|
||||
!/snippets
|
||||
!/tree-sitter
|
||||
!/profile-dotemacs.el
|
461
init.el
461
init.el
|
@ -1,139 +1,17 @@
|
|||
(setq gc-cons-threshold (* 100 1000 1000))
|
||||
(add-hook 'after-init-hook #'(lambda ()
|
||||
;; restore after startup
|
||||
(setq gc-cons-threshold 800000)))
|
||||
|
||||
(defun my/copy-buffer-file-path ()
|
||||
"Copy the current buffer's file path to kill ring.
|
||||
For regular files, copies the full path.
|
||||
For Dired buffers, copies the directory path.
|
||||
Shows a message if no path is available."
|
||||
(interactive)
|
||||
(let ((path (cond
|
||||
(buffer-file-truename
|
||||
buffer-file-truename)
|
||||
(dired-directory
|
||||
dired-directory)
|
||||
(t nil))))
|
||||
(if path
|
||||
(progn
|
||||
(kill-new path)
|
||||
(message "Copied: %s" path))
|
||||
(message "No file path available"))))
|
||||
|
||||
(defun my/dired-open-current-file-directory ()
|
||||
"Open the current file's directory in Dired, if possible."
|
||||
(interactive)
|
||||
(if (buffer-file-name)
|
||||
(dired-jump)
|
||||
(call-interactively 'dired)))
|
||||
|
||||
(defun my/duplicate-line-or-region (arg)
|
||||
(interactive "p")
|
||||
(let (beg end (origin (point)))
|
||||
(if (and mark-active (> (point) (mark)))
|
||||
(exchange-point-and-mark))
|
||||
(setq beg (line-beginning-position))
|
||||
(if mark-active
|
||||
(exchange-point-and-mark))
|
||||
(setq end (line-end-position))
|
||||
(let ((region (buffer-substring-no-properties beg end)))
|
||||
(dotimes (i arg)
|
||||
(goto-char end)
|
||||
(newline)
|
||||
(insert region)
|
||||
(setq end (point)))
|
||||
(goto-char (+ origin (* (length region) arg) arg)))))
|
||||
|
||||
(defun my/mhtml-forward (arg)
|
||||
(interactive "P")
|
||||
(pcase (get-text-property (point) 'mhtml-submode)
|
||||
('nil (sgml-skip-tag-forward 1))
|
||||
(submode (forward-sexp))))
|
||||
|
||||
(defun my/create-new-file ()
|
||||
"Create a new file with prompt for filename using :>."
|
||||
(interactive)
|
||||
(let ((filename (read-string "Filename: ")))
|
||||
(shell-command (concat ":> " filename))
|
||||
(find-file filename)))
|
||||
|
||||
(custom-set-variables
|
||||
;; custom-set-variables was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
'(custom-safe-themes
|
||||
'("b99e334a4019a2caa71e1d6445fc346c6f074a05fcbb989800ecbe54474ae1b0" default))
|
||||
'(initial-frame-alist '((fullscreen . maximized)))
|
||||
'(package-selected-packages
|
||||
'(vue-mode verb realgud json-mode orderless prettier-js magit docker-compose-mode zig-mode treesit ef-themes dockerfile-mode dap-mode julia-ts-mode lsp-julia julia-mode marginalia vertico tide which-key use-package pyenv-mode flycheck exec-path-from-shell elpy doom-themes doom-modeline all-the-icons)))
|
||||
|
||||
(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))
|
||||
|
||||
(use-package vertico
|
||||
:ensure t
|
||||
:config
|
||||
(add-hook 'rfn-eshadow-update-overlay-hook 'vertico-directory-tidy))
|
||||
|
||||
(use-package marginalia
|
||||
:ensure t)
|
||||
|
||||
(require 'treesit)
|
||||
|
||||
(use-package docker-compose-mode
|
||||
:ensure t)
|
||||
|
||||
(use-package zig-mode
|
||||
:ensure t)
|
||||
|
||||
(use-package dockerfile-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:mode ("Dockerfile\\'" "\\.dockerfile\\'")
|
||||
:commands dockerfile-mode)
|
||||
|
||||
(use-package flycheck
|
||||
:ensure t
|
||||
:defer t
|
||||
:hook (prog-mode . flycheck-mode))
|
||||
|
||||
(use-package dired
|
||||
:config
|
||||
(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))))))
|
||||
(setq delete-by-moving-to-trash t)
|
||||
(setq dired-dwim-target t))
|
||||
|
||||
(vertico-mode 1)
|
||||
|
||||
(marginalia-mode 1)
|
||||
|
||||
(tool-bar-mode -1)
|
||||
|
||||
(scroll-bar-mode -1)
|
||||
|
||||
;;"M+1Code Nerd Font"
|
||||
;;"Lekton Nerd Font"
|
||||
;; Agave Nerd Font
|
||||
;; EnvyCodeR Nerd Font
|
||||
;; Binchotan_Sharp
|
||||
;; Ubuntu Mono
|
||||
(set-face-attribute 'default nil :font "Binchotan_Sharp" :height 140)
|
||||
|
||||
;;(set-fontset-font t nil (font-spec :size 20 :name "VictorMono Nerd Font Mono"))
|
||||
;;(set-face-attribute 'default nil :font "VictorMono Nerd Font Mono" :height 110)
|
||||
|
||||
;;(setq x-antialiasing-factor nil)
|
||||
;; (set-face-attribute 'default nil :font "JetBrains Mono" :height 130)
|
||||
(set-face-attribute 'default nil :font "VictorMono Nerd Font Mono" :height 110)
|
||||
|
||||
(set-default-coding-systems 'utf-8)
|
||||
|
||||
|
@ -147,92 +25,68 @@ Shows a message if no path is available."
|
|||
|
||||
(setq-default indent-tabs-mode nil)
|
||||
|
||||
(setq show-paren-delay 0)
|
||||
(tool-bar-mode -1)
|
||||
|
||||
(setq native-comp-async-report-warnings-errors 'silent)
|
||||
;;(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)
|
||||
|
||||
(setq-default frame-title-format
|
||||
'(:eval
|
||||
(format "%s"
|
||||
(cond
|
||||
(buffer-file-truename buffer-file-truename )
|
||||
(dired-directory (concat "[ " dired-directory " ]"))
|
||||
(t "GNU Emacs 👾")))))
|
||||
|
||||
(use-package elpy
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (elpy-enable)
|
||||
:hook (python-mode . elpy-enable)
|
||||
:config
|
||||
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules)))
|
||||
:ensure t)
|
||||
|
||||
;; (setq elpy-rpc-virtualenv-path 'current)
|
||||
(use-package flycheck
|
||||
:ensure t)
|
||||
|
||||
(use-package exec-path-from-shell
|
||||
:ensure t
|
||||
:config
|
||||
(when (memq window-system '(mac ns x))
|
||||
(exec-path-from-shell-initialize)))
|
||||
: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)
|
||||
|
||||
(use-package yasnippet
|
||||
:hook (prog-mode . yas-minor-mode)
|
||||
:config
|
||||
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
|
||||
(yas-reload-all))
|
||||
(yas-reload-all)
|
||||
(add-hook 'prog-mode-hook 'yas-minor-mode))
|
||||
|
||||
;; setup dired
|
||||
(put 'dired-find-alternate-file 'disabled nil)
|
||||
|
||||
(use-package meson-mode
|
||||
:ensure t)
|
||||
|
||||
(use-package vala-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:mode (("\\.vala\\'" . vala-mode)
|
||||
("\\.vapi\\'" . vala-mode))
|
||||
:config
|
||||
(add-to-list 'file-coding-system-alist '("\\.vala\\'" . utf-8))
|
||||
(add-to-list 'file-coding-system-alist '("\\.vapi\\'" . utf-8)))
|
||||
|
||||
(use-package lsp-dart
|
||||
:ensure t
|
||||
:defer t
|
||||
:after lsp-mode)
|
||||
|
||||
(use-package dart-mode
|
||||
:ensure t
|
||||
:defer t)
|
||||
|
||||
(use-package verb
|
||||
:ensure t
|
||||
:defer t)
|
||||
|
||||
(use-package org
|
||||
:mode ("\\.org\\'" . org-mode)
|
||||
:config (define-key org-mode-map (kbd "C-c C-r") verb-command-map))
|
||||
|
||||
(use-package org-superstar
|
||||
:ensure t
|
||||
:defer t
|
||||
:hook (org-mode . org-superstar-mode))
|
||||
|
||||
(defface my-org-face
|
||||
'((t :family "Liberation Sans" :height 120))
|
||||
"Face for Org mode.")
|
||||
|
||||
(defun my-org-font-setup ()
|
||||
(face-remap-add-relative 'default 'my-org-face))
|
||||
|
||||
(add-hook 'org-mode-hook 'my-org-font-setup)
|
||||
(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
|
||||
|
||||
|
@ -240,10 +94,6 @@ Shows a message if no path is available."
|
|||
(interactive)
|
||||
(revert-buffer :ignore-auto :noconfirm))
|
||||
|
||||
(defun kill-buffer-no-confirm ()
|
||||
(interactive)
|
||||
(kill-buffer nil))
|
||||
|
||||
(defun list-buffers-please ()
|
||||
(interactive)
|
||||
(list-buffers)
|
||||
|
@ -256,31 +106,20 @@ Shows a message if no path is available."
|
|||
(mark-whole-buffer)
|
||||
(json-pretty-print (region-beginning) (region-end))))
|
||||
|
||||
(global-unset-key (kbd "C-d"))
|
||||
(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-l"))
|
||||
(global-unset-key (kbd "C-p"))
|
||||
(global-unset-key (kbd "M-v"))
|
||||
|
||||
(global-set-key (kbd "<f1>") 'find-file)
|
||||
(global-set-key (kbd "<f1>") 'list-buffers-please)
|
||||
(global-set-key (kbd "<f5>") 'revert-buffer-no-confirm)
|
||||
(global-set-key (kbd "<f12>") 'kill-buffer-no-confirm)
|
||||
(global-set-key (kbd "C-b") 'list-buffers-please)
|
||||
(global-set-key (kbd "C-n") 'my/create-new-file)
|
||||
(global-set-key (kbd "C-d") 'my/duplicate-line-or-region)
|
||||
(global-set-key (kbd "C-x d") 'my/dired-open-current-file-directory)
|
||||
(global-set-key (kbd "C-p") 'my/copy-buffer-file-path)
|
||||
|
||||
(add-hook 'elpy-mode-hook
|
||||
(lambda () (local-set-key [f2] 'elpy-refactor-rename)))
|
||||
|
||||
(add-hook 'elpy-mode-hook
|
||||
(lambda () (local-set-key [f7] 'elpy-goto-definition)))
|
||||
|
||||
(add-hook 'typescript-mode-hook
|
||||
(lambda () (local-set-key [f2] 'tide-rename-symbol)))
|
||||
|
||||
|
@ -293,60 +132,70 @@ Shows a message if no path is available."
|
|||
(add-hook 'mhtml-mode-hook
|
||||
(lambda () (local-set-key (kbd "C-f") 'prettier-js)))
|
||||
|
||||
(add-hook 'typescript-ts-mode-hook
|
||||
(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 'lsp-mode-hook
|
||||
(lambda () (local-set-key (kbd "C-f") 'lsp-format-buffer)))
|
||||
|
||||
(add-hook 'elpy-mode-hook
|
||||
(lambda () (local-set-key (kbd "C-f") 'elpy-black-fix-code))) ;elpy-format-code
|
||||
|
||||
;; (add-hook 'prog-mode-hook
|
||||
;; (lambda () (local-set-key (kbd "C-;") 'comment-or-uncomment-region)))
|
||||
|
||||
;; (define-key map (kbd "M-.") 'elpy-goto-assignment
|
||||
;; (define-key map (kbd "C-x 4 M-.") 'elpy-goto-assignment-other-window)
|
||||
|
||||
;; 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
|
||||
"{\\|<[^/>]+?"
|
||||
"}\\|</[^/>]*[^/]>"
|
||||
"<!--"
|
||||
my/mhtml-forward
|
||||
mhtml-forward
|
||||
nil))
|
||||
|
||||
(add-hook 'prog-mode-hook 'hs-minor-mode)
|
||||
|
||||
;; theming starts here:
|
||||
(require 'display-line-numbers)
|
||||
|
||||
(defcustom display-line-numbers-exempt-modes
|
||||
'(gud-mode inferior-python-mode dired-mode vterm-mode eshell-mode shell-mode term-mode ansi-tern-mode)
|
||||
"Major modes on which to disable line numbers"
|
||||
:group 'display-line-numbers
|
||||
:type 'list
|
||||
:version "green")
|
||||
|
||||
(defun display-line-numbers--turn-on ()
|
||||
"Turn on line numbers except for certain modes.
|
||||
Exempt major modes are defined in `display-line-numbers-exempt-modes'."
|
||||
(unless (or (minibufferp)
|
||||
(member major-mode display-line-numbers-exempt-modes))
|
||||
(display-line-numbers-mode)))
|
||||
|
||||
(global-display-line-numbers-mode)
|
||||
|
||||
(use-package magit
|
||||
:ensure t)
|
||||
|
||||
(use-package doom-modeline
|
||||
:ensure t
|
||||
:hook (after-init . doom-modeline-mode))
|
||||
|
||||
;; (use-package doom-themes
|
||||
;; :ensure t
|
||||
;; :config
|
||||
;; (load-theme 'doom-monokai-pro))
|
||||
|
||||
(use-package gruber-darker-theme
|
||||
;; M-x nerd-icons-install-fonts
|
||||
(use-package nerd-icons
|
||||
:ensure t)
|
||||
|
||||
(use-package modus-themes
|
||||
(use-package prettier-js
|
||||
:ensure t)
|
||||
|
||||
;; (modus-themes-select 'modus-operandi-tinted)
|
||||
(setq modus-themes-to-toggle '(modus-operandi-tinted modus-vivendi-tinted))
|
||||
;; theming starts here:
|
||||
|
||||
(use-package ef-themes
|
||||
:ensure t)
|
||||
:ensure t)
|
||||
|
||||
(setq ef-themes-to-toggle '(ef-elea-light ef-elea-dark))
|
||||
(setq ef-themes-to-toggle '(ef-day ef-autumn))
|
||||
|
||||
(setq ef-themes-headings ; read the manual's entry or the doc string
|
||||
'((0 . (variable-pitch light 1.9))
|
||||
|
@ -362,34 +211,12 @@ Shows a message if no path is available."
|
|||
(setq ef-themes-mixed-fonts t
|
||||
ef-themes-variable-pitch-ui t)
|
||||
|
||||
(defun my-setup-display-based-on-type ()
|
||||
"Load different themes and disable menu bar for console mode."
|
||||
(if (display-graphic-p)
|
||||
(progn
|
||||
(ef-themes-select 'ef-elea-light)
|
||||
(menu-bar-mode 1))
|
||||
(progn
|
||||
(load-theme 'gruber-darker t)
|
||||
(menu-bar-mode -1))))
|
||||
(mapc #'disable-theme custom-enabled-themes)
|
||||
|
||||
(add-hook 'after-init-hook 'my-setup-display-based-on-type)
|
||||
;; (ef-themes-select 'ef-autumn)
|
||||
(load-theme 'modus-operandi-tinted t)
|
||||
|
||||
;; theming stops here
|
||||
|
||||
(use-package magit
|
||||
:ensure t
|
||||
:defer t
|
||||
:bind (("C-x g" . magit-status))
|
||||
:commands (magit-status magit-dispatch magit-file-dispatch)
|
||||
:config
|
||||
(setq magit-auto-revert-mode nil))
|
||||
|
||||
;; M-x nerd-icons-install-fonts
|
||||
(use-package nerd-icons
|
||||
:ensure t)
|
||||
|
||||
(use-package prettier-js
|
||||
:ensure t)
|
||||
;;________________________________________________________
|
||||
|
||||
(use-package orderless
|
||||
:ensure t
|
||||
|
@ -397,106 +224,46 @@ ef-themes-variable-pitch-ui t)
|
|||
(completion-styles '(orderless basic))
|
||||
(completion-category-overrides '((file (styles basic partial-completion)))))
|
||||
|
||||
(use-package json-mode
|
||||
:ensure t
|
||||
:mode "\\.json\\'"
|
||||
:defer t
|
||||
:commands json-mode)
|
||||
|
||||
(use-package lsp-mode
|
||||
:ensure t)
|
||||
|
||||
(use-package dap-mode
|
||||
:ensure t
|
||||
;;:custom (lsp-enable-dap-auto-configure nil)
|
||||
:commands dap-debug)
|
||||
|
||||
(use-package vue-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:mode "\\.vue\\'"
|
||||
:hook (vue-mode . lsp-deferred))
|
||||
(use-package json-mode :ensure t)
|
||||
|
||||
;; __________________________________________________
|
||||
;; typescript setup starts here
|
||||
|
||||
|
||||
;; typescript setup starts here (TO REVIEW!)
|
||||
(defun setup-tide-mode ()
|
||||
(interactive)
|
||||
(tide-setup)
|
||||
(flycheck-mode +1)
|
||||
(setq flycheck-check-syntax-automatically '(save mode-enabled))
|
||||
(eldoc-mode +1)
|
||||
(tide-hl-identifier-mode +1))
|
||||
(tide-hl-identifier-mode +1)
|
||||
;; company is an optional dependency. You have to
|
||||
;; install it separately via package-install
|
||||
;; `M-x package-install [ret] company`
|
||||
;; (company-mode +1)
|
||||
)
|
||||
|
||||
;; aligns annotation to the right hand side
|
||||
;; (setq company-tooltip-align-annotations t)
|
||||
|
||||
;; formats the buffer before saving
|
||||
;; (add-hook 'before-save-hook 'tide-format-before-save)
|
||||
|
||||
(add-hook 'typescript-mode-hook #'setup-tide-mode)
|
||||
|
||||
(use-package tide
|
||||
:ensure t
|
||||
:after (flycheck)
|
||||
:hook ((typescript-ts-mode . setup-tide-mode)
|
||||
(tsx-ts-mode . setup-tide-mode)
|
||||
(typescript-ts-mode . tide-hl-identifier-mode)
|
||||
(before-save . tide-format-before-save))
|
||||
:config
|
||||
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode)))
|
||||
|
||||
;;----------------------------------------
|
||||
;; dotnet starts here
|
||||
|
||||
(use-package dap-netcore
|
||||
:after dap-mode
|
||||
:defer t
|
||||
:commands (dap-netcore-setup)
|
||||
:init
|
||||
(add-hook 'csharp-mode-hook
|
||||
(lambda ()
|
||||
(require 'dap-netcore)
|
||||
(dap-netcore-setup))))
|
||||
|
||||
|
||||
;;(setq dap-auto-configure-features '(sessions locals controls tooltip))
|
||||
|
||||
(defun setup-lsp-keys ()
|
||||
(interactive)
|
||||
(local-set-key [f7] 'lsp-find-implementation)
|
||||
(local-set-key [f2] 'lsp-rename))
|
||||
|
||||
(add-hook 'lsp-mode-hook
|
||||
(lambda () (setup-lsp-keys)))
|
||||
|
||||
(defun setup-dotnet ()
|
||||
(interactive)
|
||||
(exec-path-from-shell-copy-env "DOTNET_ROOT")
|
||||
(lsp-deferred))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.csproj\\'" . xml-mode))
|
||||
|
||||
(add-hook 'csharp-mode-hook
|
||||
(lambda () (setup-dotnet)))
|
||||
|
||||
(defun find-project-root ()
|
||||
(interactive)
|
||||
(if (ignore-errors (eproject-root))
|
||||
(eproject-root)
|
||||
(or (find-git-repo (buffer-file-name)) (file-name-directory (buffer-file-name)))))
|
||||
|
||||
(defun find-git-repo (dir)
|
||||
(if (string= "/" dir)
|
||||
nil
|
||||
(if (file-exists-p (expand-file-name "../.git/" dir))
|
||||
dir
|
||||
(find-git-repo (expand-file-name "../" dir)))))
|
||||
|
||||
|
||||
(defun file-path-to-namespace ()
|
||||
(interactive)
|
||||
(let (
|
||||
(root (find-project-root))
|
||||
(base (file-name-nondirectory buffer-file-name))
|
||||
)
|
||||
(substring (replace-regexp-in-string "/" "\." (substring buffer-file-name (length root) (* -1 (length base))) t t) 0 -1)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
:after (typescript-mode company flycheck)
|
||||
:hook ((typescript-mode . tide-setup)
|
||||
(typescript-mode . tide-hl-identifier-mode)
|
||||
(before-save . tide-format-before-save)))
|
||||
(custom-set-variables
|
||||
;; custom-set-variables was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
'(package-selected-packages
|
||||
'(ef-themes tide which-key use-package pyenv-mode flycheck exec-path-from-shell elpy doom-themes doom-modeline all-the-icons)))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
|
|
|
@ -1,200 +0,0 @@
|
|||
;;; profile-dotemacs.el --- Profile your Emacs init file
|
||||
|
||||
;; Copyright (C) 2010, 2012 David Engster
|
||||
|
||||
;; Author: David Engster <dengste@eml.cc>
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License
|
||||
;; as published by the Free Software Foundation; either version 2
|
||||
;; of the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This is to easily profile your Emacs init file (or any other
|
||||
;; script-like Emacs Lisp file, for that matter).
|
||||
|
||||
;; It will go over all sexp's (balanced expressions) in the file and
|
||||
;; run them through `benchmark-run'. It will then show the file with
|
||||
;; overlays applied in a way that let you easily find out which sexp's
|
||||
;; take the most time. Since time is relative, it's not the absolute
|
||||
;; value that counts but the percentage of the total running time.
|
||||
;;
|
||||
;; * All other sexp's with a percentage greater than
|
||||
;; `profile-dotemacs-low-percentage' will be preceded by a
|
||||
;; highlighted line, showing the results from `benchmark-run'.
|
||||
;; Also, the more 'reddish' the background of the sexp, the more
|
||||
;; time it needs.
|
||||
|
||||
;; * All other sexp's will be grayed out to indicate that their
|
||||
;; running time is miniscule. You can still see the benchmark
|
||||
;; results in the minibuffer by hovering over the sexp with the
|
||||
;; mouse.
|
||||
|
||||
;; You can only benchmark full sexp's, so if you wrapped large parts
|
||||
;; of your init file in some conditional clause, you'll have to remove
|
||||
;; that for getting finer granularity.
|
||||
|
||||
;;; Usage:
|
||||
|
||||
;; Start emacs as follows:
|
||||
;;
|
||||
;; emacs -Q -l <PATH>/profile-dotemacs.el -f profile-dotemacs
|
||||
;;
|
||||
;; with <PATH> being the path to where this file resides.
|
||||
|
||||
;;; Caveats (thanks to Raffaele Ricciardi for reporting those):
|
||||
|
||||
;; - The usual `--debug-init' for debugging your init file won't work
|
||||
;; with profile-dotemacs, so you'll have to call
|
||||
;; `toggle-debug-on-error', either on the commandline or at the
|
||||
;; beginning of your init file.
|
||||
;; - `load-file-name' is nil when the init file is being loaded
|
||||
;; by the profiler. This might matter if you perform the
|
||||
;; bulk of initializations in a different file.
|
||||
;; - Starting external shells like IELM or eshell in your init file
|
||||
;; might mess with overlay creation, so this must not be done.
|
||||
|
||||
;;; Download:
|
||||
|
||||
;; You can always get the latest version from
|
||||
;; http://randomsample.de/profile-dotemacs.el
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'thingatpt)
|
||||
(require 'benchmark)
|
||||
|
||||
;; User variables
|
||||
|
||||
(defvar profile-dotemacs-file "~/.emacs.d/init.el"
|
||||
"File to be profiled.")
|
||||
|
||||
(defvar profile-dotemacs-low-percentage 3
|
||||
"Percentage which should be considered low.
|
||||
All sexp's with a running time below this percentage will be
|
||||
grayed out.")
|
||||
|
||||
(defface profile-dotemacs-time-face
|
||||
'((((background dark)) (:background "OrangeRed1"))
|
||||
(t (:background "red3")))
|
||||
"Background color to indicate percentage of total time.")
|
||||
|
||||
(defface profile-dotemacs-low-percentage-face
|
||||
'((((background dark)) (:foreground "gray25"))
|
||||
(t (:foreground "gray75")))
|
||||
"Face for sexps below `profile-dotemacs-low-percentage'.")
|
||||
|
||||
(defface profile-dotemacs-highlight-face
|
||||
'((((background dark)) (:background "blue"))
|
||||
(t (:background "yellow")))
|
||||
"Highlight face for benchmark results.")
|
||||
|
||||
;; Main function
|
||||
|
||||
(defun profile-dotemacs ()
|
||||
"Load `profile-dotemacs-file' and benchmark its sexps."
|
||||
(interactive)
|
||||
(with-current-buffer (find-file-noselect profile-dotemacs-file t)
|
||||
(setq buffer-read-only t) ;; just to be sure
|
||||
(goto-char (point-min))
|
||||
(let (start end results)
|
||||
(while
|
||||
(< (point)
|
||||
(setq end (progn
|
||||
(forward-sexp 1)
|
||||
(point))))
|
||||
(forward-sexp -1)
|
||||
(setq start (point))
|
||||
(add-to-list
|
||||
'results
|
||||
`(,start ,end
|
||||
,(benchmark-run
|
||||
(eval (sexp-at-point)))))
|
||||
(goto-char end))
|
||||
(profile-dotemacs-show-results results)
|
||||
(switch-to-buffer (current-buffer)))))
|
||||
|
||||
;; Helper functions
|
||||
|
||||
(defun profile-dotemacs-show-results (results)
|
||||
"Show timings from RESULTS in current buffer."
|
||||
(let ((totaltime (profile-dotemacs-totaltime results))
|
||||
current percentage ov)
|
||||
(while results
|
||||
(let* ((current (pop results))
|
||||
(ov (make-overlay (car current) (cadr current)))
|
||||
(current (car (last current)))
|
||||
(percentage (/ (+ (car current) (nth 2 current))
|
||||
totaltime))
|
||||
col benchstr lowface)
|
||||
(setq col
|
||||
(profile-dotemacs-percentage-color
|
||||
percentage
|
||||
(face-background 'default)
|
||||
(face-background 'profile-dotemacs-time-face)))
|
||||
(setq percentage (round (* 100 percentage)))
|
||||
(setq benchstr (profile-dotemacs-make-benchstr current))
|
||||
(overlay-put ov 'help-echo benchstr)
|
||||
(if (and (numberp profile-dotemacs-low-percentage)
|
||||
(< percentage profile-dotemacs-low-percentage))
|
||||
(overlay-put ov 'face 'profile-dotemacs-low-percentage-face)
|
||||
(overlay-put ov 'before-string
|
||||
(propertize benchstr
|
||||
'face 'profile-dotemacs-highlight-face))
|
||||
(overlay-put ov 'face
|
||||
`(:background ,col)))))
|
||||
(setq ov (make-overlay (1- (point-max)) (point-max)))
|
||||
(overlay-put ov 'after-string
|
||||
(propertize
|
||||
(format "\n-----------------\nTotal time: %.2fs\n"
|
||||
totaltime)
|
||||
'face 'profile-dotemacs-highlight-face))))
|
||||
|
||||
(defun profile-dotemacs-totaltime (results)
|
||||
"Calculate total time of RESULTS."
|
||||
(let ((totaltime 0))
|
||||
(mapc (lambda (x)
|
||||
(let ((cur (car (last x))))
|
||||
(setq totaltime (+ totaltime (car cur) (nth 2 cur)))))
|
||||
results)
|
||||
totaltime))
|
||||
|
||||
(defun profile-dotemacs-percentage-color (percent col-begin col-end)
|
||||
"Calculate color according to PERCENT between COL-BEGIN and COL-END."
|
||||
(let* ((col1 (color-values col-begin))
|
||||
(col2 (color-values col-end))
|
||||
(col
|
||||
(mapcar (lambda (c)
|
||||
(round
|
||||
(+ (* (- 1 percent) (nth c col1))
|
||||
(* percent (nth c col2)))))
|
||||
'(0 1 2))))
|
||||
(format "RGB:%04x/%04x/%04x"
|
||||
(car col)
|
||||
(nth 1 col)
|
||||
(nth 2 col))))
|
||||
|
||||
(defun profile-dotemacs-make-benchstr (timings)
|
||||
"Create descriptive benchmark string from TIMINGS."
|
||||
(format
|
||||
(concat
|
||||
"<Percentage: %d ; "
|
||||
"Time: %.2f ; "
|
||||
"Number of GC: %d ; "
|
||||
"Time for GC: %.2f>\n")
|
||||
percentage
|
||||
(car timings) (nth 1 timings) (nth 2 timings)))
|
||||
|
||||
|
||||
;; profile-dotemacs.el ends here
|
|
@ -1,14 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: class
|
||||
# key: cl
|
||||
# --
|
||||
namespace `(file-path-to-namespace)`;
|
||||
|
||||
public sealed class `(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`
|
||||
{
|
||||
$0
|
||||
|
||||
public `(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: ctor
|
||||
# key: ctor
|
||||
# --
|
||||
public `(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`()
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: foreach
|
||||
# key: f
|
||||
# --
|
||||
foreach (var ${1:Name} in ${2:Collection})
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: mpriv
|
||||
# key: mr
|
||||
# --
|
||||
private ${1:void} ${2:Method}($3)
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: mpub
|
||||
# key: mp
|
||||
# --
|
||||
public ${1:void} ${2:Method}($3)
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: mpubstatv
|
||||
# key: mpsv
|
||||
# --
|
||||
public static void ${1:Method}($2)
|
||||
{
|
||||
$0
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: print
|
||||
# key: p
|
||||
# --
|
||||
System.Console.WriteLine($"{$0}");
|
|
@ -1,5 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: prop
|
||||
# key: prop
|
||||
# --
|
||||
public ${1:string} ${2:PropertyName} { get; set; }
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: summary
|
||||
# key: ///
|
||||
# --
|
||||
/// <summary>
|
||||
/// $0
|
||||
/// </summary>
|
|
@ -1,12 +0,0 @@
|
|||
# -*- mode: csharp -*-
|
||||
# name: try
|
||||
# key: t
|
||||
# --
|
||||
try
|
||||
{
|
||||
$0
|
||||
}
|
||||
catch (${1:Exception} ${2:ex})
|
||||
{
|
||||
${3:System.Console.WriteLine(ex.Message);}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: first-only
|
||||
# key: fo
|
||||
# --
|
||||
$0 = next(filter(lambda x: x.__name__ == name, values), None)
|
|
@ -1,9 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: file-read
|
||||
# key: fr
|
||||
# --
|
||||
with open($0, 'r') as file:
|
||||
try:
|
||||
data = json.load(file)
|
||||
except (json.JSONDecodeError):
|
||||
data = {}
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: file-write
|
||||
# key: fw
|
||||
# --
|
||||
f_name = ${1:name}
|
||||
with open(f'~/Documents/$0/{f_name}.txt', 'w') as file:
|
||||
file.write(${2:content})
|
|
@ -1,10 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: json-dump
|
||||
# key: jd
|
||||
# --
|
||||
import uuid
|
||||
import json
|
||||
|
||||
f_name = str(uuid.uuid4())
|
||||
with open(f'~/Documents/$0/{f_name}.json', 'w') as file:
|
||||
file.write(json.dumps(${1:content}, indent=2))
|
|
@ -2,4 +2,4 @@
|
|||
# name: print
|
||||
# key: p
|
||||
# --
|
||||
print(f'$0')
|
||||
print(f'$0')
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: print-version
|
||||
# key: pi
|
||||
# --
|
||||
import sys
|
||||
|
||||
print(sys.version)
|
|
@ -1,13 +0,0 @@
|
|||
# -*- mode: python -*-
|
||||
# name: script
|
||||
# key: s
|
||||
# --
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
def main():
|
||||
pass$0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,16 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:add-section
|
||||
# key:adds
|
||||
# --
|
||||
#############################################################
|
||||
# 1 - STEP NAME
|
||||
#############################################################
|
||||
${3:my_func}() {
|
||||
local step_name='STEP ${1:1} ${2:STEP NAME}'
|
||||
warn "Press enter to proceed with $step_name"; read
|
||||
info "$step_name"
|
||||
|
||||
$0
|
||||
|
||||
info "done"
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:cat-heredoc
|
||||
# key:cat
|
||||
# --
|
||||
cat <<EOF | tee ${1:file-name.conf}
|
||||
$0
|
||||
EOF
|
|
@ -1,9 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:read
|
||||
# key:read
|
||||
# --
|
||||
read -p "Enter ${1:name}: " ${2:input}
|
||||
if [[ -z $$2 ]]; then
|
||||
echo "Error: $1 cannot be empty"
|
||||
exit 1
|
||||
fi
|
|
@ -1,9 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:root-check
|
||||
# key:root
|
||||
# --
|
||||
user=$(whoami)
|
||||
if [ $user == root ]; then
|
||||
error "You should NOT be using a root account"
|
||||
exit 1
|
||||
fi
|
|
@ -1,72 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:script
|
||||
# key:script
|
||||
# --
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#############################################################
|
||||
# Author: Taryel Hlontsi, 2025
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
#############################################################
|
||||
|
||||
doc=$(cat <<'EOF'
|
||||
NOTES:
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
#############################################################
|
||||
# SETUP SECTION
|
||||
#############################################################
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
#############################################################
|
||||
# HELPER FUNCTIONS
|
||||
#############################################################
|
||||
info() {
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
echo -e "\${GREEN}\${1}\${NC}"
|
||||
}
|
||||
|
||||
trace() {
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
echo -e "\${YELLOW}\${1}\${NC}"
|
||||
}
|
||||
|
||||
warn() {
|
||||
PURPLE='\033[1;35m'
|
||||
NC='\033[0m'
|
||||
echo -e "\${PURPLE}\${1}\${NC}"
|
||||
}
|
||||
|
||||
error() {
|
||||
RED='\033[1;31m'
|
||||
NC='\033[0m'
|
||||
echo -e "\${RED}\${1}\${NC}"
|
||||
}
|
||||
|
||||
$0
|
||||
|
||||
#############################################################
|
||||
# RUN SECTION
|
||||
#############################################################
|
||||
echo $(date +'%Y-%m-%d %H:%M')
|
||||
info "$doc"
|
||||
|
||||
info "Bye!"
|
||||
|
||||
exit 0
|
|
@ -1,8 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:sourced-check
|
||||
# key:sourced
|
||||
# --
|
||||
if [ \$0 == $BASH_SOURCE ]; then
|
||||
error "Do not run the script in a subshell via ./ Instead you should 'source' it!"
|
||||
exit 1
|
||||
fi
|
|
@ -1,23 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:systemd
|
||||
# key:systemd
|
||||
# --
|
||||
[Unit]
|
||||
Description=Description goes here
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Environment="VAR_NAME=value"
|
||||
EnvironmentFile=-/etc/environment
|
||||
ExecStart=/usr/bin/bash /home/myuser/myscript.sh${1}
|
||||
SyslogIdentifier=my.service
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
# Should exist!
|
||||
WorkingDirectory=/var/my.service${2}
|
||||
TimeoutStopSec=30
|
||||
Type=simple
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,5 +0,0 @@
|
|||
# -*- mode: Shell-script -*-
|
||||
# name:wget
|
||||
# key:wget
|
||||
# --
|
||||
wget --continue ${1:link} --output-document ${2:file}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue