-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to turn Github Copilot off in one file or turn it off temporarily? #126
Comments
You may ask Microsoft for that. https://github.com/orgs/community/discussions/11254 There is no general way to ignore thing in LSP protocol. It's per-server definition/implementation. @rchl Is it possible to start/stop attaching a server seesion per view? |
No, we don't support such use case. @oshihirii I think you should be looking at the terms and conditions of https://github.com/features/copilot to understand what data it collects or receives since this package just starts the copilot without sending any data on top of that. Also, it's probably up to your company to specify policies where it either allows or doesn't allow the use of copilot specifically. |
Actually, I was thinking about something similar too. Technically, it should be possible, as we could check some flag in the view settings, and when it is I think VSCode has a similar feature where you can disable Copilot for the current file. |
VS Code and Zed support this. Copilot is supposed to be supporting an ignore file now or soon. |
I assume that this should be handled by the client, so that the server won't get any requests or file notifications for the ignored files. A related LSP issue: sublimelsp/LSP#2282 |
Handling it in LSP makes more sense imho. So we don't need every LSP-* to invent its own format. The session doesn't even need to attach to those ignored files. |
I'm interested in trying Copilot with Sublime Text, but for similar reasons I want to enable suggestions only on a per-file basis. I would like to use automatic suggestions, but only if I manually approve it first for a particular file. I need to be certain that credentials and other sensitive data that I may open in Sublime never leave my machine. |
Many servers do file traversing on their own since they need to read and analyze the whole project to be able to provide all the functionality. While Copilot doesn't sound like a server of that kind, in theory you can never be sure what it does, even if you restrict it to specific files. |
Yeah...Not being sure whether Copilot might be transmitting files without my explicit approval on a per-file basis is a non-starter. Have I overestimated Microsoft on this one? |
Seeing as GitHub doesn’t seem to want to support this. I’m working on support for this. |
I'm just adding for reference, based on a resource that was suggested earlier, relevant snippets from https://github.com/features/copilot Some of the statements are reassuring, but some of them seem a bit contradictory. (I've attached a screenshot of the whole
|
It seems like I'd like to leave the following example code snippet here, which should make it possible to ignore file patterns from a The I think passing only the from fnmatch import fnmatch
import os
# in your plugin class:
@classmethod
def should_ignore(cls, view: sublime.View) -> bool:
filepath = view.file_name()
if not filepath:
return False
window = view.window()
if not window:
return False
for folder in window.folders():
copilotignorefile = os.path.join(folder, '.copilotignore')
if os.path.isfile(copilotignorefile):
try:
with open(copilotignorefile, 'r') as file:
for pattern in file.readlines():
pattern = pattern.strip()
if pattern == '' or pattern.startswith(('#', ';')):
continue
if '/' not in pattern:
pattern = '**/{}'.format(pattern)
if fnmatch(filepath, pattern):
return True
except OSError:
pass
break
return False Ideally please also include a syntax definition for %YAML 1.2
---
name: Copilot Ignore
scope: text.copilotignore
version: 2
hidden: true
hidden_file_extensions:
- .copilotignore
contexts:
main:
- include: Git Common.sublime-syntax#comments
- match: '(?=\S)'
push: [pattern-content, Git Common.sublime-syntax#fnmatch-start]
pattern-content:
- meta_scope: string.unquoted.copilotignore entity.name.pattern.copilotignore
- match: $
pop: 1
- include: Git Common.sublime-syntax#fnmatch-unquoted-body |
I have just worked out a simple way to turn it off temporarily. Here's the instructions:
import sublime
import sublime_plugin
class CopilotAutoAskCompletions(sublime_plugin.ApplicationCommand):
SETTING_FILE = 'LSP-copilot.sublime-settings'
def run(self, **kwargs):
# load settings
setting = sublime.load_settings(CopilotAutoAskCompletions.SETTING_FILE)
enable = kwargs.get('enable', True)
setting['settings'] = {
'auto_ask_completions': enable
}
# write back
sublime.save_settings(CopilotAutoAskCompletions.SETTING_FILE)
[
{
"caption": "Copilot: Disable auto_ask_completions",
"command": "copilot_auto_ask_completions",
"args": { "enable": false }
},
{
"caption": "Copilot: Enable auto_ask_completions",
"command": "copilot_auto_ask_completions",
"args": { "enable": true }
}
]
|
In Command Palette, setting "LSP: Disable Language Server Globally" (or in Project) was enough for me. LSP-copilot can be disabled if you want, but not others. |
This has been shipped with |
I haven't tested and have only skimmed over the PR, but it looks like you don't use the new API method that I added based on the discussion here. So I assume that the file contents including secrets and all edits of the affected files are still sent to the server, right? I guess you needed some more code to handle the non-standard requests that Copilot uses, but is there any reason why you didn't use the new LSP API to suppress the file synchronisation? |
Which API ? |
Ahh honestly, I didn't see it. So I can update it so we use should ignore on top of the file watcher we added. But currently, no files aren't sent to the server still |
Well I don't really know how Copilot works, but if this package is using LSP, then document syncronisation is still automatically handled by LSP (unless suppressed via |
Makes sense. I've got the local changes for should_ignore. So I'll push and make a new release since we never cut a release for cooilotingore yet |
@jwortmann This is what I noticed. Which seems like I might need to use this approach, and my approach combined. This continues to ignore a file if
So changes to this file wont reflect to already opened views |
Is there a way to re-notify LSP to add file to session? I can either close and opens file (poor ux) or restart lsp-copilot |
Hm, I think there is no "official" way. Maybe we could add another method to unigore ignored views. What you could try to do is to modify either the "syntax" or "lsp_uri" view setting (and then set it back to the old value after a very short delay). This should retrigger the registration of the view, when the corresponding tab gets focused the next time: https://github.com/sublimelsp/LSP/blob/293f4a4340cca5ab1ad065643e4f20d9b270b2b1/plugin/documents.py#L1020-L1030 |
This seems working |
Hello,
Sometimes I don't want suggestions.
Is there a way to turn off GitHub Copilot for one file, or turn it off temporarily?
Thank You.
Edit:
Also, whilst I think of it, in terms of privacy/security...
Once I start using GitHub Copilot in Sublime Text, is everything I type into Sublime Text sent to GitHub Copilot servers and saved there?
Obviously, sometimes I am typing things that are business confidential and should not be shared with the world, so it would be good to get re-assurance that this is not happening. I wouldn't want something confidential I typed in my text editor, showing up as a suggestion in someone else's text editor who is using GitHub Copilot.
Thank you again.
The text was updated successfully, but these errors were encountered: