1
0
Fork 0

Add snippets to oni-csharp

This commit is contained in:
Tom Willemse 2020-03-02 17:59:42 -08:00
parent f082706a20
commit 68e796fb7c
5 changed files with 59 additions and 3 deletions

View file

@ -117,6 +117,16 @@ package-oni-twig:
paths: paths:
- oni-twig/dist/ - oni-twig/dist/
package-oni-csharp:
stage: pre-package-multifile
before_script:
- rm -rf oni-csharp/dist
script:
- cask --path oni-csharp package
artifacts:
paths:
- oni-csharp/dist/
package: package:
stage: package stage: package
dependencies: dependencies:
@ -131,6 +141,7 @@ package:
- package-oni-python - package-oni-python
- package-oni-ruby - package-oni-ruby
- package-oni-twig - package-oni-twig
- package-oni-csharp
before_script: before_script:
- rm -rf bin/ - rm -rf bin/
- mkdir bin/ - mkdir bin/

View file

@ -16,7 +16,8 @@ endef
package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \ package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \
package-oni-haml package-oni-html package-oni-nxml package-oni-org \ package-oni-haml package-oni-html package-oni-nxml package-oni-org \
package-oni-php package-oni-python package-oni-ruby package-oni-twig package-oni-php package-oni-python package-oni-ruby package-oni-twig \
package-oni-csharp
package-%: % package-%: %
$(call upload,\"$^\") $(call upload,\"$^\")
@ -54,6 +55,9 @@ package-oni-ruby:
package-oni-twig: package-oni-twig:
$(call upload-multi-file,oni-twig) $(call upload-multi-file,oni-twig)
package-oni-csharp:
$(call upload-multi-file,oni-csharp)
install-%: install-%:
emacs --batch \ emacs --batch \
--load oni-package.el \ --load oni-package.el \

10
oni-csharp/Cask Normal file
View file

@ -0,0 +1,10 @@
(source gnu)
(source melpa)
(package-file "./oni-csharp.el")
(depends-on "oni-yasnippet" :git "../" :files ("oni-yasnippet.el"))
(files
"*.el"
("snippets" "./snippets/*"))

View file

@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; Keywords: local
;; Version: 2020.0302.100628 ;; Version: 2020.0302.175435
;; Package-Requires: (csharp-mode omnisharp oni-company oni-flycheck smartparens) ;; Package-Requires: (csharp-mode omnisharp oni-company oni-flycheck oni-yasnippet smartparens)
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by ;; it under the terms of the GNU General Public License as published by
@ -27,6 +27,17 @@
;;; Code: ;;; Code:
(require 'csharp-mode) (require 'csharp-mode)
(require 'yasnippet)
(defconst oni-csharp-root
(file-name-directory
(or load-file-name
(buffer-file-name)))
"The directory where oni-csharp was loaded from.")
(defconst oni-csharp-snippets-dir
(expand-file-name "snippets" oni-csharp-root)
"The directory where oni-csharp stores its snippets.")
(defvar oni-csharp--projects (make-hash-table :test 'equal)) (defvar oni-csharp--projects (make-hash-table :test 'equal))
@ -83,6 +94,12 @@
(setq-local comment-auto-fill-only-comments t) (setq-local comment-auto-fill-only-comments t)
(auto-fill-mode)) (auto-fill-mode))
(defun oni-csharp-snippets-initialize ()
"Initialize the snippets for oni-csharp."
(when (boundp 'yas-snippet-dirs)
(add-to-list 'yas-snippet-dirs oni-csharp-snippets-dir t))
(yas-load-directory oni-csharp-snippets-dir))
(with-eval-after-load 'company (with-eval-after-load 'company
(add-to-list 'company-backends (add-to-list 'company-backends
'(company-omnisharp :with company-yasnippet))) '(company-omnisharp :with company-yasnippet)))
@ -105,6 +122,11 @@
;;;###autoload ;;;###autoload
(add-to-list 'auto-mode-alist '("\\.csproj\\'" . nxml-mode)) (add-to-list 'auto-mode-alist '("\\.csproj\\'" . nxml-mode))
;;;###autoload
(with-eval-after-load 'csharp-mode
(with-eval-after-load 'yasnippet
(oni-csharp-snippets-initialize)))
;;;###autoload(with-eval-after-load 'csharp-mode (require 'oni-csharp)) ;;;###autoload(with-eval-after-load 'csharp-mode (require 'oni-csharp))
(provide 'oni-csharp) (provide 'oni-csharp)

View file

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: Test Method
# key: testm
# --
[TestMethod]
public void ${1:TestMethod}()
{
$0
}