Mercurial > dotfiles
diff .chezmoitemplates/init.lua @ 558:3ac8dac65b1b
Add luasnip expansion mappings
author | zegervdv <zegervdv@me.com> |
---|---|
date | Mon, 14 Feb 2022 16:40:35 +0100 |
parents | bb1e1f4320d5 |
children | c8b76a79611a |
line wrap: on
line diff
--- 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' }, '<c-k>', 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' }, '<c-j>', function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) + +-- Toggle options in snippets +vim.keymap.set('i', '<c-l>', 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', '<c-l>', 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