Skip to content

nosami/yasnippet-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

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

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

About

A collection of C# snippets for yasnippet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published