mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 13:19:48 +01:00
feat: add untested tabnine keybindings
This commit is contained in:
parent
eb8c841b4a
commit
9a84c9e087
2 changed files with 39 additions and 20 deletions
|
@ -10,13 +10,43 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["tabnine-nvim"];
|
vim.startPlugins = ["tabnine-nvim"];
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkExprBinding cfg.mappings.accept ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.accept}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(completion.accept)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
(mkExprBinding cfg.mappings.dismiss ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.dismiss}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
|
completion.clear()
|
||||||
|
state.completions_cache = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('tabnine').setup({
|
require('tabnine').setup({
|
||||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
||||||
accept_keymap = ${cfg.accept_keymap},
|
accept_keymap = null,
|
||||||
dismiss_keymap = ${cfg.dismiss_keymap},
|
dismiss_keymap = null,
|
||||||
debounce_ms = ${cfg.debounce_ms},
|
debounce_ms = ${cfg.debounce_ms},
|
||||||
execlude_filetypes = ${cfg.execlude_filetypes},
|
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.assistant.tabnine = {
|
options.vim.assistant.tabnine = {
|
||||||
|
@ -14,16 +10,9 @@ with builtins; {
|
||||||
description = "Disable auto comment";
|
description = "Disable auto comment";
|
||||||
};
|
};
|
||||||
|
|
||||||
accept_keymap = mkOption {
|
mappings = {
|
||||||
type = types.str;
|
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||||
default = "<Tab>";
|
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||||
description = "Accept keymap";
|
|
||||||
};
|
|
||||||
|
|
||||||
dismiss_keymap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "<C-]>";
|
|
||||||
description = "Dismiss keymap";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
debounce_ms = mkOption {
|
debounce_ms = mkOption {
|
||||||
|
@ -32,10 +21,10 @@ with builtins; {
|
||||||
description = "Debounce ms";
|
description = "Debounce ms";
|
||||||
};
|
};
|
||||||
|
|
||||||
execlude_filetypes = mkOption {
|
exclude_filetypes = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||||
description = "Execlude filetypes";
|
description = "Exclude filetypes";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue