[libcxx-commits] [libcxx] [mlir] [polly] [llvm] [lld] [clang-tools-extra] [clang] [compiler-rt] [emacs][lsp][tblgen] add tblgen-lsp-server support for emacs lsp-mode (PR #76337)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 25 03:24:03 PST 2023


https://github.com/mgcsysinfcat updated https://github.com/llvm/llvm-project/pull/76337

>From b530c6dfc9d2e098b3634ea720f0b0bfde0d411f Mon Sep 17 00:00:00 2001
From: mgcsysinfcat <p779yqwdf at mozmail.com>
Date: Sun, 24 Dec 2023 23:00:00 +0800
Subject: [PATCH] add tblgen-lsp-server support for lsp-mode

---
 mlir/utils/emacs/tblgen-lsp.el | 45 ++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 mlir/utils/emacs/tblgen-lsp.el

diff --git a/mlir/utils/emacs/tblgen-lsp.el b/mlir/utils/emacs/tblgen-lsp.el
new file mode 100644
index 00000000000000..607459549193a1
--- /dev/null
+++ b/mlir/utils/emacs/tblgen-lsp.el
@@ -0,0 +1,45 @@
+;;; tblgen-lsp.el --- Description -*- lexical-binding: t; -*-
+;;
+;; Package-Requires: ((emacs "24.3"))
+;;
+;; This file is not part of GNU Emacs.
+;;
+;;; Commentary:
+;;  LSP clinet to use with `tablegen-mode' that uses `tblgen-lsp-server' or any
+;;  user made compatible server.
+;;
+;;
+;;; Code:
+
+
+(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 "
+  :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 lsp-tblgen-server-args))); (concat "--tablegen-compilation-database=" lsp-tblgen-compilation-database-location) )))
+    :activation-fn (lsp-activate-on "tablegen")
+    :priority -1
+    :server-id 'tblgen-lsp-server)))
+
+(provide 'tblgen-lsp)
+;;; tblgen-lsp.el ends here



More information about the libcxx-commits mailing list