Add functions and snippets for csharp

This commit is contained in:
Taryel Hlontsi 2024-03-28 14:01:33 +01:00
parent d6def578dd
commit 214eb9560d
2 changed files with 38 additions and 2 deletions

36
init.el
View File

@ -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.

View File

@ -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)))`()
{
}