Skip to content

Commit 58c9fca

Browse files
authored
add support for typespec-ts-mode (#4693)
1 parent 69c96fe commit 58c9fca

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

clients/lsp-typespec.el

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@
4141

4242
(lsp-dependency
4343
'typespec-lsp
44-
'(:npm :package "@typespec/compiler"
45-
:path "tsp-server")
44+
'(:npm
45+
:package "@typespec/compiler"
46+
:path "tsp-server")
4647
'(:system "tsp-server"))
4748

4849
(defun lsp-typespec--server-executable-path ()
4950
"Return the typespec-lsp server command."
5051
(or
5152
(when-let* ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
5253
(let ((tsp-server-local-path (f-join workspace-folder "node_modules" ".bin"
53-
(if (eq system-type 'windows-nt) "tsp-server.cmd" "tsp-server"))))
54+
(if (eq system-type 'windows-nt) "tsp-server.cmd" "tsp-server"))))
5455
(when (f-exists? tsp-server-local-path)
5556
tsp-server-local-path)))
5657
(executable-find "tsp-server")
@@ -63,15 +64,15 @@
6364
("event" . default)))
6465
:new-connection (lsp-stdio-connection `(,(lsp-typespec--server-executable-path) "--stdio"))
6566
:activation-fn (lsp-activate-on "typespec")
66-
:major-modes '(typespec-mode)
67+
:major-modes '(typespec-mode typespec-ts-mode)
6768
:server-id 'typespec-lsp))
6869

6970
(lsp-consistency-check lsp-typespec)
7071

7172
(defun lsp-typespec-semantic-tokens-refresh (&rest _)
7273
"Force refresh semantic tokens."
7374
(when-let* ((workspace (and lsp-semantic-tokens-enable
74-
(lsp-find-workspace 'typespec-lsp (buffer-file-name)))))
75+
(lsp-find-workspace 'typespec-lsp (buffer-file-name)))))
7576
(--each (lsp--workspace-buffers workspace)
7677
(when (lsp-buffer-live-p it)
7778
(lsp-with-current-buffer it
@@ -80,7 +81,8 @@
8081
(with-eval-after-load 'typespec
8182
(when lsp-semantic-tokens-enable
8283
;; refresh tokens
83-
(add-hook 'typespec-mode-hook #'lsp-typespec-semantic-tokens-refresh)))
84+
(dolist (hook '(typespec-mode-hook typespec-ts-mode-hook))
85+
(add-hook hook #'lsp-typespec-semantic-tokens-refresh))))
8486

8587
(provide 'lsp-typespec)
8688
;;; lsp-typespec.el ends here

lsp-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ Changes take effect only when a new session is started."
894894
(typescript-mode . "typescript")
895895
(typescript-ts-mode . "typescript")
896896
(typespec-mode . "typespec")
897+
(typespec-ts-mode . "typespec")
897898
(tsx-ts-mode . "typescriptreact")
898899
(svelte-mode . "svelte")
899900
(fsharp-mode . "fsharp")

0 commit comments

Comments
 (0)