nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

LSP keymaps should use keymap-helpers submodule

Open MattSturgeon opened this issue 1 year ago • 7 comments

Description

The documentation for LSP keymappings is a little vague when it comes to non-string attributes.

Looking into the code, it appears that an LSP keymapping can be either a simple "action" string, or an attribute set following the same shema as keymaps (without key, because that is inferred from the attribute key).

This could be improved by making use of the option submodules defined in lib/keymap-helpers.nix, perhaps refactoring them slightly to produce a "named" and "unnamed" variant, where only the unnamed variant has a key attribute.

If LSP keymaps have less in common with mapOptionSubmodule than I assumed, then perhaps they should get their own lspMapOptionSubmodule instead of simply a "named" variant.

By having the lsp keymap options be type attrsOf (either str helpers.keymaps.namedMapOptionSubmodule) we will get better documentation for free, as well as improved type-safety.

Alternatively, rather than lsp keymaps being an attribute set, perhaps they should be a list for consistency with keymaps?

Additionally, the description for lspBuf & diagnostic could better convey what is supported, and the usage examples could include more complex examples.

MattSturgeon avatar Feb 25 '24 01:02 MattSturgeon