Closed bbigras closed 3 weeks ago
I'd highly recommend that you use gptel instead, it's much better:
I'd highly recommend that you use gptel instead, it's much better:
I'm already using it with vanilla emacs. I think it doesn't support the autocomplete thing that copilot does.
If you put (use-package! copilot)
in your packages.el
, replace that with (package! copilot)
.
(That's true for Doom, not just Unstraightened. Doing something unexpected in packages.el
may sort of work in Doom, but it will not work in Unstraightened: Unstraightened evaluates packages.el
in Nix's build sandbox to figure out what you want to install (so it can then use Nix to actually build and install it), which is a much more restrictive environment than doom sync
runs in.)
The latter builds on my machine, but there is one issue: Unstraightened isn't picking up its autoload file (meaning things like copilot-complete
are not defined). Adding (use-package! copilot)
to your config.el
(in addition to changing packages.el
, not instead of it) should eagerly load copilot, which is not ideal but should make its commands available. Manually loading copilot-autoloads.el would also work (with less eager loading).
(copilot.el
's install instructions look like they will work, but I'd suggest leaving out the :recipe ...
bit. That's not currently causing a build failure if included but it probably should unless you add a pin, hmm...)
I'll have a look to see if I can pick up its autoload file without having to do something copilot-specific...
If this does not solve your problem, please share your doomdir (or a minimal doomdir demonstrating the problem).
it seems to work with (package! copilot)
in packages.el and this:
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
in config.el
.
Thank you very much!
btw I got this error now copilot--start-agent: Could not find node executable
, but it might be while using :tools direnv
and it might be a doom-emacs issue.
Can I do something like this?
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word))
:config ''
(setq copilot-node-executable "${pkgs.nodejs}/bin/node")
''
)
If you're using nix run .#doom-emacs
(not home-manager or overlay), running nix shell nixpkgs#nodejs
(or something similar) first to get nodejs on your shell seems like the fastest workaround.
If you're using Unstraightened's home-manager or overlay setup, I should probably give you a way of adding additional binaries to the $PATH
Doom runs with. (I'm currently not forcing things like rg
and fd
into Doom's PATH, been meaning to fix that...)
If I let you do something like extraBins = [ pkgs.nodejs ];
in Unstraightened's home-manager or overlay setup, would that be useful?
You could also make your suggestion work, but it gets a little fiddly (and exactly how you'd do it depends on how much ELisp you're comfortable having in Nix strings). Something like this should work:
doomDir = pkgs.symlinkJoin {
name = "doomdir";
paths = [
(pkgs.writeTextDir "config.el" ''
;; config.el, as in your comment
'')
./path/to/the/rest/of/your/doomdir
];
};
...but to avoid having an unwieldy amount of Lisp in Nix strings, you might prefer using concatTextFile
or substitute
so you can keep the Lisp in a separate file. I'd expect there to be examples of this sort of thing out there, but I'm not really sure where to point you for them, sorry!
I'd highly recommend that you use gptel instead, it's much better: https://github.com/karthink/gptel
I'm already using it with vanilla emacs. I think it doesn't support the autocomplete thing that copilot does.
The author of gptel is adding the copilot functionality to gptel, but I am not sure if he's going to add the autocomplete functionality, I'm pretty sure he will at some point. I am using the open source gpt4all, and I am very happy with it.
I am not sure if he's going to add the autocomplete functionality, I'm pretty sure he will at some point.
The autocomplete thing is very useful to me, so far.
https://news.ycombinator.com/item?id=40617082 was posted today and there's also 3 similar tools in the comments.
I wish there was something for emacs packages like https://github.com/NixOS/nixpkgs/blob/1729f1a7a900cd285b42db9c158da7a581ca407a/pkgs/build-support/rust/default-crate-overrides.nix is for rust.
The emacs-init home-manager module has a similar feature https://gitlab.com/rycee/nur-expressions/-/blob/7e3ce9990c382947c33f0def2a1c33c420d8c710/hm-modules/emacs-init-defaults.nix. Which is awesome and work great, but you need to define your emacs config in a nix file:
{
all-the-icons-dired = {
enable = pkgs.stdenv.hostPlatform.system == "x86_64-linux";
after = [
"dired"
"all-the-icons"
];
hook = [ "(dired-mode . all-the-icons-dired-mode)" ];
};
}
Being able to do stuff like enable = pkgs.stdenv.hostPlatform.system == "x86_64-linux"
is awesome, but the downside is that you can't just copy paste some config snippet you found online.
I've added an extraBinPackages
setting in c61cd622b7abb2de838c41d99cc9a0b1e4506917. This can be used to add things like node
to the binary search path (if they're not on your default $PATH
already).
Although I'm considering exposing the init.el
generator I'm already using in tests (which converts { lang.rust = true; lang.nix = [ "+lsp" ] }
in Nix to (doom! :lang rust (nix +lsp))
, more or less, and could be used for conditionally enabling Doom modules in a home-manager config), and I'm open to adding more ways of passing paths / packages / etc from Nix into Doom (suggestions on how to approach this appreciated), I'm not currently planning to add more extensive support for configuring Doom in Nix. In particular, I feel that generating a Doom config.el
would likely either turn into an entire configuration framework on top of Doom, or be too limited to be of much use.
With that, I think Unstraightened now supports Copilot about as well as Doom itself does, so I'm closing this issue.
The latter builds on my machine, but there is one issue: Unstraightened isn't picking up its autoload file (meaning things like
copilot-complete
are not defined). ... I'll have a look to see if I can pick up its autoload file without having to do something copilot-specific...
I'd almost forgetten about this problem, but it is now fixed (by fa6fe4cf937e25dfcf1a44bd4d69ecbca280a85f).
(use-package! copilot)
emacsPackages.copilot exits.
Is
"No such file or directory" "git"
the error?