From 214eb9560d1ff1842d68ab9fe4d9544e04bfcebc Mon Sep 17 00:00:00 2001 From: Taryel Hlontsi Date: Thu, 28 Mar 2024 14:01:33 +0100 Subject: [PATCH] Add functions and snippets for csharp --- init.el | 36 +++++++++++++++++++++++++++++++++++- snippets/csharp-mode/class | 4 +++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index 3e18067..2f60f88 100644 --- a/init.el +++ b/init.el @@ -3,6 +3,8 @@ ;; 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 '(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))) @@ -53,6 +55,8 @@ (set-face-attribute 'default nil :font "Hack Nerd Font Mono" :height 110) ;;(set-face-attribute 'default nil :font "VictorMono Nerd Font Mono" :height 110) +;;(setq x-antialiasing-factor nil) + (set-default-coding-systems 'utf-8) (setq ring-bell-function 'ignore) @@ -227,10 +231,15 @@ Exempt major modes are defined in `display-line-numbers-exempt-modes'." ;; theming starts here: +;; (use-package doom-themes +;; :ensure t +;; :config +;; (load-theme 'doom-monokai-pro)) + (use-package modus-themes :ensure t) -(modus-themes-select 'modus-vivendi-tinted) +(modus-themes-select 'modus-operandi-tinted) (setq modus-themes-to-toggle '(modus-operandi-tinted modus-vivendi-tinted)) (use-package ef-themes @@ -338,6 +347,31 @@ ef-themes-variable-pitch-ui t) :ensure t) +(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) + ) + ) + + (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/snippets/csharp-mode/class b/snippets/csharp-mode/class index 1308130..f7b7801 100644 --- a/snippets/csharp-mode/class +++ b/snippets/csharp-mode/class @@ -2,10 +2,12 @@ # name: class # key: cl # -- -namespace $0`(directory-file-name default-directory)`; +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)))`() { }