Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/lsp: migrate to mkNeovimPlugin #2700

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

HeitorAugustoLN
Copy link
Member

  • Migrated LSP to mkNeovimPlugin
  • Added support for setting mode in non-extra lsp keymaps

It should probably be fine, since I didn't change anything besides support for mode

@HeitorAugustoLN HeitorAugustoLN marked this pull request as ready for review December 17, 2024 18:43
@HeitorAugustoLN HeitorAugustoLN force-pushed the lsp-migrate branch 2 times, most recently from 9225cec to f07663d Compare December 17, 2024 19:01
Comment on lines +33 to +34

inherit (lib) mkOption types;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inherit (lib) mkOption types;
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) mkOption types;

Just at a glance, this will allow you to get rid of lib.nixvim. in this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is more than that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favour of inheriting anything that is used a lot. I'm not against being explicit, but defaultNullOpts for example gets used a ton.

Comment on lines +144 to +147
preConfig = mkOption {
type = types.lines;
description = "Code to be run before loading the LSP. Useful for requiring plugins";
default = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if preConfig and postConfig can be rename-alias modules pointing to lubConfig.pre and luaConfig.post respectively?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could, but it would need a little refactor

];
default = [ ];
lspBuf = mkOption {
type = with types; attrsOf (either str (attrsOf anything));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we can a) use type coercion to reduce the post-processing and b) use our standard lib.nixvim.keymaps.mapOptionSubmodule for increased consistency.

We may need to extend mapOptionSubmodule to support key defaulting to the attr-name though.

I'm thinking something like

type = coercedTo str (action: {inherit action;}) mapOptionSubmodule;

(Although we'd actually need to use the map-option submodule factory to produce a slightly customised type)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but I don't know if it would be possible to make it backwards-compatible. But if it is not a problem, then I think this is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When migrating plugins to mkNeovimPlugin it's acceptable to introduce some breaking changes. You can mark the old option as removed with instructions on how to migrate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can mark the old option as removed with instructions on how to migrate

This only really applies when the new option has a different name/location.

If the old "removed" option has the same name as the new option that doesn't work.

In this case, I think we can do a migration without breaking changes. But since the option isn't being renamed, it can wait until after this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I meant for options that we move from the top-level to settings, but if this option does not move then there's not much we can do

@HeitorAugustoLN HeitorAugustoLN force-pushed the lsp-migrate branch 2 times, most recently from fd103de to 73d5833 Compare December 24, 2024 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants