Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
devcontainer setup to make working on windows tolerable
  • Loading branch information
DanBradbury committed Mar 7, 2025
commit e93fbccefe861698441928544781065b4b53bc28
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:latest
RUN apk update && apk add git vim curl
RUN mkdir ~/.vim
RUN mkdir ~/.vim/bundle
RUN git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dockerFile": "Dockerfile",
"postStartCommand": "cp .devcontainer/vimrc ~/.vimrc && vim +PluginInstall +qall && cp -r * ~/.vim/bundle/copilot.vim/"
}
10 changes: 10 additions & 0 deletions .devcontainer/vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set nocompatible " be iMproved, required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'DanBradbury/copilot.vim'
call vundle#end() " required
filetype plugin indent on " required
8 changes: 1 addition & 7 deletions plugin/copilot.vim
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,4 @@ endif
let s:dir = expand('<sfile>:h:h')
if getftime(s:dir . '/doc/copilot.txt') > getftime(s:dir . '/doc/tags')
silent! execute 'helptags' fnameescape(s:dir . '/doc')
endif

" Source the copilot_chat.vim file
source /Users/bradbd/Documents/Github/copilot.vim/copilot_chat.vim

" Add key mapping to open Copilot Chat
nnoremap <leader>cc :CopilotChat<CR>
endif
18 changes: 14 additions & 4 deletions copilot_chat.vim → plugin/copilot_chat.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
let s:plugin_dir = expand('<sfile>:p:h')
let s:token_file = s:plugin_dir . '/copilot_token'

function! CopilotChat()
" Open a new split window for the chat
split
Expand Down Expand Up @@ -64,10 +67,11 @@ function! GetBearerToken()
let l:curl_cmd .= '-H "' . header . '" '
endfor
let l:curl_cmd .= "-d '" . l:token_data . "' " . l:token_url
echom l:curl_cmd

" Execute the curl command
let l:response = system(l:curl_cmd)
echom 'Response: ' . l:response
exit(1)

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

" Execute the curl command
let l:response = system(l:curl_cmd)
echom l:response
echo l:response

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

function! CheckDeviceToken()
endfunction

function! CopilotAPIRequest(message)
" Replace with actual API call logic
"CheckDeviceToken()
let l:url = 'https://api.githubcopilot.com/chat/completions'
if exists('$COPILOT_BEARER_TOKEN')
let l:bearer_token = $COPILOT_BEARER_TOKEN
Expand Down Expand Up @@ -227,4 +234,7 @@ command! CopilotChat call CopilotChat()
command! SubmitChatMessage call SubmitChatMessage()

" Add key mapping to submit chat message
nnoremap <buffer> <leader>cs :SubmitChatMessage<CR>
nnoremap <buffer> <leader>cs :SubmitChatMessage<CR>

" Add key mapping to open Copilot Chat
nnoremap <leader>cc :CopilotChat<CR>