Skip to content

Latest commit

 

History

History
187 lines (135 loc) · 2.91 KB

File metadata and controls

187 lines (135 loc) · 2.91 KB

Installation Guide

Prerequisites

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 --version

For detailed installation instructions, see DEPENDENCIES.md

For LazyVim Users (Simplest Method)

Step 1: Create plugin configuration

Create the file ~/.config/nvim/lua/plugins/swift.lua:

return {
  {
    "devswiftzone/swift.nvim",
    ft = "swift",
    opts = {},
  },
}

Step 2: Restart Neovim

# Close and reopen Neovim, or run:
:Lazy sync

Step 3: Test it

cd your-swift-project
nvim main.swift

You should see a notification: "Swift Package detected: /path/to/project"


For Local Development

If you're developing the plugin locally:

Step 1: Clone or create the plugin

mkdir -p ~/projects/nvim
cd ~/projects/nvim
# Your plugin is already at: ~/projects/nvim/swift.nvim

Step 2: Configure LazyVim

Create ~/.config/nvim/lua/plugins/swift-dev.lua:

return {
  {
    dir = "~/projects/nvim/swift.nvim",
    ft = "swift",
    config = function()
      require("swift").setup()
    end,
  },
}

Step 3: Reload

:Lazy reload swift.nvim

Verification

After installation, verify everything works:

:checkhealth swift

You should see:

  • ✓ Plugin loaded successfully
  • ✓ Configuration loaded
  • ✓ Feature 'project_detector' is enabled

Troubleshooting

Plugin not loading?

  1. Check if installed:

    :Lazy

    Look for "swift.nvim" in the list

  2. Check for errors:

    :messages
  3. Try manual reload:

    :Lazy reload swift.nvim

Project not detected?

  1. Make sure you have one of these files in your project:

    • Package.swift
    • *.xcodeproj
    • *.xcworkspace
  2. Try manual detection:

    :SwiftDetectProject
  3. Check if you're in a Swift file:

    :set filetype?

    Should show: filetype=swift

Still having issues?

  1. Enable debug logging:

    require("swift").setup({
      log_level = "debug",
    })
  2. Check health:

    :checkhealth swift
  3. Check messages:

    :messages

Next Steps

Uninstallation

To remove the plugin:

  1. Delete the plugin file:

    rm ~/.config/nvim/lua/plugins/swift.lua
  2. Clean up:

    :Lazy clean
  3. Restart Neovim