2023-02-27 14:05:53 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
|
|
|
inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim;
|
|
|
|
|
2023-02-27 14:05:53 +00:00
|
|
|
cfg = config.vim.assistant.tabnine;
|
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
vim.startPlugins = ["tabnine-nvim"];
|
|
|
|
|
2023-04-22 14:06:09 +00:00
|
|
|
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")
|
|
|
|
];
|
|
|
|
|
2023-02-27 14:05:53 +00:00
|
|
|
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
|
|
|
require('tabnine').setup({
|
|
|
|
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
2023-04-22 14:06:09 +00:00
|
|
|
accept_keymap = null,
|
|
|
|
dismiss_keymap = null,
|
2023-02-27 14:05:53 +00:00
|
|
|
debounce_ms = ${cfg.debounce_ms},
|
2023-04-22 14:06:09 +00:00
|
|
|
exclude_filetypes = ${cfg.exclude_filetypes},
|
2023-02-27 14:05:53 +00:00
|
|
|
})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|