Skip to content

Commit bb8bf60

Browse files
authored
A couple of improvements to the Neovim setup guide (#737)
1 parent 8cbb535 commit bb8bf60

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

documentation/articles/getting-started-with-vscode-swift.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
layout: page
33
date: 2024-05-28 12:00:00
4-
title: Getting started with Swift in VS Code
4+
title: Configuring VS Code for Swift Development
55
author: [matthewbastien, plemarquand]
66
---
77

8-
Visual Studio Code (VS Code) is a popular general purpose editor that supports a
8+
[Visual Studio Code](https://code.visualstudio.com/) (VS Code) is a popular general purpose editor that supports a
99
variety of languages through extensibility. The Swift extension brings Swift
1010
language-specific features to the editor, providing a seamless experience for
1111
developing Swift applications on all platforms.
@@ -79,7 +79,7 @@ which can include:
7979
![Package swift actions](/assets/images/getting-started-with-vscode-swift/language-features/package_actions.png)
8080

8181
<div class="warning" markdown="1">
82-
Before language features can be used you must perform a `swift build` command on your
82+
Before language features can be used you must perform a `swift build` command on your
8383
project either on the command line or using a task in VS Code. This populates the index in SourceKit-LSP.
8484
</div>
8585

documentation/articles/zero-to-swift-emacs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: page
33
date: 2024-06-05 12:00:00
4-
title: From Zero to Swift | Getting started with Swift in Emacs
4+
title: Configuring Emacs for Swift Development
55
author: [al45tair]
66
---
77

documentation/articles/zero-to-swift-nvim.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
layout: page
33
date: 2024-06-04 15:13:07
4-
title: From Zero to Swift | Configuring Neovim for Swift Development
4+
title: Configuring Neovim for Swift Development
55
author: [etcwilde]
66
---
77

8-
Neovim is a modern reimplementation of _Vim_, a popular terminal-based text
8+
[Neovim](https://neovim.io) is a modern reimplementation of _Vim_, a popular terminal-based text
99
editor.
1010
Neovim adds new features like asynchronous operations and powerful Lua bindings
1111
for a snappy editing experience, in addition to the improvements _Vim_ brings to
@@ -14,6 +14,8 @@ the original _Vi_ editor.
1414
This article walks you through configuring Neovim for Swift development,
1515
providing configurations for various plugins to build a working Swift editing
1616
experience.
17+
The configuration files are built up step by step and the end of the article contains the
18+
fully assembled versions of those files.
1719
It is not a tutorial on how to use Neovim and assumes some familiarity
1820
with modal text editors like _Neovim_, _Vim_, or _Vi_.
1921
We are also assuming that you have already installed a Swift toolchain on your
@@ -29,7 +31,7 @@ Basic setup and configuration includes:
2931
1. Installing Neovim.
3032
2. Installing `lazy.nvim` to manage our plugins.
3133
3. Configuring the SourceKit-LSP server.
32-
4. Setting up Language-Server-driven autocompletion with _nvim-cmp_.
34+
4. Setting up Language-Server-driven code completion with _nvim-cmp_.
3335
5. Setting up snippets with _LuaSnip_.
3436

3537
The following sections are provided to help guide you through the setup:
@@ -38,8 +40,9 @@ The following sections are provided to help guide you through the setup:
3840
- [Package Management](#packaging-with-lazy)
3941
- [Language Server Support](#language-server-support)
4042
- [File Updates](#file-updating)
41-
- [Autocomplete](#auto-complete)
43+
- [Code Completion](#code-completion)
4244
- [Snippets](#Snippets)
45+
- [Fully Assembled Configuration Files](#files)
4346

4447
> Tip: If you already have Neovim, Swift, and a package manager installed, you can skip to setting up [Language Server support](#language-server-support).
4548
@@ -194,10 +197,10 @@ return {
194197
}
195198
```
196199

197-
While this gives us LSP support through sourcekit-lsp, there are no keybindings,
198-
so it's not very practical. Lets hook those up now.
200+
While this gives us LSP support through SourceKit-LSP, there are no keybindings,
201+
so it's not very practical. Let's hook those up now.
199202

200-
We'll set up an auto command that fires when LSP attaches in the `config`
203+
We'll set up an auto command that fires when an LSP server attaches in the `config`
201204
function under where we set up the `sourcekit` server. The keybindings are
202205
applied to all LSP servers so you end up with a consistent experience across
203206
languages.
@@ -231,7 +234,7 @@ SourceKit-LSP increasingly relies on the editor informing the server when
231234
certain files change. This need is communicated through _dynamic registration_.
232235
You don't have to understand what that means, but Neovim doesn't implement
233236
dynamic registration. You'll notice this when you update your package manifest,
234-
or add new files to your compile-commands file and LSP doesn't work without
237+
or add new files to your `compile_commands.json` file and LSP doesn't work without
235238
restarting Neovim.
236239

237240
Instead, we know that SourceKit-LSP needs this functionality, so we'll enable it
@@ -255,16 +258,16 @@ following issues describe the issue in more detail:
255258
- [LSP: Implement dynamicRegistration](https://github.com/neovim/neovim/issues/13634)
256259
- [add documentFormattingProvider to server capabilities response](https://github.com/microsoft/vscode-eslint/pull/1307)
257260

258-
## Auto Complete
261+
## Code Completion
259262

260263
![LSP-driven autocomplete completing the Foundation module](/assets/images/zero-to-swift-nvim/LSP-Autocomplete.png)
261264

262-
We will use [_nvim-cmp_](https://github.com/hrsh7th/nvim-cmp) to act as the autocomplete mechanism.
265+
We will use [_nvim-cmp_](https://github.com/hrsh7th/nvim-cmp) to act as the code completion mechanism.
263266
We'll start by telling _lazy.nvim_ to download the package and to load it lazily when we enter insert
264-
mode since you don't need autocompletion if you're not editing the file.
267+
mode since you don't need code completion if you're not editing the file.
265268

266269
```lua
267-
-- lua/plugins/autocomplete.lua
270+
-- lua/plugins/codecompletion.lua
268271
return {
269272
{
270273
"hrsh7th/nvim-cmp",
@@ -274,7 +277,7 @@ return {
274277
}
275278
```
276279

277-
Next, we'll configure some completion sources to provide autocompletion results.
280+
Next, we'll configure some completion sources to provide code completion results.
278281
_nvim-cmp_ doesn't come with completion sources, those are additional plugins.
279282
For this configuration, I want results based on LSP, filepath completion, and
280283
the text in my current buffer. For more, the _nvim-cmp_ Wiki has a [list of
@@ -285,7 +288,7 @@ on them.
285288
This ensures that _lazy.nvim_ will initialize each of them when _nvim-cmp_ is loaded.
286289

287290
```lua
288-
-- lua/plugins/autocomplete.lua
291+
-- lua/plugins/codecompletion.lua
289292
return {
290293
{
291294
"hrsh7th/nvim-cmp",
@@ -303,7 +306,7 @@ return {
303306
}
304307
```
305308

306-
Now we need to configure _nvim-cmp_ to take advantage of the auto-completion
309+
Now we need to configure _nvim-cmp_ to take advantage of the code completion
307310
sources.
308311
Unlike many other plugins, _nvim-cmp_ hides many of its inner-workings, so
309312
configuring it is a little different from other plugins. Specifically, you'll
@@ -453,15 +456,14 @@ Now our tab-key is thoroughly overloaded in super-tab fashion.
453456
list.
454457
- If you press tab over a snippet, the snippet will expand, and continuing to
455458
press tab moves the cursor to the next selection point.
456-
- If you're neither auto-completing nor expanding a snippet, it will behave
459+
- If you're neither code completing nor expanding a snippet, it will behave
457460
like a normal `tab` key.
458461

459462
Now we need to write up some snippets. _LuaSnip_ supports several snippet formats,
460463
including a subset of the popular
461464
[TextMate](https://macromates.com/textmate/manual/snippets),
462465
[Visual Studio Code](https://code.visualstudio.com/docs/editor/userdefinedsnippets) snippet format,
463-
its own [Lua-based](https://github.com/L3MON4D3/LuaSnip/blob/master/Examples/snippets.lua) API,
464-
and snippets coming from an [LSP server](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax).
466+
and its own [Lua-based](https://github.com/L3MON4D3/LuaSnip/blob/master/Examples/snippets.lua) API.
465467

466468
Here are some snippets that I've found to be useful:
467469

@@ -584,7 +586,7 @@ vim.opt.tw = 80
584586
```
585587

586588
```lua
587-
-- lua/plugins/autocomplete.lua
589+
-- lua/plugins/codecompletion.lua
588590
return {
589591
{
590592
"hrsh7th/nvim-cmp",

0 commit comments

Comments
 (0)