You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor!: centralize sticky prompt and selection handling
This refactoring improves the CopilotChat plugin's state management by:
- Adding `insert_sticky` function to centralize sticky prompt management
- Creating `set_selection` to provide a cleaner API for selection handling
- Consolidating highlight management in `update_highlights`
- Standardizing function signatures and return values
- Improving `Chat:set_prompt` functionality
- Removing redundant code for better maintainability
BREAKING CHANGES:
- `M.resolve_prompt` now returns config first and prompt second
- `M.update_selection` removed in favor of new `M.set_selection` function
- `M.resolve_embeddings` renamed to `M.resolve_context`
- Selection setting now only configurable in global config, not per-operation
- `get_selection` no longer accepts a config parameter
- Selection handling moved from dynamic config to static global config
- Changed sticky format and processing approach
- Prompts in config now use explicit `sticky` property instead of prefixing
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
@@ -535,10 +536,12 @@ Below are all available configuration options with their default values:
535
536
-- see config/prompts.lua for implementation
536
537
prompts= {
537
538
Explain= {
538
-
prompt='> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.',
539
+
prompt='Write an explanation for the selected code as paragraphs of text.',
540
+
sticky='/COPILOT_EXPLAIN',
539
541
},
540
542
Review= {
541
-
prompt='> /COPILOT_REVIEW\n\nReview the selected code.',
543
+
prompt='Review the selected code.',
544
+
sticky='/COPILOT_REVIEW',
542
545
},
543
546
Fix= {
544
547
prompt='There is a problem in this code. Identify the issues and rewrite the code with fixes. Explain what was wrong and how your changes address the problems.',
@@ -553,7 +556,8 @@ Below are all available configuration options with their default values:
553
556
prompt='Please generate tests for my code.',
554
557
},
555
558
Commit= {
556
-
prompt='> #git:staged\n\nWrite commit message for the change with commitizen convention. Keep the title under 50 characters and wrap message at 72 characters. Format as a gitcommit code block.',
559
+
prompt='Write commit message for the change with commitizen convention. Keep the title under 50 characters and wrap message at 72 characters. Format as a gitcommit code block.',
Copy file name to clipboardExpand all lines: lua/CopilotChat/config/prompts.lua
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -96,11 +96,13 @@ return {
96
96
},
97
97
98
98
Explain= {
99
-
prompt='> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.',
99
+
prompt='Write an explanation for the selected code as paragraphs of text.',
100
+
sticky='/COPILOT_EXPLAIN',
100
101
},
101
102
102
103
Review= {
103
-
prompt='> /COPILOT_REVIEW\n\nReview the selected code.',
104
+
prompt='Review the selected code.',
105
+
sticky='/COPILOT_REVIEW',
104
106
callback=function(response, source)
105
107
localdiagnostics= {}
106
108
forlineinresponse:gmatch('[^\r\n]+') do
@@ -159,6 +161,7 @@ return {
159
161
},
160
162
161
163
Commit= {
162
-
prompt='> #git:staged\n\nWrite commit message for the change with commitizen convention. Keep the title under 50 characters and wrap message at 72 characters. Format as a gitcommit code block.',
164
+
prompt='Write commit message for the change with commitizen convention. Keep the title under 50 characters and wrap message at 72 characters. Format as a gitcommit code block.',
0 commit comments