aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-03-02 17:59:42 -0800
committerGravatar Tom Willemse2020-03-02 17:59:42 -0800
commit68e796fb7c6242ac9a3941f62c03aa8ba0d0f178 (patch)
tree3008a816db6dde6cb21e17ab1516b76774673064
parentf082706a204de79f70ff9dcde9957eab8eeadc20 (diff)
downloademacs-config-68e796fb7c6242ac9a3941f62c03aa8ba0d0f178.tar.gz
emacs-config-68e796fb7c6242ac9a3941f62c03aa8ba0d0f178.zip
Add snippets to oni-csharp
-rw-r--r--.gitlab-ci.yml11
-rw-r--r--GNUmakefile6
-rw-r--r--oni-csharp/Cask10
-rw-r--r--oni-csharp/oni-csharp.el (renamed from oni-csharp.el)26
-rw-r--r--oni-csharp/snippets/csharp-mode/testm9
5 files changed, 59 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9ae8a76..06a979d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -117,6 +117,16 @@ package-oni-twig:
paths:
- 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:
stage: package
dependencies:
@@ -131,6 +141,7 @@ package:
- package-oni-python
- package-oni-ruby
- package-oni-twig
+ - package-oni-csharp
before_script:
- rm -rf bin/
- mkdir bin/
diff --git a/GNUmakefile b/GNUmakefile
index 7e22dd0..0d51bcb 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -16,7 +16,8 @@ endef
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-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-%: %
$(call upload,\"$^\")
@@ -54,6 +55,9 @@ package-oni-ruby:
package-oni-twig:
$(call upload-multi-file,oni-twig)
+package-oni-csharp:
+ $(call upload-multi-file,oni-csharp)
+
install-%:
emacs --batch \
--load oni-package.el \
diff --git a/oni-csharp/Cask b/oni-csharp/Cask
new file mode 100644
index 0000000..0355c12
--- /dev/null
+++ b/oni-csharp/Cask
@@ -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/*"))
diff --git a/oni-csharp.el b/oni-csharp/oni-csharp.el
index 1a2c04f..e9a55f9 100644
--- a/oni-csharp.el
+++ b/oni-csharp/oni-csharp.el
@@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2020.0302.100628
-;; Package-Requires: (csharp-mode omnisharp oni-company oni-flycheck smartparens)
+;; Version: 2020.0302.175435
+;; Package-Requires: (csharp-mode omnisharp oni-company oni-flycheck oni-yasnippet smartparens)
;; 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
@@ -27,6 +27,17 @@
;;; Code:
(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))
@@ -83,6 +94,12 @@
(setq-local comment-auto-fill-only-comments t)
(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
(add-to-list 'company-backends
'(company-omnisharp :with company-yasnippet)))
@@ -105,6 +122,11 @@
;;;###autoload
(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))
(provide 'oni-csharp)
diff --git a/oni-csharp/snippets/csharp-mode/testm b/oni-csharp/snippets/csharp-mode/testm
new file mode 100644
index 0000000..4bd243d
--- /dev/null
+++ b/oni-csharp/snippets/csharp-mode/testm
@@ -0,0 +1,9 @@
+# -*- mode: snippet -*-
+# name: Test Method
+# key: testm
+# --
+[TestMethod]
+public void ${1:TestMethod}()
+{
+ $0
+} \ No newline at end of file