From 95bc4ffd5a1bbc38635b0c0688a2a04a18c818c3 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Sun, 27 Sep 2026 15:58:04 -0500 Subject: [PATCH] feat(swift): add Swift highlighting, sourcekit-lsp and formatting LazyVim has no Swift extra, so configure the pieces swift.org's Neovim guide uses: the Treesitter swift parser and sourcekit-lsp from the installed toolchain rather than Mason. lspconfig also assigns sourcekit C, C++ and Objective-C, which would put a second server beside clangd on those files, so limit it to Swift. Format on save with conform's swift formatter, which runs the toolchain's `swift format`; the standalone swift-format binary isn't on PATH. --- lua/plugins/swift.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lua/plugins/swift.lua diff --git a/lua/plugins/swift.lua b/lua/plugins/swift.lua new file mode 100644 index 0000000..0a4a92b --- /dev/null +++ b/lua/plugins/swift.lua @@ -0,0 +1,29 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "swift" } }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + sourcekit = { + -- sourcekit-lsp ships with Xcode and the Swift toolchain, not Mason. + mason = false, + -- lspconfig also lists C, C++ and Objective-C, which clangd handles. + filetypes = { "swift" }, + }, + }, + }, + }, + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + -- Runs `swift format` from the toolchain; the standalone + -- swift-format binary isn't on PATH. + swift = { "swift" }, + }, + }, + }, +}