Skip to content

Commit

Permalink
Add function to execute the lsp extension full source
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat committed Oct 18, 2023
1 parent 71bbf89 commit 52811aa
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions clients/lsp-wgsl.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@
:group 'lsp-wgsl
:package-version '(lsp-mode . "8.0.1"))


;; Various interactive functions to use the custom LSP extensions from the server
(defun lsp-wgsl-full-source ()
"Gets the full source of the file with all imports and preprocessor definitions resolved."
(interactive)
(lsp-request-async
"wgsl-analyzer/fullSource"
(list :textDocument (list :uri (lsp--buffer-uri)))
(lambda (source)
(let ((buffer (get-buffer-create "*WGSL-full-source*")))
(with-current-buffer buffer
(setq-local buffer-read-only nil)
(erase-buffer)
(insert source)
(read-only-mode)
;; activate only syntax highlighting
(font-lock-add-keywords nil wgsl-font-lock-keywords)
(font-lock-mode))
(switch-to-buffer buffer)))))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda ()
Expand Down

0 comments on commit 52811aa

Please sign in to comment.