Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nosami/yasnippet-csharp
A collection of C# snippets for yasnippet
https://github.com/nosami/yasnippet-csharp
Last synced: about 15 hours ago
JSON representation
A collection of C# snippets for yasnippet
- Host: GitHub
- URL: https://github.com/nosami/yasnippet-csharp
- Owner: nosami
- License: unlicense
- Created: 2014-07-22T21:10:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-11T20:32:57.000Z (over 10 years ago)
- Last Synced: 2024-11-08T09:51:27.883Z (about 2 months ago)
- Size: 195 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
yasnippet-csharp
================A collection of C# snippets for yasnippet with automatic namespace and classname insertion.
The following elisp snippet is required for namespace generation. (Thanks to http://cupfullofcode.com/snippet-expansion-with-yasnippet/)
```elisp
(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)
)
)
```