Skip to content

Check whether copilot is available#1

Open
ryoppippi wants to merge 2 commits intohrsh7th:mainfrom
ryoppippi:dev/add-copilot-loaded-detecter
Open

Check whether copilot is available#1
ryoppippi wants to merge 2 commits intohrsh7th:mainfrom
ryoppippi:dev/add-copilot-loaded-detecter

Conversation

@ryoppippi
Copy link

Add check whether copilot is available.

@ryoppippi ryoppippi marked this pull request as draft April 26, 2022 21:49
@ryoppippi ryoppippi force-pushed the dev/add-copilot-loaded-detecter branch from 0f855ed to 2d8b404 Compare April 26, 2022 21:50
@ryoppippi ryoppippi marked this pull request as ready for review April 26, 2022 21:50
@tmerse
Copy link

tmerse commented Jun 23, 2022

Should be merged, or people will be confused why Copilot still gives suggestion, even if disabled via config.

EDIT: Unfortunately, the patch does not seem to respect dynamically switching on/off via :Copilot enable/:Copilot disable.

For this to work, the vim.g.loaded_copilot == 1 and vim.b.copilot_enabled ~= false) would need to run every time before vim.fn['copilot#Complete'] is invoked I suppose.

EDIT 2: I found behavior around

vim.g.loaded_copilot
vim.b.copilot_enabled
vim.g.copilot_enabled

rather inconsistent in conjunction with :Copilot disable/enable. E.g. :lua print(vim.g.copilot_enabled) holds values of false, 0, 1.

What works for me is

source.is_available = function()
  return vim.g.copilot_enabled == 1
end

Of course ymmv.

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

Successfully merging this pull request may close these issues.

2 participants