diff --git a/README.md b/README.md index 2dd18716..ff516371 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,58 @@ return { }, }, }, + + -- Use for completion and snippets (supertab) + -- first: disable default and behavior in LuaSnip + { + "L3MON4D3/LuaSnip", + keys = function() + return {} + end, + }, + -- then: setup supertab in cmp + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-emoji", + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + local luasnip = require("luasnip") + local cmp = require("cmp") + + opts.mapping = vim.tbl_extend("force", opts.mapping, { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }) + end, + }, } ``` @@ -418,52 +470,54 @@ possible keymaps starting with ``.
General -| Key | Description | Mode | -| -------------------- | -------------------------- | -------------------------- | -| `` | Go to left window | **n** | -| `` | Go to lower window | **n** | -| `` | Go to upper window | **n** | -| `` | Go to right window | **n** | -| `` | Increase window height | **n** | -| `` | Decrease window height | **n** | -| `` | Decrease window width | **n** | -| `` | Increase window width | **n** | -| `` | Move down | **n**, **v**, **i** | -| `` | Move up | **n**, **v**, **i** | -| `bb` | Switch to Other Buffer | **n** | -| `` ` `` | Switch to Other Buffer | **n** | -| `` | Escape and clear hlsearch | **i**, **n** | -| `ur` | Redraw and clear hlsearch | **n** | -| `n` | Next search result | **n**, **x**, **o** | -| `N` | Prev search result | **n**, **x**, **o** | -| `` | Save file | **i**, **v**, **n**, **s** | -| `l` | Lazy | **n** | -| `fn` | New File | **n** | -| `xl` | Open Location List | **n** | -| `xq` | Open Quickfix List | **n** | -| `uf` | Toggle format on Save | **n** | -| `us` | Toggle Spelling | **n** | -| `uw` | Toggle Word Wrap | **n** | -| `ul` | Toggle Line Numbers | **n** | -| `ud` | Toggle Diagnostics | **n** | -| `uc` | Toggle Conceal | **n** | -| `gg` | Lazygit (cwd) | **n** | -| `gG` | Lazygit (root dir) | **n** | -| `qq` | Quit all | **n** | -| `sH` | Highlight Groups at cursor | **n** | -| `ft` | Terminal (root dir) | **n** | -| `fT` | Terminal (cwd) | **n** | -| `` | Enter Normal Mode | **t** | -| `ww` | other-window | **n** | -| `wd` | delete-window | **n** | -| `w-` | split-window-below | **n** | -| `w\|` | split-window-right | **n** | -| `l` | Last | **n** | -| `f` | First | **n** | -| `` | New Tab | **n** | -| `]` | Next | **n** | -| `d` | Close | **n** | -| `[` | Previous | **n** | +| Key | Description | Mode | +| -------------------- | ------------------------------------- | -------------------------- | +| `` | Go to left window | **n** | +| `` | Go to lower window | **n** | +| `` | Go to upper window | **n** | +| `` | Go to right window | **n** | +| `` | Increase window height | **n** | +| `` | Decrease window height | **n** | +| `` | Decrease window width | **n** | +| `` | Increase window width | **n** | +| `` | Move down | **n**, **v**, **i** | +| `` | Move up | **n**, **v**, **i** | +| `bb` | Switch to Other Buffer | **n** | +| `` ` `` | Switch to Other Buffer | **n** | +| `` | Escape and clear hlsearch | **i**, **n** | +| `ur` | Redraw / clear hlsearch / diff update | **n** | +| `n` | Next search result | **n**, **x**, **o** | +| `N` | Prev search result | **n**, **x**, **o** | +| `` | Save file | **i**, **v**, **n**, **s** | +| `l` | Lazy | **n** | +| `fn` | New File | **n** | +| `xl` | Open Location List | **n** | +| `xq` | Open Quickfix List | **n** | +| `uf` | Toggle format on Save | **n** | +| `us` | Toggle Spelling | **n** | +| `uw` | Toggle Word Wrap | **n** | +| `ul` | Toggle Line Numbers | **n** | +| `ud` | Toggle Diagnostics | **n** | +| `uc` | Toggle Conceal | **n** | +| `gg` | Lazygit (cwd) | **n** | +| `gG` | Lazygit (root dir) | **n** | +| `qq` | Quit all | **n** | +| `sH` | Highlight Groups at cursor | **n** | +| `ft` | Terminal (root dir) | **n** | +| `fT` | Terminal (cwd) | **n** | +| `` | Enter Normal Mode | **t** | +| `ww` | Other window | **n** | +| `wd` | Delete window | **n** | +| `w-` | Split window below | **n** | +| `w\|` | Split window right | **n** | +| `-` | Split window below | **n** | +| `\|` | Split window right | **n** | +| `l` | Last | **n** | +| `f` | First | **n** | +| `` | New Tab | **n** | +| `]` | Next | **n** | +| `d` | Close | **n** | +| `[` | Previous | **n** |
@@ -481,8 +535,9 @@ possible keymaps starting with ``. | `gt` | Goto Type Definition | **n** | | `K` | Hover | **n** | | `gK` | Signature Help | **n** | -| `[d` | Next Diagnostic | **n** | -| `]d` | Prev Diagnostic | **n** | +| `` | Signature Help | **i** | +| `]d` | Next Diagnostic | **n** | +| `[d` | Prev Diagnostic | **n** | | `]e` | Next Error | **n** | | `[e` | Prev Error | **n** | | `]w` | Next Warning | **n** | @@ -496,59 +551,71 @@ possible keymaps starting with ``.
Plugins -| Key | Description | Mode | -| ----------------- | ----------------------------------------------------------------------------------------------- | ----- | -| `cm` | [mason.nvim](https://github.com/williamboman/mason.nvim.git) Mason | **n** | -| `bd` | [mini.bufremove](https://github.com/echasnovski/mini.bufremove.git) Delete Buffer | **n** | -| `bD` | [mini.bufremove](https://github.com/echasnovski/mini.bufremove.git) Delete Buffer (Force) | **n** | -| `fe` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (root dir) | **n** | -| `fE` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (cwd) | **n** | -| `e` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (root dir) | **n** | -| `E` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (cwd) | **n** | -| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Redirect Cmdline | **c** | -| `snl` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice Last Message | **n** | -| `snh` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice History | **n** | -| `sna` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice All | **n** | -| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Scroll forward | **n** | -| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Scroll backward | **n** | -| `un` | [nvim-notify](https://github.com/rcarriga/nvim-notify.git) Delete all Notifications | **n** | -| `sr` | [nvim-spectre](https://github.com/windwp/nvim-spectre.git) Replace in files (Spectre) | **n** | -| `qs` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Restore Session | **n** | -| `ql` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Restore Last Session | **n** | -| `qd` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Don't Save Current Session | **n** | -| `,` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Switch Buffer | **n** | -| `/` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find in Files (Grep) | **n** | -| `:` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Command History | **n** | -| `` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (root dir) | **n** | -| `fF` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (cwd) | **n** | -| `fb` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Buffers | **n** | -| `ff` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (root dir) | **n** | -| `fr` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Recent | **n** | -| `gc` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) commits | **n** | -| `gs` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) status | **n** | -| `sa` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Auto Commands | **n** | -| `sC` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Commands | **n** | -| `so` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Options | **n** | -| `st` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Telescope | **n** | -| `sh` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Search Highlight Groups | **n** | -| `sG` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Grep (cwd) | **n** | -| `sk` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Key Maps | **n** | -| `sM` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Man Pages | **n** | -| `sb` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Buffer | **n** | -| `sc` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Command History | **n** | -| `sg` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Grep (root dir) | **n** | -| `sh` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Help Pages | **n** | -| `sm` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Jump to Mark | **n** | -| `ss` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Goto Symbol | **n** | -| `]t` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Next todo comment | **n** | -| `[t` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Previous todo comment | **n** | -| `xt` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Trouble | **n** | -| `xtt` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Trouble | **n** | -| `xT` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Telescope | **n** | -| `xx` | [trouble.nvim](https://github.com/folke/trouble.nvim.git) Document Diagnostics (Trouble) | **n** | -| `xX` | [trouble.nvim](https://github.com/folke/trouble.nvim.git) Workspace Diagnostics (Trouble) | **n** | -| `]]` | [vim-illuminate](https://github.com/RRethy/vim-illuminate.git) Next Reference | **n** | -| `[[` | [vim-illuminate](https://github.com/RRethy/vim-illuminate.git) Prev Reference | **n** | +| Key | Description | Mode | +| ----------------- | ------------------------------------------------------------------------------------------------------ | ------------ | +| `cm` | [mason.nvim](https://github.com/williamboman/mason.nvim.git) Mason | **n** | +| `bd` | [mini.bufremove](https://github.com/echasnovski/mini.bufremove.git) Delete Buffer | **n** | +| `bD` | [mini.bufremove](https://github.com/echasnovski/mini.bufremove.git) Delete Buffer (Force) | **n** | +| `gza` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Add surrounding | **n**, **v** | +| `gzd` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Delete surrounding | **n** | +| `gzf` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Find right surrounding | **n** | +| `gzF` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Find left surrounding | **n** | +| `gzh` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Highlight surrounding | **n** | +| `gzr` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Replace surrounding | **n** | +| `gzn` | [mini.surround](https://github.com/echasnovski/mini.surround.git) Update `MiniSurround.config.n_lines` | **n** | +| `fe` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (root dir) | **n** | +| `fE` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (cwd) | **n** | +| `e` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (root dir) | **n** | +| `E` | [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim.git) Explorer NeoTree (cwd) | **n** | +| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Redirect Cmdline | **c** | +| `snl` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice Last Message | **n** | +| `snh` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice History | **n** | +| `sna` | [noice.nvim](https://github.com/folke/noice.nvim.git) Noice All | **n** | +| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Scroll forward | **n** | +| `` | [noice.nvim](https://github.com/folke/noice.nvim.git) Scroll backward | **n** | +| `un` | [nvim-notify](https://github.com/rcarriga/nvim-notify.git) Delete all Notifications | **n** | +| `sr` | [nvim-spectre](https://github.com/windwp/nvim-spectre.git) Replace in files (Spectre) | **n** | +| `` | [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter.git) Increment selection | **n** | +| `` | [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter.git) Schrink selection | **n** | +| `qs` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Restore Session | **n** | +| `ql` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Restore Last Session | **n** | +| `qd` | [persistence.nvim](https://github.com/folke/persistence.nvim.git) Don't Save Current Session | **n** | +| `,` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Switch Buffer | **n** | +| `/` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find in Files (Grep) | **n** | +| `:` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Command History | **n** | +| `` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (root dir) | **n** | +| `fb` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Buffers | **n** | +| `ff` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (root dir) | **n** | +| `fF` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Find Files (cwd) | **n** | +| `fr` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Recent | **n** | +| `gc` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) commits | **n** | +| `gs` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) status | **n** | +| `sa` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Auto Commands | **n** | +| `sb` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Buffer | **n** | +| `sc` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Command History | **n** | +| `sC` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Commands | **n** | +| `sg` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Grep (root dir) | **n** | +| `sG` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Grep (cwd) | **n** | +| `sh` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Help Pages | **n** | +| `sH` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Search Highlight Groups | **n** | +| `sk` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Key Maps | **n** | +| `sM` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Man Pages | **n** | +| `sm` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Jump to Mark | **n** | +| `so` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Options | **n** | +| `st` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Telescope | **n** | +| `sw` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Word (root dir) | **n** | +| `sW` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Word (cwd) | **n** | +| `uC` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Colorscheme with preview | **n** | +| `ss` | [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim.git) Goto Symbol | **n** | +| `]t` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Next todo comment | **n** | +| `[t` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Previous todo comment | **n** | +| `xt` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Trouble | **n** | +| `xtt` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Trouble | **n** | +| `xT` | [todo-comments.nvim](https://github.com/folke/todo-comments.nvim.git) Todo Telescope | **n** | +| `xx` | [trouble.nvim](https://github.com/folke/trouble.nvim.git) Document Diagnostics (Trouble) | **n** | +| `xX` | [trouble.nvim](https://github.com/folke/trouble.nvim.git) Workspace Diagnostics (Trouble) | **n** | +| `]]` | [vim-illuminate](https://github.com/RRethy/vim-illuminate.git) Next Reference | **n** | +| `[[` | [vim-illuminate](https://github.com/RRethy/vim-illuminate.git) Prev Reference | **n** |
@@ -607,6 +674,7 @@ possible keymaps starting with ``. - [tokyonight.nvim](https://github.com/folke/tokyonight.nvim) - [trouble.nvim](https://github.com/folke/trouble.nvim) - [vim-illuminate](https://github.com/RRethy/vim-illuminate) +- [vim-repeat](https://github.com/tpope/vim-repeat) - [vim-startuptime](https://github.com/dstein64/vim-startuptime) - [which-key.nvim](https://github.com/folke/which-key.nvim)