[emacs][lsp][tblgen] add tblgen-lsp-server support for emacs lsp-mode (#76337)

Co-authored-by: mgcsysinfcat <p779yqwdf@mozmail.com>
Co-authored-by: Ronan Keryell <ronan.keryell@amd.com>
This commit is contained in:
mgcsysinfcat 2025-01-29 03:26:14 +08:00 committed by GitHub
parent ef232a7e34
commit 589bef333e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,45 @@
;;; tblgen-lsp-client.el --- Description -*- lexical-binding: t; -*-
;;
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;; LSP client to use with `tablegen-mode' that uses `tblgen-lsp-server' or any
;; user made compatible server.
;;
;;
;;; Code:
(require 'lsp-mode)
(defgroup lsp-tblgen nil
"LSP support for Tablegen."
:group 'lsp-mode
:link '(url-link "https://mlir.llvm.org/docs/Tools/MLIRLSP/"))
(defcustom lsp-tblgen-server-executable "tblgen-lsp-server"
"Command to start the mlir language server."
:group 'lsp-tblgen
:risky t
:type 'file)
(defcustom lsp-tblgen-server-args ""
"Args of LSP client for TableGen, for example '--tablegen-compilation-database=.../build/tablegen_compile_commands.yml'"
:group 'lsp-tblgen
:risky t
:type 'file)
(defun lsp-tblgen-setup ()
"Setup the LSP client for TableGen."
(add-to-list 'lsp-language-id-configuration '(tablegen-mode . "tablegen"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection (lambda () (cons lsp-tblgen-server-executable (split-string-shell-command lsp-tblgen-server-args))))
:activation-fn (lsp-activate-on "tablegen")
:priority -1
:server-id 'tblgen-lsp)))
(provide 'tblgen-lsp)
;;; tblgen-lsp-client.el ends here