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:
@@ -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" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user