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.
This commit is contained in:
Jason Ross
2026-09-27 15:58:04 -05:00
parent baa7030a5a
commit 95bc4ffd5a
+29
View File
@@ -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" },
},
},
},
}