Skip to content

Commit

Permalink
Add interactive function for viewing wgsl syntax tree (#4242)
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat authored Nov 20, 2023
1 parent e8fc0cd commit d441f3d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clients/lsp-wgsl.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@
(font-lock-mode))
(switch-to-buffer buffer)))))

(defun lsp-wgsl-syntax-tree ()
"Gets the syntax tree of the current buffer."
(interactive)
(lsp-request-async
"wgsl-analyzer/syntaxTree"
(list :textDocument (list :uri (lsp--buffer-uri))
:range (if (use-region-p)
(lsp--region-to-range (region-beginning) (region-end))
(lsp--region-to-range (point-min) (point-max))))
(lambda (syntax-tree)
(let ((buffer (get-buffer-create (format "*WGSL-syntax-tree %s*" (lsp--buffer-uri)))))
(with-current-buffer buffer
(setq-local buffer-read-only nil)
(erase-buffer)
(insert syntax-tree)
(read-only-mode))
(switch-to-buffer buffer)))))

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

0 comments on commit d441f3d

Please sign in to comment.