spacevim/docs/_posts/2024-03-09-use-vim-as-a-swift-ide.md
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

53 lines
2.0 KiB
Markdown

---
title: "使用 Vim 搭建 swift 开发环境"
categories: [tutorials_cn, blog_cn]
image: https://img.spacevim.org/89797871-0d9ca580-db5e-11ea-8d43-c02cd9e49915.png
description: "介绍如何使用 Spacevim 搭建 swift 的 Vim/Neovim 开发环境,以及 lang#swift 模块所支持的功能特性、使用技巧"
permalink: /cn/:title/
lang: zh
type: article
language: Swift
---
# [Blogs](../blog/) >> 使用 Vim 搭建 swift 开发环境
本文主要介绍了使用 `SpaceVim` 搭建 `Swift` 语言开发环境的基本流程,以及所包含的功能。
`lang#swift` 模块提供了 `swift` 语言开发的基础环境,包括语法高亮、自动补全、语法检查、格式化等功能。
在阅读这篇文章之前,可以先阅读《[使用 Vim 搭建基础的开发环境](../use-vim-as-ide/)》,
`SpaceVim` 的基本使用有一个大致的了解。
<!-- vim-markdown-toc GFM -->
- [启用语言模块](#启用语言模块)
- [代码运行](#代码运行)
- [交互式编程](#交互式编程)
<!-- vim-markdown-toc -->
### 启用语言模块
`lang#swift` 模块为 SpaceVim 提供了 swift 编程语言的支持。这一模块默认并未启用,编辑 swift 语言建议启用该模块。
使用快捷键 `SPC f v d` 打开 SpaceVim 配置文件,并添加如下内容:
```toml
[[layers]]
name = 'lang#swift'
```
更多关于这一模块的功能可以查阅 [lang#swift](../layers/lang/swift/) 模块文档。
### 代码运行
默认运行代码的快捷键为 `SPC l r`,这个快捷键将异步执行命令 `swift current_file`。输出内容将在下方的插件窗口展示。
![swift_runner](https://img.spacevim.org/89795928-96fea880-db5b-11ea-81c4-7f3384f419e7.png)
### 交互式编程
在编辑 swift 文件时,可通过快捷键 `SPC l s i` 启动 swift 交互窗口,
之后使用快捷键将代码发送至解释器。默认快捷键都以 `SPC l s` 为前缀。
![swift_repl](https://img.spacevim.org/89796468-48054300-db5c-11ea-9ebe-4bb56e31722e.png)