aboutsummaryrefslogtreecommitdiffstats
path: root/oni-csharp
diff options
context:
space:
mode:
Diffstat (limited to 'oni-csharp')
-rw-r--r--oni-csharp/oni-csharp.el108
1 files changed, 59 insertions, 49 deletions
diff --git a/oni-csharp/oni-csharp.el b/oni-csharp/oni-csharp.el
index 11c1dcf..02b1cd7 100644
--- a/oni-csharp/oni-csharp.el
+++ b/oni-csharp/oni-csharp.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2022.0105.161232
+;; Version: 2022.0202.115001
;; Package-Requires: (csharp-mode oni-company oni-flycheck oni-yasnippet oni-hydra oni-lsp oni-smartparens)
;; This program is free software; you can redistribute it and/or modify
@@ -78,54 +78,6 @@ _cs_: Solution
(let ((compile-command (concat oni-csharp-devenv-executable " /Build Debug " (oni-csharp-locate-dominating-file-wildcard "*.sln") " /project " (oni-csharp-locate-dominating-file-wildcard "*.csproj"))))
(compile compile-command)))
-(defun oni-csharp-collect-project-names ()
- "Go through the current buffer and collect all the project names."
- (interactive)
- (clrhash oni-csharp--projects)
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward
- (rx bol
- "Project(\"{"
- (group (minimal-match (1+ (or alphanumeric "-"))))
- "}\") = \""
- (group (minimal-match (1+ any)))
- "\", \""
- (minimal-match (1+ any))
- "\", \"{"
- (group (minimal-match (1+ any)))
- "}\""
- eol)
- nil
- :noerror)
- (puthash (match-string-no-properties 3)
- (match-string-no-properties 2)
- oni-csharp--projects))))
-
-(defun oni-csharp-display-project-names ()
- "Display the project names in the current buffer."
- (interactive)
- (save-excursion
- (goto-char (point-min))
- (remove-overlays (point-min) (point-max) 'oni-csharp--overlayp t)
- (while (re-search-forward
- (rx bol
- (zero-or-more whitespace)
- "{"
- (group (minimal-match (one-or-more (or alphanumeric "-"))))
- "} = {"
- (group (minimal-match (one-or-more (or alphanumeric "-"))))
- "}"
- eol)
- nil
- :noerror)
- (let ((current-overlay (make-overlay (line-beginning-position) (line-end-position))))
- (overlay-put current-overlay 'after-string
- (propertize (format " => %s" (gethash (match-string 1) oni-csharp--projects))
- 'face '(:foreground "#808080")))
- (overlay-put current-overlay 'oni-csharp--overlayp t)
- (overlay-put current-overlay 'evaporate t)))))
-
(defun oni-csharp--auto-fill-mode ()
"Enable ‘auto-fill-mode’ only for comments."
(setq-local comment-auto-fill-only-comments t)
@@ -203,5 +155,63 @@ _cs_: Solution
(with-eval-after-load 'yasnippet
(oni-csharp-snippets-initialize)))
+;;; Solution mode
+
+(defun oni-csharp-collect-project-names ()
+ "Go through the current buffer and collect all the project names."
+ (interactive)
+ (clrhash oni-csharp--projects)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward
+ (rx bol
+ "Project(\"{"
+ (group (minimal-match (1+ (or alphanumeric "-"))))
+ "}\") = \""
+ (group (minimal-match (1+ any)))
+ "\", \""
+ (minimal-match (1+ any))
+ "\", \"{"
+ (group (minimal-match (1+ any)))
+ "}\""
+ eol)
+ nil
+ :noerror)
+ (puthash (match-string-no-properties 3)
+ (match-string-no-properties 2)
+ oni-csharp--projects))))
+
+(defun oni-csharp-display-project-names ()
+ "Display the project names in the current buffer."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (remove-overlays (point-min) (point-max) 'oni-csharp--overlayp t)
+ (while (re-search-forward
+ (rx bol
+ (zero-or-more whitespace)
+ "{"
+ (group (minimal-match (one-or-more (or alphanumeric "-"))))
+ "} = {"
+ (group (minimal-match (one-or-more (or alphanumeric "-"))))
+ "}"
+ eol)
+ nil
+ :noerror)
+ (let ((current-overlay (make-overlay (line-beginning-position) (line-end-position))))
+ (overlay-put current-overlay 'after-string
+ (propertize (format " => %s" (gethash (match-string 1) oni-csharp--projects))
+ 'face '(:foreground "#808080")))
+ (overlay-put current-overlay 'oni-csharp--overlayp t)
+ (overlay-put current-overlay 'evaporate t)))))
+
+(define-derived-mode csharp-solution-mode prog-mode "Sln"
+ "A major mode for viewing and editing C# ‘.sln’ files."
+ (oni-csharp-collect-project-names)
+ (oni-csharp-display-project-names))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist `(,(rx ".sln" eos) . csharp-solution-mode))
+
(provide 'oni-csharp)
;;; oni-csharp.el ends here