Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 28, 2025

Conversation

mgcsysinfcat
Copy link
Contributor

No description provided.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the mlir label Dec 24, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 24, 2023

@llvm/pr-subscribers-mlir

Author: None (mgcsysinfcat)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/76337.diff

1 Files Affected:

  • (added) mlir/utils/emacs/tblgen-lsp.el (+45)
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

Copy link
Contributor

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for doing this!
Since the tblgen name of the group is used in the customization UI names as Lsp Tblgen Server Args or Lsp Tblgen Server Executable, I wonder whether we should not rename any tblgen to tablegen in this file to be clearer.
Also this file could be renamed to tblgen-lsp-client.el to follow mlir-lsp-client.el.

@mgcsysinfcat
Copy link
Contributor Author

Thank you very much for doing this! Since the tblgen name of the group is used in the customization UI names as Lsp Tblgen Server Args or Lsp Tblgen Server Executable, I wonder whether we should not rename any tblgen to tablegen in this file to be clearer. Also this file could be renamed to tblgen-lsp-client.el to follow mlir-lsp-client.el.

Thank you for your feedback! It's been a while since I last worked on these, so I hope I didn't overlook anything. I've made the requested changes to the submission.

@keryell
Copy link
Contributor

keryell commented Jan 9, 2025

Thank you for your feedback! It's been a while since I last worked on these, so I hope I didn't overlook anything. I've made the requested changes to the submission.

I am sorry that nobody gave you feedback before. ☹️
Your file works for me on Ubuntu 24.10 & GNU Emacs 29.4. 👍

Copy link
Contributor

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

@keryell
Copy link
Contributor

keryell commented Jan 17, 2025

@joker-eph could you please look at this, as you contributed mlir-lsp-client.el?

@ftynse ftynse merged commit 589bef3 into llvm:main Jan 28, 2025
8 checks passed
@keryell
Copy link
Contributor

keryell commented Jan 29, 2025

@ftynse Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants