Skip to content
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

"Codeium: Disable" in the command palette doesn't work #10

Open
clci opened this issue Jan 30, 2024 · 10 comments
Open

"Codeium: Disable" in the command palette doesn't work #10

clci opened this issue Jan 30, 2024 · 10 comments

Comments

@clci
Copy link

clci commented Jan 30, 2024

As per title, the option to disable the plugin doesn't work, it relentlessly continues to make suggestions. Restarting ST isn't helpful.
I'm running Sublime Text 4168 on Kubuntu 22.04.

Thanks for your work!

@chris3eleven
Copy link

Same here on Mac OS.

@Gabriel-p
Copy link

Same here in elementary OS 7.1 (based on Ubuntu 22.04.3 LTS)

@ivanlegranbizarro
Copy link

Same here with Linux Mint (based on Ubuntu 22:04.1 LTS)

@chris3eleven
Copy link

Would be pretty cool if someone responded.

@chris3eleven
Copy link

chris3eleven commented Sep 3, 2024

Okay, so I'm not a Python guy, but I decided to see if I could figure this out. I installed Extract Sublime Package, and used it to extract Codeium.sublime-package. This placed the extracted package in my "Packages" folder, as opposed to "Installed Packages" folder, where Codeium.sublime-package resides. Sublime then prefers the extracted package, allowing me to tinker with the files and see the effects of my changes as I make them.

I discovered on line 74 of display_completions.py, within the make_async_request function, the following:

view.settings().set("Codeium.completion_active", True)

As far as I can tell, this turns completion on regardless of whether it has been turned off by the user. In any case, aside of the fact the Codeium should surely not be making a request if it has been disabled(?), simply commenting this line out has, in my testing, resulted in the "Codeium: Disable" and "Codeium: Enable" commands in the command palette working as expected - no more code completion once I've run Codeium: Disable, but code completion is restored after running Codeium: Enable.

HOWEVER, a side-effect I've noticed is that, with this line commented out, when code completion is enabled, my escape key no longer rejects a suggestion (backspace does, though). Could possibly be something to do with line 132 of the same file, within the CodeiumRejectCompletionCommand function, which reads:

self.view.settings().set("Codeium.completion_active", False)

It's late here, I'll dig more into it tomorrow, time permitting, and report further findings.

@chris3eleven
Copy link

chris3eleven commented Sep 4, 2024

Turns out the above solution not only broke escape to reject completion, but also tab to accept completion.

But I have found the answer.

If you've commented out line 74 of display_completions.py, as per my above instruction, uncomment it. Then, on line 83 of the same file, which reads:

and CodeiumSettings.enable

Append ' == true', so it looks like this:

and CodeiumSettings.enable == True

et voilà, Enable/Disable Codeium now works as it should, without breaking any functionality.

Bonus tip: edit Default.sublime-keymap and change the binding for codeium_accept_completion to shift+tab (or key/s of your choosing) so you don't insert a suggested completion every time you try to indent something. Was driving me insane.

{
	"keys" : ["shift+tab"], // tab
	"command": "codeium_accept_completion",
	"context": [
		{
			"key" : "setting.Codeium.completion_active",
			"operator": "equal", "operand": true
		}
	]
},

@chris3eleven
Copy link

@fortenforge, @mochaaP, @2022tgoel - can one of you test + apply the abovementioned fix, or do I need to figure out how to repackage Codeium.sublime-package and submit a PR?

@ivanlegranbizarro
Copy link

@chris3eleven thank you so much man!

@ivanlegranbizarro
Copy link

@fortenforge, @mochaaP, @2022tgoel - can one of you test + apply the abovementioned fix, or do I need to figure out how to repackage Codeium.sublime-package and submit a PR?

Finally I tried and for me your solution works pretty well. Again, thanks! Now I chan change to sublime from vscode xD

@ivanlegranbizarro
Copy link

ivanlegranbizarro commented Oct 1, 2024

In the end, what worked best for me was to create a plugin that manages the enable and disable of Codeium. The code is this:

import sublime
import sublime_plugin
from Codeium.login import CodeiumSettings

class CodeiumToggleCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        # Toggle the Codeium enable setting
        CodeiumSettings.enable = not CodeiumSettings.enable
        
        # Save the settings
        sublime.save_settings("Codeium.sublime-settings")
        
        # Provide feedback to the user
        status = "habilitado" if CodeiumSettings.enable else "deshabilitado"
        sublime.status_message(f"Codeium {status}")
        print(f"Codeium {status}")

class CodeiumStatusListener(sublime_plugin.EventListener):
    def on_activated_async(self, view):
        self.update_status(view)
    
    def on_modified_async(self, view):
        self.update_status(view)
    
    def update_status(self, view):
        if CodeiumSettings.enable:
            view.set_status('codeium', 'Codeium: Activo')
        else:
            view.erase_status('codeium')`
            

Now you just need to assign a keybinding to this command:

 [
  {
    "keys": ["ctrl+shift+c"],
    "command": "codeium_toggle"
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants