Skip to content

Commit cc2bbd9

Browse files
committed
refactor
1 parent 345d874 commit cc2bbd9

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
(ns com.github.clojure-lsp.intellij.client
22
(:import
33
[com.intellij.openapi.project Project]
4-
[com.redhat.devtools.lsp4ij LanguageServerManager]))
4+
[com.redhat.devtools.lsp4ij LanguageServerManager]
5+
[com.redhat.devtools.lsp4ij.commands CommandExecutor LSPCommandContext]
6+
[org.eclipse.lsp4j Command]))
57

68
(set! *warn-on-reflection* true)
79

810
(defn server-status [^Project project]
911
(when-let [manager (LanguageServerManager/getInstance project)]
1012
(keyword (.toString (.getServerStatus manager "clojure-lsp")))))
13+
14+
(defn execute-command [^String name ^String text ^Project project]
15+
(-> (CommandExecutor/executeCommand
16+
(doto (LSPCommandContext. (Command. text name) project)
17+
(.setPreferredLanguageServerId "clojure-lsp")))
18+
(.response)))

src/main/clojure/com/github/clojure_lsp/intellij/extension/register_actions_startup.clj

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:implements [com.intellij.openapi.startup.StartupActivity
55
com.intellij.openapi.project.DumbAware])
66
(:require
7+
[com.github.clojure-lsp.intellij.client :as lsp-client]
78
[com.github.ericdallo.clj4intellij.action :as action]
89
[com.github.ericdallo.clj4intellij.logger :as logger]
910
[com.rpl.proxy-plus :refer [proxy+]])
@@ -12,9 +13,8 @@
1213
[com.intellij.openapi.actionSystem ActionManager AnActionEvent KeyboardShortcut]
1314
[com.intellij.openapi.keymap KeymapManager]
1415
[com.intellij.openapi.project Project]
15-
[com.redhat.devtools.lsp4ij.commands CommandExecutor LSPCommandAction LSPCommandContext]
16-
[javax.swing Icon KeyStroke]
17-
[org.eclipse.lsp4j Command]))
16+
[com.redhat.devtools.lsp4ij.commands LSPCommandAction]
17+
[javax.swing Icon KeyStroke]))
1818

1919
(set! *warn-on-reflection* true)
2020

@@ -73,11 +73,8 @@
7373
keymap (.getActiveKeymap keymap-manager)
7474
action (proxy+ ClojureLSPCommand [] LSPCommandAction
7575
(commandPerformed [_ _command ^AnActionEvent event]
76-
(-> (CommandExecutor/executeCommand
77-
(doto (LSPCommandContext. (Command. title id) project)
78-
(.setPreferredLanguageServerId "clojure-lsp")))
79-
(.response)
80-
)))]
76+
(lsp-client/execute-command id title)))]
77+
8178
(.setText (.getTemplatePresentation action) ^String title)
8279
(.setIcon (.getTemplatePresentation action) ^Icon icon)
8380
(when-not (.getAction manager id)

0 commit comments

Comments
 (0)