-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #24 - Add context-aware prompting
Add initial context-aware prompt editing by writing simple scripts.
- Loading branch information
Showing
10 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
" Author: w0rp <[email protected]> | ||
" Description: Pre-processing rules for Go files. | ||
|
||
function! neural#pre_process#go#Process(buffer, input) abort | ||
let l:has_package = search('^package ', 'wnc') != 0 | ||
|
||
let a:input.prompt = 'Write golang code. ' | ||
\ . (l:has_package ? 'Do not write package main or main func. ' : '') | ||
\ . a:input.prompt | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
" Author: w0rp <[email protected]> | ||
" Description: Pre-processing rules for markdown files. | ||
|
||
function! neural#pre_process#markdown#Process(buffer, input) abort | ||
let a:input.prompt = 'Write text in a markdown file. ' | ||
\ . a:input.prompt | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Before: | ||
Save g:neural | ||
|
||
unlet! g:neural | ||
|
||
let g:input = {'prompt': 'Do something.'} | ||
call neural#config#Load() | ||
|
||
After: | ||
unlet! g:input | ||
|
||
Restore | ||
|
||
Given go(An empty Go file): | ||
Execute(It should be possible to disable pre-processing): | ||
let g:neural.pre_process.enabled = 0 | ||
|
||
call neural#PreProcess(bufnr(''), g:input) | ||
|
||
AssertEqual 'Do something.', g:input.prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Before: | ||
let g:input = {'prompt': 'Do something.'} | ||
call neural#config#Load() | ||
|
||
After: | ||
unlet! g:input | ||
|
||
Given go(An empty Go file): | ||
Execute(Basic Go prompt editing should be done): | ||
call neural#PreProcess(bufnr(''), g:input) | ||
|
||
AssertEqual 'Write golang code. Do something.', g:input.prompt | ||
|
||
Given go(A go file with a package declaration): | ||
package anything | ||
Execute(The prescence of a package should edit the prompt to not add a main function): | ||
call neural#PreProcess(bufnr(''), g:input) | ||
|
||
AssertEqual 'Write golang code. Do not write package main or main func. Do something.', g:input.prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Before: | ||
let g:input = {'prompt': 'Do something.'} | ||
call neural#config#Load() | ||
|
||
After: | ||
unlet! g:input | ||
|
||
Given markdown(An empty Markdown file): | ||
Execute(Basic Markdown prompt editing should be done): | ||
call neural#PreProcess(bufnr(''), g:input) | ||
|
||
AssertEqual 'Write text in a markdown file. Do something.', g:input.prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters