summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2024-01-06 11:44:43 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2024-01-06 11:44:43 +0000
commit5da80bb44cf623ea5b422b8685318d4437427177 (patch)
tree4564f148ed023b0a219065a1159a9e83c95a6d97
parent27d9ebcf6d2a7505db02a9a552f1f3a8e8ebc711 (diff)
emacs: Add Swift configuration
-rw-r--r--emacs/init.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 5e43218..b545677 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -187,6 +187,25 @@
:mode ("/PKGBUILD\\'" . sh-mode))
+;; Swift
+
+(use-package eglot
+ :config (add-to-list 'eglot-server-programs
+ '(swift-mode . ("xcrun" "sourcekit-lsp")))
+ :defer t)
+
+(use-package swift-mode
+ :init
+ (defun my/swift-format ()
+ "Format Swift code."
+ (interactive)
+ (save-buffer)
+ (shell-command (format "swift format -i %s" (buffer-file-name))))
+ :hook (swift-mode . eglot-ensure)
+ :bind (:map swift-mode-map ("C-c d" . my/swift-format))
+ :ensure t)
+
+
;; systemd
(use-package conf-mode