# Is anyone interested in writing Github Copilot plugin?

**URL:** <https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131>\
**Category:** Plugins\
**Created:** [September 26, 2022, 8:32pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131 "2022-09-26T20:32:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 26, 2022, 8:32pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/1 "2022-09-26T20:32:29Z")

</div>

It really helps a lot:

![](https://discuss.kakoune.com/uploads/default/original/2X/1/185a317132a078d06d9194d9cd97144a6939c423.gif)

there is an official vim plugin:

[https://github.com/github/copilot.vim](https://github.com/github/copilot.vim)

and, an unofficial emacs plugin:

[https://github.com/zerolfx/copilot.el](https://github.com/zerolfx/copilot.el)

I want to implement it in kakoune, but have absolutely no clue.

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 26, 2022, 8:41pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/2 "2022-09-26T20:41:53Z")

</div>

Sublime Plugin: [GitHub - TheSecEng/LSP-copilot: GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.](https://github.com/TheSecEng/LSP-copilot)

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 26, 2022, 8:55pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/3 "2022-09-26T20:55:25Z")

</div>

I’ve been using Kakoune for over 1 week now and I really like various aspects of Kakoune, but I can’t really stand not having copilot.

Maybe I’ll just have to change to neovim for now …

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 26, 2022, 9:19pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/4 "2022-09-26T21:19:23Z")

</div>

Pure Lua plugin: [GitHub - zbirenbaum/copilot.lua: Lua plugin for starting and interacting with github copilot](https://github.com/zbirenbaum/copilot.lua)

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 27, 2022, 4:41am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/5 "2022-09-27T04:41:58Z")

</div>

Does anyone know how to implement it in kakoune? I need some outline style guides…

---

<div class="post-metadata">

**Author:** ![JJK96](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jjk96/32/305_2.png) [@JJK96](https://discuss.kakoune.com/u/JJK96)\
**Post date:** [September 27, 2022, 4:58pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/6 "2022-09-27T16:58:44Z")

</div>

Usually the process for implementing a more complex plug-in in kakoune is to write a command-line program that does the functionality and interface kakoune with the program using named pipes.  
So writing (or finding) a command-line program that does the heavy lifting will probably be most of the way!

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 27, 2022, 5:08pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/7 "2022-09-27T17:08:45Z")

</div>

Thanks! I learned how to write a basic kakoune plugin, I really like it’s simple concepts, I even wrote one: [GitHub - theowenyoung/kakoune-buffer-manager: Managing Buffers within the file, support multiple selections, delete buffers, open buffers](https://github.com/theowenyoung/kakoune-buffer-manager/) , but copilot is another level for me. cause it need to handle login github service, and start a local agent to communicate with github service and text editor.

should I try to a kak-lsp compatible language server for this? or I don’t have to?

---

<div class="post-metadata">

**Author:** ![JJK96](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jjk96/32/305_2.png) [@JJK96](https://discuss.kakoune.com/u/JJK96)\
**Post date:** [September 27, 2022, 8:35pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/8 "2022-09-27T20:35:40Z")

</div>

You should handle all the tricky stuff and communication with github copilot in a command-line program written in your favorite programming language. Then on the kakoune side, it will be similar to kakoune-snippets, I think, where the snippets will be provided by your commandline program.

---

<div class="post-metadata">

**Author:** ![JJK96](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jjk96/32/305_2.png) [@JJK96](https://discuss.kakoune.com/u/JJK96)\
**Post date:** [September 27, 2022, 9:07pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/9 "2022-09-27T21:07:19Z")

</div>

I’ve looked a bit at other plugins, and I think writing a language server is indeed a good idea, if that works, you don’t need a kakoune plugin at all!

I think this file in copilot.vim is in fact already the language server implementation [copilot.vim/agent.js at release · github/copilot.vim · GitHub](https://github.com/github/copilot.vim/blob/release/copilot/dist/agent.js)

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 27, 2022, 9:21pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/10 "2022-09-27T21:21:18Z")

</div>

Thanks! then I need to learn more about @krobelus kak-lsp, to figure out how to build it.

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [September 29, 2022, 3:46am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/11 "2022-09-29T03:46:35Z")

</div>

VSCode supports running multiple language servers in a single file. [This issue](https://github.com/kak-lsp/kak-lsp/issues/17) tracks how we can add that feature to kak-lsp. We might be able to write a special language server that merely acts as a proxy to multiple language servers. That would be usable in any editor.

Anyway that’s not needed for basic Copilot support. It would be nice if there was a generic Copilot language server (maybe there is one?) then there is no extra work

---

<div class="post-metadata">

**Author:** ![krobelus](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/krobelus/32/616_2.png) [@krobelus](https://discuss.kakoune.com/u/krobelus)\
**Post date:** [September 29, 2022, 3:47am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/12 "2022-09-29T03:47:55Z")

</div>

VSCode supports running multiple language servers in a single file. [This issue](https://github.com/kak-lsp/kak-lsp/issues/17) tracks how we can add that feature to kak-lsp. We might be able to write a special language server that merely acts as a proxy to multiple language servers. That would be usable in any editor.

Anyway that’s not needed for basic Copilot support. It would be nice if there was a generic Copilot language server (maybe there is one?) then it is trivial to integrate it with kak-lsp.

---

<div class="post-metadata">

**Author:** ![theowenyoung](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/theowenyoung/32/1117_2.png) [@theowenyoung](https://discuss.kakoune.com/u/theowenyoung)\
**Post date:** [September 29, 2022, 2:39pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/13 "2022-09-29T14:39:26Z")

</div>

neovim also supports multiple lsp. but it seems [GitHub - github/copilot.vim: Neovim plugin for GitHub Copilot](https://github.com/github/copilot.vim) and [GitHub - zerolfx/copilot.el: An unofficial Copilot plugin for Emacs.](https://github.com/zerolfx/copilot.el) , both of them are not using lsp.

only [GitHub - TheSecEng/LSP-copilot: GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.](https://github.com/TheSecEng/LSP-copilot) is using lsp.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [October 13, 2022, 12:11am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/14 "2022-10-13T00:11:06Z")

</div>

I’m super down for a kakoune copilot plugin!  
Would love to try it on my favorite editor

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [October 13, 2022, 12:32am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/15 "2022-10-13T00:32:56Z")

</div>

> <https://github.com/TerminalFi/LSP-copilot/commit/7526bfaec4dd7256742fb01ec339ae02a9cb4efe#diff-dd55ebe7130b5ef2b6957736e71042a94289d14f1e7381098824836413a18597>

Reading the first POC commit of LSP-copilot helps understand how to communicate with it [copilot-node-server](https://www.npmjs.com/package/copilot-node-server) used by copilot.vim and LSP-copilot

---

<div class="post-metadata">

**Author:** ![ewintr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ewintr/32/1153_2.png) [@ewintr](https://discuss.kakoune.com/u/ewintr)\
**Post date:** [December 19, 2022, 1:30pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/16 "2022-12-19T13:30:59Z")

</div>

There might be an easier way to go about it. At least for now.

Copilot is powered by Openai’s Codex. Openai also offers a playground and an API that both give access to Codex. So it is possible to write a simple commandline client that calls Codex directly and integrate that in Kakoune, simply sidestepping GitHub.

The API to Codex is what they call in “Limited beta” so it is not clear if they will keep offering it. It is also not free, but neither is Copilot.

Codex: [OpenAI API](https://beta.openai.com/docs/models/codex)  
API: [OpenAI API](https://beta.openai.com/docs/guides/code)

---

<div class="post-metadata">

**Author:** ![ebetica](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ebetica/32/1171_2.png) [@ebetica](https://discuss.kakoune.com/u/ebetica)\
**Post date:** [March 23, 2023, 8:19pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/17 "2023-03-23T20:19:52Z")

</div>

I found a go CLI client for ChatGPT that works pretty well:

> **[GitHub - verdverm/chatgpt: ChatGPT CLI, interactive or file based sessions...](https://github.com/verdverm/chatgpt)**
>
> ChatGPT CLI, interactive or file based sessions with context and moods. - GitHub - verdverm/chatgpt: ChatGPT CLI, interactive or file based sessions with context and moods.

Then, if you install it, you can just pipe to it. For writing code, the -c models seem to be overloaded a lot, but maybe if it’s not you can use it. Normal chatgpt3.5 works pretty well. I have leader-c mapped to replace the code, leader-q to open a clippy with some prompt engineering to form it as a question, and leader-r to resample the text.

```auto
map global user -docstring "Replace selection with chatgpt's answer" c '<a-|>tee /tmp/chatgpt.txt<ret>| cat /tmp/chatgpt.txt | chatgpt -x<ret>'
map global user -docstring "Resample the last question with chatgpt" r '|cat /tmp/chatgpt.txt | chatgpt -x<ret>'
map global user -docstring "Ask chatgpt about the selection!" q '<a-|>(tee /tmp/chatgpt.txt; echo "\nWhat is this?" >> /tmp/chatgpt.txt)<ret>:info -title "chatgpt" "%sh{cat /tmp/chatgpt.txt | chatgpt -x}"<ret>'

```

---

<div class="post-metadata">

**Author:** ![ewintr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ewintr/32/1153_2.png) [@ewintr](https://discuss.kakoune.com/u/ewintr)\
**Post date:** [March 25, 2023, 10:21am UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/18 "2023-03-25T10:21:05Z")

</div>

I read this just on the day that I was going to attempt to write it myself. Now I don’t need to anymore. Thanks!

---

<div class="post-metadata">

**Author:** ![TeddyDD](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/teddydd/32/21_2.png) [@TeddyDD](https://discuss.kakoune.com/u/TeddyDD)\
**Post date:** [March 29, 2023, 12:55pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/19 "2023-03-29T12:55:11Z")

</div>

I’m testing [GitHub - j178/chatgpt: Interactive CLI for ChatGPT](https://github.com/j178/chatgpt) with gpt-3.5 model, pretty cool I can just pipe text straight from buffer 😃

---

<div class="post-metadata">

**Author:** ![JacobTravers](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jacobtravers/32/848_2.png) [@JacobTravers](https://discuss.kakoune.com/u/JacobTravers)\
**Post date:** [April 26, 2023, 9:40pm UTC](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131/20 "2023-04-26T21:40:35Z")

</div>

I’ve been using a nice combination of [kakpipe](https://github.com/eburghar/kakpipe) and [heygpt](https://github.com/fuyufjh/heygpt) for this, here’s an example using [cork.kak](https://github.com/topisani/cork.kak)

```auto
cork kakpipe https://github.com/eburghar/kakpipe %{ require-module kakpipe }

define-command hey -docstring "
  hey <query>: heygpt utility wrapper
  Query ChatGPT and stream the response in a FIFO buffer
" -params 1.. %{
  kakpipe -w -n hey-response -- heygpt %arg{@};
}

```

this works nicely with expansions:

```auto
:hey explain this code: %val{selection}
:hey create jsdoc comments for this code: %val{selection}
:hey refactor this code using async/await: %val{selection}

```

I also have this block in my config to create a buffer for iterating and sending prompts:

```auto
define-command hey-buffer -docstring "
  opens a *hey-prompt* buffer for writing queries to pass to hey
" %{
  edit -scratch *hey-prompt*
  set-option buffer filetype hey-prompt
}
define-command hey-buffer-write -docstring "
  send the *hey-prompt* buffer to hey
" -hidden %[
  buffer *hey-prompt*
  execute-keys '%: hey %val{selection} <ret>'
]
hook global BufSetOption filetype=hey-prompt %{
  alias buffer write hey-buffer-write
  alias buffer w hey-buffer-write
}

```

[Next page](https://discuss.kakoune.com/t/is-anyone-interested-in-writing-github-copilot-plugin/2131.md?page=2)
