diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 4a6b91a3..24d2ff61 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -411,6 +411,58 @@ Example spec: lua/plugins/example.lua }, }, }, + + -- 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, + }, } < @@ -428,51 +480,53 @@ see a popup with all 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** │ LSP @@ -488,8 +542,9 @@ LSP │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** │ @@ -502,58 +557,70 @@ LSP Plugins -│ Key │ Description │Mode │ -│cm │mason.nvim Mason │**n**│ -│bd │mini.bufremove Delete Buffer │**n**│ -│bD │mini.bufremove Delete Buffer (Force) │**n**│ -│fe │neo-tree.nvim Explorer NeoTree (root dir)│**n**│ -│fE │neo-tree.nvim Explorer NeoTree (cwd) │**n**│ -│e │neo-tree.nvim Explorer NeoTree (root dir)│**n**│ -│E │neo-tree.nvim Explorer NeoTree (cwd) │**n**│ -│ │noice.nvim Redirect Cmdline │**c**│ -│snl │noice.nvim Noice Last Message │**n**│ -│snh │noice.nvim Noice History │**n**│ -│sna │noice.nvim Noice All │**n**│ -│ │noice.nvim Scroll forward │**n**│ -│ │noice.nvim Scroll backward │**n**│ -│un │nvim-notify Delete all Notifications │**n**│ -│sr │nvim-spectre Replace in files (Spectre) │**n**│ -│qs │persistence.nvim Restore Session │**n**│ -│ql │persistence.nvim Restore Last Session │**n**│ -│qd │persistence.nvim Don’t Save Current Session │**n**│ -│, │telescope.nvim Switch Buffer │**n**│ -│/ │telescope.nvim Find in Files (Grep) │**n**│ -│: │telescope.nvim Command History │**n**│ -│ │telescope.nvim Find Files (root dir) │**n**│ -│fF │telescope.nvim Find Files (cwd) │**n**│ -│fb │telescope.nvim Buffers │**n**│ -│ff │telescope.nvim Find Files (root dir) │**n**│ -│fr │telescope.nvim Recent │**n**│ -│gc │telescope.nvim commits │**n**│ -│gs │telescope.nvim status │**n**│ -│sa │telescope.nvim Auto Commands │**n**│ -│sC │telescope.nvim Commands │**n**│ -│so │telescope.nvim Options │**n**│ -│st │telescope.nvim Telescope │**n**│ -│sh │telescope.nvim Search Highlight Groups │**n**│ -│sG │telescope.nvim Grep (cwd) │**n**│ -│sk │telescope.nvim Key Maps │**n**│ -│sM │telescope.nvim Man Pages │**n**│ -│sb │telescope.nvim Buffer │**n**│ -│sc │telescope.nvim Command History │**n**│ -│sg │telescope.nvim Grep (root dir) │**n**│ -│sh │telescope.nvim Help Pages │**n**│ -│sm │telescope.nvim Jump to Mark │**n**│ -│ss │telescope.nvim Goto Symbol │**n**│ -│]t │todo-comments.nvim Next todo comment │**n**│ -│[t │todo-comments.nvim Previous todo comment │**n**│ -│xt │todo-comments.nvim Todo Trouble │**n**│ -│xtt │todo-comments.nvim Todo Trouble │**n**│ -│xT │todo-comments.nvim Todo Telescope │**n**│ -│xx │trouble.nvim Document Diagnostics (Trouble) │**n**│ -│xX │trouble.nvim Workspace Diagnostics (Trouble) │**n**│ -│]] │vim-illuminate Next Reference │**n**│ -│[[ │vim-illuminate Prev Reference │**n**│ +│ Key │ Description │ Mode │ +│cm │mason.nvim Mason │**n** │ +│bd │mini.bufremove Delete Buffer │**n** │ +│bD │mini.bufremove Delete Buffer (Force) │**n** │ +│gza │mini.surround Add surrounding │**n**, **v**│ +│gzd │mini.surround Delete surrounding │**n** │ +│gzf │mini.surround Find right surrounding │**n** │ +│gzF │mini.surround Find left surrounding │**n** │ +│gzh │mini.surround Highlight surrounding │**n** │ +│gzr │mini.surround Replace surrounding │**n** │ +│gzn │mini.surround Update MiniSurround.config.n_lines │**n** │ +│fe │neo-tree.nvim Explorer NeoTree (root dir) │**n** │ +│fE │neo-tree.nvim Explorer NeoTree (cwd) │**n** │ +│e │neo-tree.nvim Explorer NeoTree (root dir) │**n** │ +│E │neo-tree.nvim Explorer NeoTree (cwd) │**n** │ +│ │noice.nvim Redirect Cmdline │**c** │ +│snl │noice.nvim Noice Last Message │**n** │ +│snh │noice.nvim Noice History │**n** │ +│sna │noice.nvim Noice All │**n** │ +│ │noice.nvim Scroll forward │**n** │ +│ │noice.nvim Scroll backward │**n** │ +│un │nvim-notify Delete all Notifications │**n** │ +│sr │nvim-spectre Replace in files (Spectre) │**n** │ +│ │nvim-treesitter Increment selection │**n** │ +│ │nvim-treesitter Schrink selection │**n** │ +│qs │persistence.nvim Restore Session │**n** │ +│ql │persistence.nvim Restore Last Session │**n** │ +│qd │persistence.nvim Don’t Save Current Session │**n** │ +│, │telescope.nvim Switch Buffer │**n** │ +│/ │telescope.nvim Find in Files (Grep) │**n** │ +│: │telescope.nvim Command History │**n** │ +│ │telescope.nvim Find Files (root dir) │**n** │ +│fb │telescope.nvim Buffers │**n** │ +│ff │telescope.nvim Find Files (root dir) │**n** │ +│fF │telescope.nvim Find Files (cwd) │**n** │ +│fr │telescope.nvim Recent │**n** │ +│gc │telescope.nvim commits │**n** │ +│gs │telescope.nvim status │**n** │ +│sa │telescope.nvim Auto Commands │**n** │ +│sb │telescope.nvim Buffer │**n** │ +│sc │telescope.nvim Command History │**n** │ +│sC │telescope.nvim Commands │**n** │ +│sg │telescope.nvim Grep (root dir) │**n** │ +│sG │telescope.nvim Grep (cwd) │**n** │ +│sh │telescope.nvim Help Pages │**n** │ +│sH │telescope.nvim Search Highlight Groups │**n** │ +│sk │telescope.nvim Key Maps │**n** │ +│sM │telescope.nvim Man Pages │**n** │ +│sm │telescope.nvim Jump to Mark │**n** │ +│so │telescope.nvim Options │**n** │ +│st │telescope.nvim Telescope │**n** │ +│sw │telescope.nvim Word (root dir) │**n** │ +│sW │telescope.nvim Word (cwd) │**n** │ +│uC │telescope.nvim Colorscheme with preview │**n** │ +│ss │telescope.nvim Goto Symbol │**n** │ +│]t │todo-comments.nvim Next todo comment │**n** │ +│[t │todo-comments.nvim Previous todo comment │**n** │ +│xt │todo-comments.nvim Todo Trouble │**n** │ +│xtt │todo-comments.nvim Todo Trouble │**n** │ +│xT │todo-comments.nvim Todo Telescope │**n** │ +│xx │trouble.nvim Document Diagnostics (Trouble) │**n** │ +│xX │trouble.nvim Workspace Diagnostics (Trouble) │**n** │ +│]] │vim-illuminate Next Reference │**n** │ +│[[ │vim-illuminate Prev Reference │**n** │ PLUGINS *LazyVim-plugins* @@ -608,6 +675,7 @@ Core - tokyonight.nvim - trouble.nvim - vim-illuminate +- vim-repeat - vim-startuptime - which-key.nvim