2023-02-03 14:07:17 +03:00
|
|
|
## LSP Features
|
|
|
|
|
|
|
|
When `nil` is invoked without arguments, it runs in the [LSP] mode.
|
|
|
|
Stdin and stdout are used for jsonrpc.
|
|
|
|
|
|
|
|
[LSP]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification
|
2022-09-22 19:09:41 +03:00
|
|
|
|
|
|
|
This incomplete list tracks noteble features currently implemented or planned.
|
|
|
|
|
|
|
|
- [x] Goto definition. `textDocument/definition`
|
|
|
|
- [x] References to parameters, `let` and `rec {}` bindings.
|
|
|
|
- [x] Relative paths.
|
2023-01-27 13:32:49 +03:00
|
|
|
- [x] Source of flake inputs, when cursor is on keys of `inputs` or
|
|
|
|
parameters of `outputs` lambda.
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Find references. `textDocument/reference`
|
|
|
|
- [x] Parameters, `let` and `rec {}` bindings.
|
|
|
|
- [x] With expression.
|
2022-11-27 19:40:58 +03:00
|
|
|
- [x] Highlight related. `textDocument/documentHighlight`.
|
|
|
|
- [x] Highlight definitions and references when cursor's on identifiers.
|
|
|
|
- [x] Highlight all (attribute) references when cursor's on `with`.
|
|
|
|
- [x] Highlight all effective `with`s when cursor's on attributes from `with`.
|
2022-11-09 22:24:59 +03:00
|
|
|
- [x] Links. `textDocument/documentLink`
|
|
|
|
- [x] Links for relative and absolute paths.
|
|
|
|
- [ ] Links for search paths like `<nixpkgs>`.
|
|
|
|
- [x] Links for URLs like `"https://..."`, `"http://..."` and etc.
|
|
|
|
- [x] Links for [flake references][flake-ref] like `"github:NixOS/nixpkgs"`.
|
|
|
|
|
2022-11-23 20:41:27 +03:00
|
|
|
- [x] Code actions. `textDocument/codeAction`
|
2023-02-24 19:38:56 +03:00
|
|
|
See [`docs/code_actions.md`](./code_actions.md) for the list of supported code actions.
|
2022-11-24 20:22:32 +03:00
|
|
|
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Completion. `textDocument/completion`
|
|
|
|
- [x] Builtin names.
|
|
|
|
- With documentations.
|
|
|
|
- [x] Local bindings and rec-attrset fields.
|
|
|
|
- [x] Keywords.
|
|
|
|
- [ ] Attrset fields.
|
2023-02-03 14:07:17 +03:00
|
|
|
- [x] If it can be inferenced in the local file.
|
|
|
|
- [x] Flake schema, including common inputs fields like `url` and
|
|
|
|
output fields like `outPath`.
|
|
|
|
- [ ] Real flake outputs from evaluation.
|
2023-04-03 20:38:11 +03:00
|
|
|
- [x] NixOS options.
|
|
|
|
Evaluated from the flake input named `nixpkgs`.
|
2023-02-03 14:07:17 +03:00
|
|
|
- [x] Pat-parameter definition.
|
|
|
|
- [x] Flake inputs in the parameter of `outputs`.
|
2022-11-23 20:41:27 +03:00
|
|
|
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Diagnostics. `textDocument/publishDiagnostics`
|
2022-11-25 18:41:09 +03:00
|
|
|
|
2023-03-03 20:53:52 +03:00
|
|
|
- [x] Syntax errors.
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Hard semantic errors reported as parse errors by Nix, like duplicated keys in attrsets.
|
2023-08-06 17:20:45 +03:00
|
|
|
- [x] Undefined names.
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Warnings of legacy syntax.
|
|
|
|
- [x] Warnings of unnecessary syntax.
|
|
|
|
- [x] Warnings of unused bindings, `with` and `rec`.
|
2023-03-03 21:24:44 +03:00
|
|
|
- [x] Warnings of unused parameters for packages, modules and flake output parameters.
|
2022-09-22 19:09:41 +03:00
|
|
|
- [ ] Client pulled diagnostics.
|
2022-11-25 18:41:09 +03:00
|
|
|
- [x] Custom filter on kinds.
|
|
|
|
- [x] Exclude files.
|
2022-09-25 18:33:55 +03:00
|
|
|
|
2022-11-25 18:41:09 +03:00
|
|
|
You can disable some diagnostic kinds or for some (generated) files via LSP configuration.
|
|
|
|
See [docs/configuration.md](./configuration.md) for more information.
|
2022-09-25 18:33:55 +03:00
|
|
|
|
2022-09-22 19:09:41 +03:00
|
|
|
- [x] Expand selection. `textDocument/selectionRange`
|
|
|
|
- [x] Renaming. `textDocument/renamme`, `textDocument/prepareRename`
|
|
|
|
- [x] Identifiers in parameters and bindings, from `let`, rec and non-rec attrsets.
|
|
|
|
- [x] Static string literal bindings.
|
|
|
|
- [x] Merged path-value binding names.
|
|
|
|
- [x] Names introduced by `inherit`.
|
|
|
|
- [x] Names used by `inherit`.
|
|
|
|
- [ ] Conflict detection.
|
|
|
|
- [x] Rename to string literals.
|
|
|
|
- [x] Semantic highlighting. `textDocument/semanticTokens/{range,full}`
|
|
|
|
- [ ] Delta response. `textDocument/semanticTokens/full/delta`
|
2022-11-30 16:25:43 +03:00
|
|
|
|
2023-05-20 01:21:10 +03:00
|
|
|
:warning: There is a known performance issue for semantic highlighting with
|
|
|
|
neovim native LSP. See more details in https://github.com/oxalica/nil/issues/83
|
|
|
|
|
2022-11-30 16:25:43 +03:00
|
|
|
Note: [`coc.nvim`] doesn't enable semantic highlighting by default.
|
|
|
|
You need to manually enable it in settings.
|
|
|
|
```jsonc
|
|
|
|
// coc-settings.json
|
|
|
|
{
|
|
|
|
"semanticTokens": { "filetypes": ["nix"] }
|
|
|
|
}
|
|
|
|
```
|
2022-09-22 19:09:41 +03:00
|
|
|
|
|
|
|
- [x] Hover text. `textDocument/hover`.
|
|
|
|
- [x] Show kind of names.
|
|
|
|
- [x] Documentation for builtin names.
|
2022-09-25 21:01:22 +03:00
|
|
|
- [x] File symbols with hierarchy (aka. outline). `textDocument/documentSymbol`
|
2022-09-26 10:53:04 +03:00
|
|
|
|
|
|
|
- [x] File formatting.
|
|
|
|
- [x] Whole file formatting.
|
|
|
|
- [ ] Range formatting.
|
|
|
|
- [ ] On-type formatting.
|
|
|
|
- [x] External formatter.
|
2022-11-25 18:41:09 +03:00
|
|
|
|
|
|
|
External formatter must be manually configured to work.
|
|
|
|
See [docs/configuration.md](./configuration.md) for more information.
|
|
|
|
|
|
|
|
When formatter is configured, you can also enable format-on-save in your editor.
|
|
|
|
Like, for [`coc.nvim`],
|
|
|
|
```jsonc
|
|
|
|
// coc-settings.json
|
|
|
|
{
|
|
|
|
"coc.preferences.formatOnSaveFiletypes": ["nix"]
|
|
|
|
}
|
|
|
|
```
|
2022-09-26 10:53:04 +03:00
|
|
|
|
2022-09-22 19:09:41 +03:00
|
|
|
- [ ] Cross-file analysis.
|
2022-09-27 16:08:24 +03:00
|
|
|
- [x] Multi-threaded.
|
|
|
|
- [x] Request cancellation. `$/cancelRequest`
|
2022-09-26 10:53:04 +03:00
|
|
|
|
|
|
|
[`coc.nvim`]: https://github.com/neoclide/coc.nvim
|
2022-11-09 22:24:59 +03:00
|
|
|
[flake-ref]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#types
|
2023-02-03 14:07:17 +03:00
|
|
|
|
|
|
|
## CLI Features
|
|
|
|
|
|
|
|
`nil` could also be invoked in command line.
|
|
|
|
You can run `nil --help` for usages of all available commands.
|
|
|
|
|
|
|
|
- `nil diagnostics <PATH>`
|
|
|
|
Check and print diagnostics for a file.
|
2023-06-12 01:31:37 +03:00
|
|
|
Exit with code `1` if there are any errors.
|
2023-02-03 14:07:17 +03:00
|
|
|
:warning: **WARNING**: The output format is for human and should not be relied on.
|