Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
)
)
```