File tree Expand file tree Collapse file tree 3 files changed +55
-8
lines changed Expand file tree Collapse file tree 3 files changed +55
-8
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ your browser and pasting it into API token request.
7171To use Codeium Chat, execute the ` :Codeium Chat ` command. The chat will be opened
7272in your default browser using the xdg-open command.
7373
74+ You can globaly enable or disable Codeium Completion with ` :Codeium Toggle ` command.
75+
7476## Options
7577
7678- ` config_path ` : the path to the config file, used to store the API key.
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ function Server:new()
166166 local healthy = false
167167 local last_heartbeat = nil
168168 local last_heartbeat_error = nil
169+ local enabled = true
169170
170171 local function request (fn , payload , callback )
171172 local url = " http://127.0.0.1:" .. port .. " /exa.language_server_pb.LanguageServerService/" .. fn
@@ -336,6 +337,9 @@ function Server:new()
336337
337338 local pending_request = { 0 , noop }
338339 function m .request_completion (document , editor_options , other_documents , callback )
340+ if enabled == false then
341+ return
342+ end
339343 pending_request [2 ](true )
340344
341345 local metadata = get_request_metadata ()
@@ -529,6 +533,24 @@ function Server:new()
529533 end
530534 end
531535
536+ function m .enable ()
537+ enabled = true
538+ notify .info (" Codeium enabled" )
539+ end
540+
541+ function m .disable ()
542+ enabled = false
543+ notify .info (" Codeium disabled" )
544+ end
545+
546+ function m .toggle ()
547+ if enabled then
548+ m .disable ()
549+ else
550+ m .enable ()
551+ end
552+ end
553+
532554 m .__index = m
533555 return o
534556end
Original file line number Diff line number Diff line change @@ -7,38 +7,61 @@ function M.setup(options)
77 local health = require (" codeium.health" )
88 require (" codeium.config" ).setup (options )
99
10- local s = Server :new ()
10+ M . s = Server :new ()
1111 update .download (function (err )
1212 if not err then
1313 Server .load_api_key ()
14- s .start ()
14+ M . s .start ()
1515 end
1616 end )
17- health .register (s .checkhealth )
17+ health .register (M . s .checkhealth )
1818
1919 vim .api .nvim_create_user_command (" Codeium" , function (opts )
2020 local args = opts .fargs
2121 if args [1 ] == " Auth" then
2222 Server .authenticate ()
2323 end
2424 if args [1 ] == " Chat" then
25- s .refresh_context ()
26- s .get_chat_ports ()
27- s .add_workspace ()
25+ M .s .refresh_context ()
26+ M .s .get_chat_ports ()
27+ M .s .add_workspace ()
28+ end
29+ if args [1 ] == " Toggle" then
30+ M .s .toggle ()
2831 end
2932 end , {
3033 nargs = 1 ,
3134 complete = function ()
32- local commands = { " Auth" }
35+ local commands = { " Auth" , " Toggle " }
3336 if require (" codeium.config" ).options .enable_chat then
3437 commands = vim .list_extend (commands , { " Chat" })
3538 end
3639 return commands
3740 end ,
3841 })
3942
40- local source = Source :new (s )
43+ local source = Source :new (M . s )
4144 require (" cmp" ).register_source (" codeium" , source )
4245end
4346
47+ --- Open Codeium Chat
48+ function M .chat ()
49+ M .s .refresh_context ()
50+ M .s .get_chat_ports ()
51+ M .s .add_workspace ()
52+ end
53+
54+ --- Toggle the Codeium plugin
55+ function M .toggle ()
56+ M .s .toggle ()
57+ end
58+
59+ function M .enable ()
60+ M .s .enable ()
61+ end
62+
63+ function M .disable ()
64+ M .s .disable ()
65+ end
66+
4467return M
You can’t perform that action at this time.
0 commit comments