# HG changeset patch # User zegervdv # Date 1644853235 -3600 # Node ID 3ac8dac65b1b6ba0340fbd798abaf41802619cc4 # Parent bb1e1f4320d51a35424e7fc4dff88d82bffe69fd Add luasnip expansion mappings diff -r bb1e1f4320d5 -r 3ac8dac65b1b .chezmoitemplates/init.lua --- a/.chezmoitemplates/init.lua Wed Feb 09 17:16:57 2022 +0100 +++ b/.chezmoitemplates/init.lua Mon Feb 14 16:40:35 2022 +0100 @@ -834,6 +834,29 @@ end end +-- Snippets +local ls = require 'luasnip' +-- Expand snippet or jump to next placeholder +vim.keymap.set({ 'i', 's' }, '', function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) + +-- Go back to previous placeholder +vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) + +-- Toggle options in snippets +vim.keymap.set('i', '', function() + if ls.choice_active() then + ls.change_choice() + end +end) + -- LSP config local lsp = require 'lspconfig' local null_ls = require 'null-ls' @@ -864,8 +887,6 @@ vim.bo.formatexpr = 'v:lua.vim.lsp.formatexpr()' - map('i', '', vim.lsp.buf.signature_help, { silent = true, buffer = 0 }) - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) end