forked from OmniSharp/omnisharp-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
omnisharp-server-actions.el
69 lines (57 loc) · 2.79 KB
/
omnisharp-server-actions.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;; -*- lexical-binding: t; -*-
;; This file 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, or (at your option)
;; any later version.
;; This file 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 <http://www.gnu.org/licenses/>.
(defun omnisharp--start-omnisharp-server (no-autodetect)
"Actual implementation for autoloaded omnisharp-start-omnisharp-server.
Will query user for a path to project/solution file to start the server with."
(let ((server-executable-path (omnisharp--resolve-omnisharp-server-executable-path))
(project-root (omnisharp--project-root)))
(if server-executable-path
(if (and (not no-autodetect)
project-root
(file-directory-p project-root))
(omnisharp--do-server-start project-root)
(let ((project-root (read-directory-name "Project root to use with OmniSharp: ")))
(if (file-directory-p project-root)
(omnisharp--do-server-start project-root)
(error (format "Path does not lead to a directory: %s" project-root))))))))
(defun omnisharp--stop-server ()
"Actual implementation for autoloaded omnisharp-stop-server"
(unless (equal nil omnisharp--server-info)
(kill-process (cdr (assoc :process omnisharp--server-info)))))
(defun omnisharp--reload-solution ()
"Actual implementation for autoloaded omnisharp-reload-solution"
(if (and (not (equal nil omnisharp--last-project-path))
(not (equal nil omnisharp--server-info)))
(progn
(setq omnisharp--restart-server-on-stop t)
(kill-process (cdr (assoc :process omnisharp--server-info))))
(message "Cannot reload project in Omnisharp - no project previously loaded")))
(defun omnisharp--check-alive-status ()
"Actual implementation for autoloaded omnisharp-check-alive-status"
(omnisharp--send-command-to-server
"checkalivestatus"
nil
#'omnisharp--check-alive-status-worker))
(defun omnisharp--check-alive-status-worker (alive?)
(if alive?
(message "Server is alive and well. Happy coding!")
(message "Server is not alive")))
(defun omnisharp--check-ready-status ()
"Actual implementation for autoloaded omnisharp--check-ready-status"
(omnisharp--send-command-to-server
"checkreadystatus"
nil
(lambda (ready?)
(if ready?
(message "Server is ready")
(message "Server is not ready yet")))))
(provide 'omnisharp-server-actions)