Skip to content

Commit 589bef3

Browse files
mgcsysinfcatmgcsysinfcatkeryell
authored
[emacs][lsp][tblgen] add tblgen-lsp-server support for emacs lsp-mode (#76337)
Co-authored-by: mgcsysinfcat <[email protected]> Co-authored-by: Ronan Keryell <[email protected]>
1 parent ef232a7 commit 589bef3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

mlir/utils/emacs/tblgen-lsp-client.el

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
;;; tblgen-lsp-client.el --- Description -*- lexical-binding: t; -*-
2+
;;
3+
;; Package-Requires: ((emacs "24.3"))
4+
;;
5+
;; This file is not part of GNU Emacs.
6+
;;
7+
;;; Commentary:
8+
;; LSP client to use with `tablegen-mode' that uses `tblgen-lsp-server' or any
9+
;; user made compatible server.
10+
;;
11+
;;
12+
;;; Code:
13+
(require 'lsp-mode)
14+
15+
(defgroup lsp-tblgen nil
16+
"LSP support for Tablegen."
17+
:group 'lsp-mode
18+
:link '(url-link "https://mlir.llvm.org/docs/Tools/MLIRLSP/"))
19+
20+
(defcustom lsp-tblgen-server-executable "tblgen-lsp-server"
21+
"Command to start the mlir language server."
22+
:group 'lsp-tblgen
23+
:risky t
24+
:type 'file)
25+
26+
27+
(defcustom lsp-tblgen-server-args ""
28+
"Args of LSP client for TableGen, for example '--tablegen-compilation-database=.../build/tablegen_compile_commands.yml'"
29+
:group 'lsp-tblgen
30+
:risky t
31+
:type 'file)
32+
33+
(defun lsp-tblgen-setup ()
34+
"Setup the LSP client for TableGen."
35+
(add-to-list 'lsp-language-id-configuration '(tablegen-mode . "tablegen"))
36+
37+
(lsp-register-client
38+
(make-lsp-client
39+
:new-connection (lsp-stdio-connection (lambda () (cons lsp-tblgen-server-executable (split-string-shell-command lsp-tblgen-server-args))))
40+
:activation-fn (lsp-activate-on "tablegen")
41+
:priority -1
42+
:server-id 'tblgen-lsp)))
43+
44+
(provide 'tblgen-lsp)
45+
;;; tblgen-lsp-client.el ends here

0 commit comments

Comments
 (0)