Copilot for micro [wip]
iGio90 opened this issue · comments
Hi.
I started 2 days ago to check micro (never hear about it before) because i wanted to prepare my android phone to perform some small development.
I came across micro with plugin filemanager which is the unique (i think) text editor with a file picker and also split views.
Immediately felt the need to have copilot as in my daily setup.
I created this plugin which is an initial idea.
https://gist.github.com/iGio90/f6f7c60bad824ae469cf65f9280ee493
the logic is:
- when a new character is added and its placed at the end of the line, we build a context which consist of all function signatures from opened files + the whole function body of the current function we are in
- we push the context to copilot and get the response
- the completion suggestion is added in the so called info bar
- there is a key binding to add the result straight
This code has been built by 99% from chatgpt as i never wrote a line of lua in my entire life. (We can discuss in other channels about the choice of using this language xD)
Anyway, im not really happy about it. I asked chatgpt to make it async, it gave me some output which doesn't look to work, but its an initial solution.
Im sharing the code on a gist in the hope that someone with better experience with lua can jump in and help with the development.
How to use it, since currently the whole login part is missing.
- pull this repo https://github.com/B00TK1D/copilot-api
- run the
api.py
and follow instruction to login - after login, a file named
.copilot_token
is created in the same dir - create a folder
~/.config/micro/plug/copilot
and move inside the .copilot_token and the content of my gist saved to copilot.lua - download https://github.com/rxi/json.lua/blob/master/json.lua and save it as well to
~/.config/micro/plug/copilot
the plugin will perform the api call through curl (chatgpt told me there is no proper way with lua to perform http request so it just used shell + curl) on each rune added at the end of line, it will display the hint and give you ability to apply it
i just realized i can use go net for performing request in a better way. Currently it is very limited to my current env. Im looking for some examples around.
(please comment the downvote, dont just downvote)
I'm not sure what the problem is (or if there even is one). Maybe this should have been posted in discussions?
yes! you are right.
Not an issue, was just looking for a place to discuss about this and get suggestion.
didn't noticed there is discussion tab and tbh is the first time i see one.
will move it there :)
thanks