Skip to content

Commit 5bc2f66

Browse files
refactor: update neovim docs (#206)
1 parent 94dc001 commit 5bc2f66

File tree

1 file changed

+56
-10
lines changed

1 file changed

+56
-10
lines changed

src/getting-started.md

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,48 @@ A screenshot of the Flix Visual Studio Code extension in action:
4343

4444
### Using Flix from Neovim
4545

46-
Flix can also be used from [Neovim](https://neovim.io/).
47-
48-
Follow these steps to get started:
46+
Flix can also be used from [Neovim](https://neovim.io/). Follow these steps to
47+
get started:
4948

5049
#### Step 1: Install Neovim (v0.9 +)
5150

5251
Install Neovim using your preferred package manager or follow the [official installation guide](https://github.com/neovim/neovim/blob/master/INSTALL.md).
5352

53+
You can check if Neovim is installed and its version by running:
54+
55+
```shell
56+
nvim --version
57+
```
58+
5459
#### Step 2: Add nvim-lspconfig plugin to your Neovim
5560

56-
Install the `nvim-lspconfig` plugin using your preferred Neovim plugin manager. If you are not using a plugin manager, you can install it manually by running the following command (assuming your Neovim configuration directory is `~/.config/nvim`):
61+
Install the `nvim-lspconfig` plugin using your preferred Neovim plugin manager.
62+
63+
If you are not using a plugin manager, you can install it manually by running
64+
the following command (assuming your Neovim configuration directory is
65+
`~/.config/nvim`):
66+
67+
```shell
68+
git clone https://github.com/neovim/nvim-lspconfig \
69+
~/.config/nvim/pack/nvim/start/nvim-lspconfig
70+
```
71+
72+
If you are on Windows, you can run:
5773

5874
```shell
59-
git clone https://github.com/neovim/nvim-lspconfig ~/.config/nvim/pack/nvim/start/nvim-lspconfig
75+
cd C:/Users/<USER>/AppData/Local/nvim/pack/nvim/start
76+
git clone https://github.com/neovim/nvim-lspconfig
6077
```
6178

6279
#### Step 3: Configure Flix LSP in Neovim
6380

64-
Add the following minimal configuration along with essential key bindings to your `~/.config/nvim/init.lua`:
81+
Add the following minimal configuration to your `~/.config/nvim/init.lua`:
6582

6683
```lua
6784
local lspconfig = require("lspconfig")
6885
local configs = require("lspconfig.configs")
69-
local start_cmd = { "java", "-jar", "flix.jar", "lsp" } -- Replace with the actual path to your Flix jar
86+
-- Replace with the actual path to your Flix jar
87+
local start_cmd = { "java", "-jar", "flix.jar", "lsp" }
7088

7189
-- Set Flix as the filetype for *.flix files
7290
vim.filetype.add({
@@ -106,11 +124,39 @@ lspconfig.flix.setup({
106124
flags = {},
107125
})
108126
```
109-
#### Step 4: Validate the Configuration
110127

111-
When you open a `*.flix` file in Neovim (with `flix.jar` in the same directory), you should see the message “Flix LSP attached to buffer <buffer_number>” in the status line. This indicates that the language server is running correctly.
128+
If you are on Windows, the file should be stored at:
129+
130+
```shell
131+
C:/Users/<USER>/AppData/Local/nvim/init.lua
132+
```
133+
134+
You can verify that `nvim-lspconfig` and the Flix language server is installed
135+
correctly by running: `nvim` and then running the command `:LspInfo`.
136+
137+
#### Step 4: Programming with Flix with Neovim
138+
139+
You can now open any `*.flix` file provided that the Flix compiler jar
140+
(`flix.jar`) is located in the same directory as the Flix.
141+
142+
When you open a Flix, you should see message "Flix LSP attached to buffer
143+
<buffer_number>" in the status line. Moreover, the opened file should be syntax
144+
highlighted.
145+
146+
The default Flix LSP configuration includes the following keybindings:
112147

113-
At this stage, syntax highlighting and LSP features should function as expected. You can access all LSP functionalities using the predefined key bindings in normal mode, with `\` as the default leader key.
148+
| Keybinding | Action |
149+
|-----------------|-----------------------|
150+
| `gd` | Go to definition |
151+
| `gD` | Go to declaration |
152+
| `gi` | Go to implementation |
153+
| `gr` | Find references |
154+
| `gy` | Go to type definition |
155+
| `ctrl+x,ctrl+o` | Trigger auto-complete |
156+
| `shift+k` | Hover |
157+
| `<leader>rn` | Rename symbol |
158+
| `<leader>ca` | Code actions |
159+
| `<leader>e` | Show diagnostics |
114160

115161
### Using Flix from the Command Line
116162

0 commit comments

Comments
 (0)