mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 13:19:48 +01:00
fix: stop errors from popping up when panel is not open
This commit is contained in:
parent
9a84c9e087
commit
bc9caacd78
1 changed files with 20 additions and 7 deletions
|
@ -7,6 +7,18 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
|
||||||
|
wrapPanelBinding = luaFunction: key: ''
|
||||||
|
function()
|
||||||
|
local s, _ = pcall(${luaFunction})
|
||||||
|
|
||||||
|
if not s then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON key}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
|
@ -45,13 +57,14 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
vim.maps.normal = mkMerge [
|
||||||
(mkLuaBinding cfg.mappings.panel.jumpPrev "require(\"copilot.panel\").jump_prev" "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.jumpNext "require(\"copilot.panel\").jump_next" "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.accept "require(\"copilot.panel\").accept" "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.refresh "require(\"copilot.panel\").refresh" "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.open ''
|
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
|
||||||
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end
|
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end
|
||||||
'' "[copilot] Accept suggestion")
|
''
|
||||||
|
cfg.mappings.panel.open) "[copilot] Accept suggestion")
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.maps.insert = mkMerge [
|
vim.maps.insert = mkMerge [
|
||||||
|
|
Loading…
Reference in a new issue