Before installing swift.nvim, ensure you have the Swift toolchain installed.
Quick setup:
# 1. Install swiftly (Swift version manager)
curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash
# 2. Install Swift toolchain
swiftly install latest
# 3. Verify installation
swift --version
sourcekit-lsp --versionFor detailed installation instructions, see DEPENDENCIES.md
Create the file ~/.config/nvim/lua/plugins/swift.lua:
return {
{
"devswiftzone/swift.nvim",
ft = "swift",
opts = {},
},
}# Close and reopen Neovim, or run:
:Lazy synccd your-swift-project
nvim main.swiftYou should see a notification: "Swift Package detected: /path/to/project"
If you're developing the plugin locally:
mkdir -p ~/projects/nvim
cd ~/projects/nvim
# Your plugin is already at: ~/projects/nvim/swift.nvimCreate ~/.config/nvim/lua/plugins/swift-dev.lua:
return {
{
dir = "~/projects/nvim/swift.nvim",
ft = "swift",
config = function()
require("swift").setup()
end,
},
}:Lazy reload swift.nvimAfter installation, verify everything works:
:checkhealth swiftYou should see:
- ✓ Plugin loaded successfully
- ✓ Configuration loaded
- ✓ Feature 'project_detector' is enabled
-
Check if installed:
:Lazy
Look for "swift.nvim" in the list
-
Check for errors:
:messages -
Try manual reload:
:Lazy reload swift.nvim
-
Make sure you have one of these files in your project:
Package.swift*.xcodeproj*.xcworkspace
-
Try manual detection:
:SwiftDetectProject
-
Check if you're in a Swift file:
:set filetype?
Should show:
filetype=swift
-
Enable debug logging:
require("swift").setup({ log_level = "debug", })
-
Check health:
:checkhealth swift
-
Check messages:
:messages
- See QUICKSTART.md for usage examples
- See README.md for full documentation
- See examples/ for configuration examples
- See .github/CONFIGURATION_TEMPLATE.md for copy-paste templates
To remove the plugin:
-
Delete the plugin file:
rm ~/.config/nvim/lua/plugins/swift.lua -
Clean up:
:Lazy clean
-
Restart Neovim