From 042ceb0194bf4105d9cbf287f3c9e3dd7ecdf6ce Mon Sep 17 00:00:00 2001 From: Eddie Hillenbrand Date: Thu, 20 Aug 2020 11:59:29 -0700 Subject: [PATCH] Add support for C-famaily languages Add support for C-family languages and did some cosmetic cleanup to match lsp-clangd. --- lsp-sourcekit.el | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/lsp-sourcekit.el b/lsp-sourcekit.el index 8be4b62..b31b177 100644 --- a/lsp-sourcekit.el +++ b/lsp-sourcekit.el @@ -29,9 +29,9 @@ ;;; Commentary: ;; -;; Call (lsp) after visiting a file in swift-mode major mode. -;; -;; TODO: Configure the Objective-C/C++ LSP client (requires clangd). +;; Call (lsp) after visiting a file in a major mode supported by +;; sourcekit-lsp. + ;;; Code: @@ -41,17 +41,25 @@ ;; Customization ;; --------------------------------------------------------------------- -(defcustom lsp-sourcekit-executable - "sourcekit" - "Path of the lsp-sourcekit executable." + +(defgroup lsp-sourcekit nil + "LSP support for Swift & C-family languages (C, C++, +Objective-C, Objective-C++) using sourcekit-lsp." + :group 'lsp-mode + :tag "Language Server" + :link '(url-link "https://github.com/apple/sourcekit-lsp")) + +(defcustom lsp-sourcekit-executable "sourcekit-lsp" + "The sourcekit-lsp executable to use. +Leave as just the executable name to use the default behavior of +finding the executable with `exec-path'." :type 'file - :group 'sourcekit) + :group 'lsp-sourcekit) -(defcustom lsp-sourcekit-extra-args - nil - "Additional command line options passed to the lsp-sourcekit executable." +(defcustom lsp-sourcekit-extra-args nil + "Extra arguments for the sourcekit-lsp executable." :type '(repeat string) - :group 'sourcekit) + :group 'lsp-sourcekit) ;; --------------------------------------------------------------------- ;; Register lsp client @@ -59,13 +67,13 @@ (defun lsp-sourcekit--lsp-command () "Generate the language server startup command." - `(,lsp-sourcekit-executable - ,@lsp-sourcekit-extra-args)) + `(,lsp-sourcekit-executable ,@lsp-sourcekit-extra-args)) (lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-sourcekit--lsp-command) - :major-modes '(swift-mode) - :server-id 'sourcekit-ls)) + (make-lsp-client :new-connection (lsp-stdio-connection + 'lsp-sourcekit--lsp-command) + :major-modes '(swift-mode c-mode c++-mode objc-mode) + :server-id 'sourcekit-lsp)) (provide 'lsp-sourcekit) ;;; lsp-sourcekit.el ends here