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

feat(cmp): add on_config_done callback #3589

Merged
merged 2 commits into from Dec 13, 2022

Conversation

mcartaud
Copy link
Contributor

@mcartaud mcartaud commented Dec 9, 2022

Description

User can use a on_config_done property in nvim-cmp config. It allow user to hook on the plugin and make additionnal configuration after the plugin is setup.

How has this been tested

  1. See that completion shows up when writing a commit for exemple
  2. Add
lvim.builtin.cmp.on_config_done = function(cmp)
  cmp.setup.filetype("gitcommit", {
    enabled = false,
  })
end

In the nvim config file
4. Reload LunarVim
5. Commit something in a repo and see that completion doesn't open

Signed-off-by: Mathieu Cartaud dev@mcartaud.com

@LostNeophyte
Copy link
Member

The enabled function is configurable so it's already possible

@LostNeophyte
Copy link
Member

The cmp.setup.filetypes may not be possible to set but i think having an on_config_done callback like with other plugins would be a better solution

@mcartaud
Copy link
Contributor Author

The enabled function is configurable so it's already possible

Ok, I though that it would be best to have this case available by configuration instead of by overriding all work done in the enabled function, because it might be harder to upgrade for the user if LunarVim code changes

The cmp.setup.filetypes may not be possible to set but i think having an on_config_done callback like with other plugins would be a better solution

I was not aware of this mechanism, will rework the PR

This allow user to customize nvim_cmp behavior after initialization.
For instance user can disable the completion on some filetypes

Signed-off-by: Mathieu Cartaud <dev@mcartaud.com>
@mcartaud mcartaud force-pushed the feat/disable-cmp-configuration branch from 7356a08 to a406162 Compare December 12, 2022 17:07
@mcartaud
Copy link
Contributor Author

This new version adds an on_config_done property on the cmp object and removes the configuration to disable cmp in comments

@LostNeophyte
Copy link
Member

LostNeophyte commented Dec 12, 2022

Is it ready for review? (it's a draft), oh and update the pr description and name if it is ready

@mcartaud mcartaud marked this pull request as ready for review December 12, 2022 17:20
Add an empty line at before the end of the cmp setup function

Co-authored-by: LostNeophyte <lostneophyte@tuta.io>
@mcartaud mcartaud changed the title feat(cmp): user can disable nvim-cmp in comments or by filetype feat(cmp): add an on_config_done property in nvim-cmp config Dec 12, 2022
@mcartaud
Copy link
Contributor Author

Thanks for the review

@LostNeophyte
Copy link
Member

Update the pr description and all looks good to me, i've never seen the checks take so long btw

@mcartaud
Copy link
Contributor Author

i've never seen the checks take so long btw

Yes, lot's of things to test in this review :)

It's all done, thanks

Copy link
Member

@LostNeophyte LostNeophyte left a comment

Choose a reason for hiding this comment

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

LGTM, thanks :)

Copy link
Collaborator

@kylo252 kylo252 left a comment

Choose a reason for hiding this comment

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

Thanks!

@kylo252 kylo252 changed the title feat(cmp): add an on_config_done property in nvim-cmp config feat(cmp): add on_config_done callback Dec 13, 2022
@kylo252 kylo252 merged commit f50e49a into LunarVim:master Dec 13, 2022
@mcartaud mcartaud deleted the feat/disable-cmp-configuration branch December 14, 2022 10:12
tomazursic pushed a commit to tomazursic/LunarVim that referenced this pull request Dec 15, 2022
* upstream/master:
  fix(config): fix typo in example configs (LunarVim#3611)
  feat(cmp): add on_config_done callback (LunarVim#3589)
  fix(lsp): add neocmake to skipped_servers (LunarVim#3597)
  fix(alpha): check height of the aplha window (LunarVim#3585)
  fix: only call theme's setup if it's selected (LunarVim#3586)
  chore: bump plugins version (LunarVim#3518)
  ci: restrict scheduled workflows to lunarvim (LunarVim#3591)
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.

None yet

3 participants