2019-04-09 00:25:56 +02:00
|
|
|
;;; oni-csharp.el --- C# Configuration -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
;; Keywords: local
|
2019-07-16 17:30:12 +02:00
|
|
|
;; Version: 20190711082233
|
|
|
|
;; Package-Requires: (csharp-mode omnisharp oni-company oni-flycheck)
|
2019-04-09 00:25:56 +02:00
|
|
|
|
|
|
|
;; 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
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; My C# configuration.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2019-04-09 23:05:09 +02:00
|
|
|
(defvar oni-csharp--projects (make-hash-table :test 'equal))
|
2019-04-09 00:25:56 +02:00
|
|
|
|
2019-04-09 23:05:09 +02:00
|
|
|
(defun oni-csharp-collect-project-names ()
|
2019-04-09 00:25:56 +02:00
|
|
|
"Go through the current buffer and collect all the project names."
|
|
|
|
(interactive)
|
2019-04-09 23:05:09 +02:00
|
|
|
(clrhash oni-csharp--projects)
|
2019-04-09 00:25:56 +02:00
|
|
|
(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)
|
2019-04-09 23:05:09 +02:00
|
|
|
oni-csharp--projects))))
|
2019-04-09 00:25:56 +02:00
|
|
|
|
|
|
|
(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
|
2019-04-09 23:05:09 +02:00
|
|
|
(propertize (format " => %s" (gethash (match-string 1) oni-csharp--projects))
|
2019-04-09 00:25:56 +02:00
|
|
|
'face '(:foreground "#808080")))
|
2019-04-09 23:05:09 +02:00
|
|
|
(overlay-put current-overlay 'oni-csharp--overlayp t)
|
|
|
|
(overlay-put current-overlay 'evaporate t)))))
|
2019-04-09 00:25:56 +02:00
|
|
|
|
2019-07-16 17:30:12 +02:00
|
|
|
(with-eval-after-load 'company
|
|
|
|
(add-to-list 'company-backends 'company-omnisharp))
|
|
|
|
|
|
|
|
(add-hook 'csharp-mode-hook 'company-mode)
|
|
|
|
(add-hook 'csharp-mode-hook 'electric-indent-local-mode)
|
|
|
|
(add-hook 'csharp-mode-hook 'electric-pair-local-mode)
|
|
|
|
(add-hook 'csharp-mode-hook 'flycheck-mode)
|
|
|
|
(add-hook 'csharp-mode-hook 'omnisharp-mode)
|
|
|
|
|
|
|
|
;;;###autoload(with-eval-after-load 'csharp-mode (require 'oni-csharp))
|
|
|
|
|
2019-04-09 00:25:56 +02:00
|
|
|
(provide 'oni-csharp)
|
|
|
|
;;; oni-csharp.el ends here
|