Update init.el with vertico, marginalia, lsp for C#

This commit is contained in:
Taryel Hlontsi 2023-12-01 10:17:16 +01:00
parent 9aa893f17a
commit 786808e94b
7 changed files with 158 additions and 92 deletions

210
init.el
View File

@ -1,3 +1,12 @@
(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.
'(initial-frame-alist '((fullscreen . maximized)))
'(package-selected-packages
'(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) (require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize) (package-initialize)
@ -10,7 +19,34 @@
:ensure t :ensure t
:config (which-key-mode)) :config (which-key-mode))
(set-face-attribute 'default nil :font "JetBrains Mono" :height 130) (use-package vertico
:ensure t
:config
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy))
(use-package marginalia
:ensure t)
(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)
;;(set-face-attribute 'default nil :font "JetBrains Mono" :height 110)
(set-face-attribute 'default nil :font "VictorMono Nerd Font Mono" :height 110)
(set-default-coding-systems 'utf-8) (set-default-coding-systems 'utf-8)
@ -24,25 +60,22 @@
(setq-default indent-tabs-mode nil) (setq-default indent-tabs-mode nil)
;;(setq ido-everywhere t)
;;(setq ido-enable-flex-matching t)
(ido-mode)
(setq show-paren-delay 0) (setq show-paren-delay 0)
(delete-selection-mode 1) (delete-selection-mode 1)
(show-paren-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) (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 (use-package elpy
:ensure t) :ensure t)
@ -56,13 +89,15 @@
(exec-path-from-shell-copy-env "PATH") (exec-path-from-shell-copy-env "PATH")
(when (require 'flycheck nil t) ;; black or 'standard' (flake8 ?) code formatter:
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) ;; (add-hook 'elpy-mode-hook (lambda ()
(add-hook 'elpy-mode-hook 'flycheck-mode)) ;; (add-hook 'before-save-hook
;; 'elpy-format-code nil t)))
(add-hook 'elpy-mode-hook (lambda () (add-hook 'elpy-mode-hook (lambda ()
(add-hook 'before-save-hook (add-hook 'before-save-hook
'elpy-format-code nil t))) 'elpy-black-fix-code nil t)))
(add-hook 'python-mode-hook (add-hook 'python-mode-hook
(lambda () (setq gud-pdb-command-name "python3 -m pdb"))) (lambda () (setq gud-pdb-command-name "python3 -m pdb")))
@ -77,13 +112,6 @@
(yas-reload-all) (yas-reload-all)
(add-hook 'prog-mode-hook 'yas-minor-mode)) (add-hook 'prog-mode-hook 'yas-minor-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 ;; my keybindings
@ -91,6 +119,10 @@
(interactive) (interactive)
(revert-buffer :ignore-auto :noconfirm)) (revert-buffer :ignore-auto :noconfirm))
(defun kill-buffer-no-confirm ()
(interactive)
(kill-buffer nil))
(defun list-buffers-please () (defun list-buffers-please ()
(interactive) (interactive)
(list-buffers) (list-buffers)
@ -108,15 +140,22 @@
(global-unset-key (kbd "C-f")) (global-unset-key (kbd "C-f"))
(global-unset-key (kbd "C-b")) (global-unset-key (kbd "C-b"))
(global-unset-key (kbd "C-n")) (global-unset-key (kbd "C-n"))
(global-unset-key (kbd "C-l"))
(global-unset-key (kbd "C-p")) (global-unset-key (kbd "C-p"))
(global-unset-key (kbd "M-v")) (global-unset-key (kbd "M-v"))
(global-set-key (kbd "<f1>") 'list-buffers-please) (global-set-key (kbd "<f1>") 'find-file)
(global-set-key (kbd "<f5>") 'revert-buffer-no-confirm) (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") 'dired-create-empty-file)
(add-hook 'elpy-mode-hook (add-hook 'elpy-mode-hook
(lambda () (local-set-key [f2] 'elpy-refactor-rename))) (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 (add-hook 'typescript-mode-hook
(lambda () (local-set-key [f2] 'tide-rename-symbol))) (lambda () (local-set-key [f2] 'tide-rename-symbol)))
@ -129,15 +168,21 @@
(add-hook 'mhtml-mode-hook (add-hook 'mhtml-mode-hook
(lambda () (local-set-key (kbd "C-f") 'prettier-js))) (lambda () (local-set-key (kbd "C-f") 'prettier-js)))
(add-hook 'typescript-mode-hook (add-hook 'typescript-ts-mode-hook
(lambda () (local-set-key (kbd "C-f") 'prettier-js))) (lambda () (local-set-key (kbd "C-f") 'prettier-js)))
(add-hook 'js-mode-hook (add-hook 'js-mode-hook
(lambda () (local-set-key (kbd "C-f") 'make-json-great-again))) (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 'prog-mode-hook ;; (add-hook 'prog-mode-hook
;; (lambda () (local-set-key (kbd "C-;") 'comment-or-uncomment-region))) ;; (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 ;; stuff for folding html
(defun mhtml-forward (arg) (defun mhtml-forward (arg)
(interactive "P") (interactive "P")
@ -158,7 +203,7 @@
(require 'display-line-numbers) (require 'display-line-numbers)
(defcustom display-line-numbers-exempt-modes (defcustom display-line-numbers-exempt-modes
'(gud-mode inferior-python-mode dired-mode vterm-mode eshell-mode shell-mode term-mode ansi-tern-mode) '(gud-mode inferior-python-mode dired-mode vterm-mode eshell-mode shell-mode term-mode ansi-tern-mode treemacs-mode)
"Major modes on which to disable line numbers" "Major modes on which to disable line numbers"
:group 'display-line-numbers :group 'display-line-numbers
:type 'list :type 'list
@ -180,41 +225,6 @@ Exempt major modes are defined in `display-line-numbers-exempt-modes'."
(load-theme 'modus-operandi-tinted t) (load-theme 'modus-operandi-tinted t)
;;(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
;;(use-package doom-themes
;; :ensure t
;; :config
;; (load-theme 'doom-monokai-pro t))
;; (use-package zenburn-theme
;; :ensure t)
;; (load-theme 'zenburn t)
;; (use-package birds-of-paradise-plus-theme
;; :ensure t)
;; (load-theme 'birds-of-paradise-plus t)
;; (use-package spacemacs-theme
;; :defer t
;; :init (load-theme 'spacemacs-light t))
;; (use-package poet-theme
;; :ensure t)
;; (load-theme 'poet t)
;; ;;(set-face-attribute 'default nil :family "DejaVu Sans Mono" :height 130)
;; (set-face-attribute 'fixed-pitch nil :family "DejaVu Sans Mono")
;; (set-face-attribute 'variable-pitch nil :family "IBM Plex Serif")
;; (add-to-list
;; 'default-frame-alist'(ns-transparent-titlebar . t))
;; (add-to-list
;; 'default-frame-alist'(ns-appearance . light))
;; (add-hook 'text-mode-hook
;; (lambda ()
;; (variable-pitch-mode 1)))
(use-package magit (use-package magit
:ensure t) :ensure t)
@ -222,14 +232,15 @@ Exempt major modes are defined in `display-line-numbers-exempt-modes'."
:ensure t :ensure t
:hook (after-init . doom-modeline-mode)) :hook (after-init . doom-modeline-mode))
(use-package all-the-icons ;; M-x nerd-icons-install-fonts
:if (display-graphic-p)) (use-package nerd-icons
:ensure t)
;; prettier setup goes here ;; prettier setup goes here
(use-package prettier-js (use-package prettier-js
:ensure t) :ensure t)
;;________________________________________________________ ;; __________________________________________________
(use-package orderless (use-package orderless
:ensure t :ensure t
@ -240,43 +251,60 @@ Exempt major modes are defined in `display-line-numbers-exempt-modes'."
(use-package json-mode :ensure t) (use-package json-mode :ensure t)
;; __________________________________________________ ;; __________________________________________________
;; typescript setup starts here
;; typescript setup starts here (TO REVIEW!)
(defun setup-tide-mode () (defun setup-tide-mode ()
(interactive) (interactive)
(tide-setup) (tide-setup)
(flycheck-mode +1) (flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled)) (setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1) (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 (use-package tide
:ensure t :ensure t
:after (typescript-mode company flycheck) :after (flycheck)
:hook ((typescript-mode . tide-setup) :hook ((typescript-ts-mode . setup-tide-mode)
(typescript-mode . tide-hl-identifier-mode) (tsx-ts-mode . setup-tide-mode)
(typescript-ts-mode . tide-hl-identifier-mode)
(before-save . tide-format-before-save))) (before-save . tide-format-before-save)))
(custom-set-variables
;; custom-set-variables was added by Custom. (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode))
;; If you edit it by hand, you could mess it up, so be careful. (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;;----------------------------------------
'(package-selected-packages ;; dotnet starts here
'(tide which-key use-package pyenv-mode flycheck exec-path-from-shell elpy doom-themes doom-modeline all-the-icons))) (use-package lsp-mode
:commands (lsp lsp-deferred))
(use-package dap-mode
:ensure t
;;:custom (lsp-enable-dap-auto-configure nil)
:commands dap-debug)
;;(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))
(defun setup-dotnet ()
(interactive)
(exec-path-from-shell-copy-env "DOTNET_ROOT")
(lsp-deferred))
(add-hook 'csharp-mode-hook
(lambda () (setup-dotnet)))
(add-hook 'lsp-mode-hook
(lambda () (setup-lsp-keys)))
(require 'dap-netcore)
(use-package dockerfile-mode
:ensure t)
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View File

@ -0,0 +1,9 @@
# -*- mode: python -*-
# name: file-read
# key: fr
# --
with open($0, 'r') as file:
try:
data = json.load(file)
except (json.JSONDecodeError):
data = {}

View File

@ -0,0 +1,7 @@
# -*- 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})

View File

@ -0,0 +1,10 @@
# -*- 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))

View File

@ -0,0 +1,7 @@
# -*- mode: python -*-
# name: print-version
# key: pi
# --
import sys
print(sys.version)

View File

@ -0,0 +1,5 @@
# -*- mode: python -*-
# name: script
# key: s
# --
#!/usr/bin/env python3