Skip to content

Commit e93fbcc

Browse files
committed
devcontainer setup to make working on windows tolerable
1 parent e87b231 commit e93fbcc

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM alpine:latest
2+
RUN apk update && apk add git vim curl
3+
RUN mkdir ~/.vim
4+
RUN mkdir ~/.vim/bundle
5+
RUN git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"dockerFile": "Dockerfile",
3+
"postStartCommand": "cp .devcontainer/vimrc ~/.vimrc && vim +PluginInstall +qall && cp -r * ~/.vim/bundle/copilot.vim/"
4+
}

.devcontainer/vimrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set nocompatible " be iMproved, required
2+
filetype off " required
3+
4+
" set the runtime path to include Vundle and initialize
5+
set rtp+=~/.vim/bundle/Vundle.vim
6+
call vundle#begin()
7+
Plugin 'VundleVim/Vundle.vim'
8+
Plugin 'DanBradbury/copilot.vim'
9+
call vundle#end() " required
10+
filetype plugin indent on " required

plugin/copilot.vim

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,4 @@ endif
111111
let s:dir = expand('<sfile>:h:h')
112112
if getftime(s:dir . '/doc/copilot.txt') > getftime(s:dir . '/doc/tags')
113113
silent! execute 'helptags' fnameescape(s:dir . '/doc')
114-
endif
115-
116-
" Source the copilot_chat.vim file
117-
source /Users/bradbd/Documents/Github/copilot.vim/copilot_chat.vim
118-
119-
" Add key mapping to open Copilot Chat
120-
nnoremap <leader>cc :CopilotChat<CR>
114+
endif
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
let s:plugin_dir = expand('<sfile>:p:h')
2+
let s:token_file = s:plugin_dir . '/copilot_token'
3+
14
function! CopilotChat()
25
" Open a new split window for the chat
36
split
@@ -64,10 +67,11 @@ function! GetBearerToken()
6467
let l:curl_cmd .= '-H "' . header . '" '
6568
endfor
6669
let l:curl_cmd .= "-d '" . l:token_data . "' " . l:token_url
67-
echom l:curl_cmd
6870

6971
" Execute the curl command
7072
let l:response = system(l:curl_cmd)
73+
echom 'Response: ' . l:response
74+
exit(1)
7175

7276
" Check for errors in the response
7377
if v:shell_error != 0
@@ -141,7 +145,7 @@ function! GetChatToken()
141145

142146
" Execute the curl command
143147
let l:response = system(l:curl_cmd)
144-
echom l:response
148+
echo l:response
145149

146150
" Check for errors in the response
147151
if v:shell_error != 0
@@ -154,8 +158,11 @@ function! GetChatToken()
154158
return l:json_response.token
155159
endfunction
156160

161+
function! CheckDeviceToken()
162+
endfunction
163+
157164
function! CopilotAPIRequest(message)
158-
" Replace with actual API call logic
165+
"CheckDeviceToken()
159166
let l:url = 'https://api.githubcopilot.com/chat/completions'
160167
if exists('$COPILOT_BEARER_TOKEN')
161168
let l:bearer_token = $COPILOT_BEARER_TOKEN
@@ -227,4 +234,7 @@ command! CopilotChat call CopilotChat()
227234
command! SubmitChatMessage call SubmitChatMessage()
228235

229236
" Add key mapping to submit chat message
230-
nnoremap <buffer> <leader>cs :SubmitChatMessage<CR>
237+
nnoremap <buffer> <leader>cs :SubmitChatMessage<CR>
238+
239+
" Add key mapping to open Copilot Chat
240+
nnoremap <leader>cc :CopilotChat<CR>

0 commit comments

Comments
 (0)