Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,71 @@ Note when in a nimble project, `nimble` will drive the entry points for `nimsugg
- `nim.nimsuggestIdleTimeout` - the timeout in ms after which an idle `nimsuggest` will be stopped. If not specified the default is 120 seconds.
- `nim.useNimCheck` - use `nim check` instead of `nimsuggest` for linting. Defaults to `true`.
- `nim.maxNimsuggestProcesses` - the maximum number of `nimsuggest` processes to keep alive. 0 means unlimited. If not specified the default is 0.

### Inlay Hints

Inlay hints are visual snippets displayed by the editor inside your code.

Typical usage for inlay hints is displaying type information but it can go beyond that and provide all sorts of useful context.

nimlangserver offers three kinds of inlay hints:
- **Type hints**. Show variable types.
- **Parameter hints**. TODO
- **Exception hints**. Highlight functions that raise exceptions.

Here's how inlay hints look like in VSCode
- type hint: ![](./vscode_type_hint.png)
- exception hint: ![](./vscode_exception_hint.png)

Here are the same hints in Helix:
- ![](./helix_type_hint.png)
- ![](./helix_exception_hint.png)


In VSCode, inlay hints are enabled by default. You can toggle different kinds of hints in the settings:

1. Go to **Settings**.
2. Search **inlay**.
3. Go to **Nim configuration**.

![](./vscode_settings.png)

To enable inlay hints in Neovim, configure lspconfig in your `init.vim`:

```lua
lua << EOF

lspconfig.nim_langserver.setup({
settings = {
nim = {
inlayHints = {
typeHints = true,
parameterHints = true,
exceptionHints = true,
}
}
},

-- Enable hints on LSP attach
on_attach = function(client, bufnr)
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
end
})

EOF
```

In Vim, use the coc configuration to enable inlay hints (see [VIM/Neovim](#vimneovim)).

To enable inlay hints in Helix, add this langserver configuration to your `languages.toml` (you can toggle different hint kinds individually):

```toml
[language-server.nimlangserver.config.nim]
inlayHints = { typeHints = true, parameterHints = true, exceptionHints = true }
```

## Features

`nimlangserver` supports the following LSP features:
Expand Down
Binary file added helix_exception_hint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added helix_type_hint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode_exception_hint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode_type_hint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.