From f5b546d6aaabc3364c34ea212eef6b9f91b0f82e Mon Sep 17 00:00:00 2001 From: aarondill Date: Mon, 25 Mar 2024 01:51:36 -0500 Subject: [PATCH] doc: update doc/tabnine.txt Add the advanced usecase to the vimdoc This help feels neglected... --- doc/tabnine.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/tabnine.txt b/doc/tabnine.txt index f4598d9..186f026 100644 --- a/doc/tabnine.txt +++ b/doc/tabnine.txt @@ -9,6 +9,7 @@ Introduction |tabnine-nvim-introduction| Usage |tabnine-nvim-usage| Commands |tabnine-nvim-commands| Configuration |tabnine-nvim-configuration| +Advanced keymaps |tabnine-nvim-advanced-keymaps| ============================================================================== INTRODUCTION *tabnine-nvim-introduction* @@ -32,7 +33,7 @@ This will initialize and setup the plugin to start using completion. Further configuration can be passed to the setup function (|CONFIGURATION|) ============================================================================== -COMMANDS +COMMANDS *tabnine-nvim-commands* Print Tabnine status :TabnineStatus @@ -82,9 +83,11 @@ See https://vim.fandom.com/wiki/Disable_automatic_comment_insertion *accept_keymap* - String - Default: "" The key to press to accept the current completion. +Note: Set to `false` to disable the accept keymap *dismiss_keymap* - String - Default: "" The key to press to hide the current completion. +Note: Set to `false` to disable the dismiss keymap *debounce_ms* - Integer - Default: 800 - Minumum: 0 The number of milliseconds to wait between keystrokes before giving @@ -105,5 +108,25 @@ Use :|setfiletype| to see available file types. An absolute path to Tabnine log file. +============================================================================== +ADVANCED KEYMAPS *tabnine-nvim-advanced-keymaps* + +You can set `accept_keymap` and `dismiss_keymap` to `false` to disable them +then you can create mappings using `require('tabnine.keymaps')` +>lua +--- Example integration with Tabnine and LuaSnip +--- falling back to inserting tab if neither has a completion +vim.keymap.set("i", "", function() + if require("tabnine.keymaps").has_suggestion() then + return require("tabnine.keymaps").accept_suggestion() + elseif require("luasnip").jumpable(1) then + return require("luasnip").jump(1) + else + return "" + end +end, { expr = true }) +< + + ============================================================================== vim:tw=78:ts=4:ft=help:norl:noet:fen:noet: