Skip to content

Commit

Permalink
lsp-csharp: add a test to check if dotnet tool csharp-ls is actually …
Browse files Browse the repository at this point in the history
…installed
  • Loading branch information
razzmatazz committed Feb 13, 2022
1 parent 557832b commit 9b3a921
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clients/lsp-csharp.el
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ is returned so lsp-mode can display this file."
(list "csharp-ls")
solution-file-params)))

(defun lsp-csharp--cls-test-csharp-ls-present ()
"Return non-nil if dotnet tool csharp-ls is installed globally."
(string-match-p "csharp-ls"
(shell-command-to-string "dotnet tool list -g")))

(defun lsp-csharp--cls-download-server (_client callback error-callback update?)
"Install/update csharp-ls language server using `dotnet tool'.
Expand All @@ -452,7 +457,8 @@ Will invoke CALLBACK or ERROR-CALLBACK based on result. Will update if UPDATE? i
"dotnet" "tool" (if update? "update" "install") "-g" "csharp-ls"))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection #'lsp-csharp--cls-make-launch-cmd)
(make-lsp-client :new-connection (lsp-stdio-connection #'lsp-csharp--cls-make-launch-cmd
#'lsp-csharp--cls-test-csharp-ls-present)
:priority -2
:server-id 'csharp-ls
:major-modes '(csharp-mode csharp-tree-sitter-mode)
Expand Down

0 comments on commit 9b3a921

Please sign in to comment.