Skip to content
New issue

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

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

Already on GitHub? # to your account

Add a working copilot plugin. #691

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

anicolao
Copy link

@anicolao anicolao commented Mar 7, 2025

The copilot-lua plugin that is included with nvf doesn't work at all for me, while the official plugin works excellently. Add a "copilot" option so that users can use the official plugin if they like.

Also fix a typo reported by me as a bug in the npins JSON because without that fix the npins doesn't work.

@anicolao anicolao requested a review from NotAShelf as a code owner March 7, 2025 05:04
@anicolao anicolao mentioned this pull request Mar 7, 2025
1 task
@NotAShelf
Copy link
Owner

There is no need to modify the pins here if we are not adding a module. nvf provides an extra plugins API that you can use to install and configure plugins without relying on upstream (us.) I would encourage using said API, or refactoring to also include a module.

Note that I am not too keen on vimscript plugins. copilot.vim is very slow, and is not designed with modern setups in mind. Copilot.lua is supposed to be feature complete, but if I recall correctly the author was not able to work on bugfixes. Perhaps there is a fork that we can use?

P.S. the npins bug should be fixed with 414c922

@anicolao
Copy link
Author

anicolao commented Mar 7, 2025

There is no need to modify the pins here if we are not adding a module. nvf provides an extra plugins API that you can use to install and configure plugins without relying on upstream (us.) I would encourage using said API, or refactoring to also include a module.

Note that I am not too keen on vimscript plugins. copilot.vim is very slow, and is not designed with modern setups in mind. Copilot.lua is supposed to be feature complete, but if I recall correctly the author was not able to work on bugfixes. Perhaps there is a fork that we can use?

I couldn't figure out how to use extraPlugins from the documentation. The example reads

    config.vim.extraPlugins = with pkgs.vimPlugins; {                             
      aerial = {                                                                  
        package = aerial-nvim;                                                    
        setup = "require('aerial').setup {}";                                     
      };                                                                          
                                                                                  
      harpoon = {                                                                 
        package = harpoon;                                                        
        setup = "require('harpoon').setup {}";                                    
        after = ["aerial"]; # place harpoon configuration after aerial            
      };                                                                          
    }     

and I failed to find any information on how to define a copilot-nvim at the user level that could be used as the package parameter and point at github the way the pin does (or some other way). I did spend a few hours on that approach before giving up and using the npins approach which even with the bug that I stumbled upon while doing it took me only about 45m to figure out and test.

There's an additional problem with this PR that I realized when I woke up this morning though which is that it depends on nodejs being in the user's environment. I don't know how/where to indicate that if the user uses this plugin nodejs should be included in the resulting neovim dependencies so that it comes from there rather than from the user's system.

Maybe we can fix the documentation instead so that I could understand how to use extraPlugins directly; I'm a complete nix n00b and find the existing documentation pretty much impenetrable in spite of all the great effort that has been put in to make it easy/well documented.

@NotAShelf
Copy link
Owner

In this example:

config.vim.extraPlugins = with pkgs.vimPlugins; {                             
      aerial = {                                                                  
        package = aerial-nvim;                                                    
        setup = "require('aerial').setup {}";                                     
      };                                                                          
                                                                                  
      harpoon = {                                                                 
        package = harpoon;                                                        
        setup = "require('harpoon').setup {}";                                    
        after = ["aerial"]; # place harpoon configuration after aerial            
      };                                                                          
    }     

the packages are acquired from the with scope. E.g. package = harpoon is package = pkgs.vimPlugins.harpoon. In hindsight this is a very confusing example, because with scopes are confusing by default. Perhaps I'll document using npins in your own configuration, but first it is worth clearing where the packages come from.

Looking at it now, neither copilot plugin seems to be packaged in Nixpkgs. You could request that they're packaged, but it is also possible that we add a module instead. Then again, I am not a huge fan of LLM companions and especially not a fan of Vimscript plugins.

@anicolao
Copy link
Author

anicolao commented Mar 7, 2025

#609

looks relevant. It isn't the with that was confusing, it was where/how to fetch the plugin from github, which is from my PoV what npins is doing for me, setting up a configuration that enables nvf to find the plugin. I can find no similar example in the documentation for how to do it. Possibly I can get it to go after reading that discussion more thoroughly.

I shoudl perhaps be 100% clear that I tried initially to use the "assistant" module to enable copilot, but aside from the fact that it dragged in a super irritating copilot-cmp configuration that I don't want, it also didn't work at all. Probably I configured it wrong. I could file a separate issue for that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants