comparison .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
comparison
equal deleted inserted replaced
557:bb1e1f4320d5 558:3ac8dac65b1b
832 if vim.o.diff then 832 if vim.o.diff then
833 vim.cmd [[ diffupdate ]] 833 vim.cmd [[ diffupdate ]]
834 end 834 end
835 end 835 end
836 836
837 -- Snippets
838 local ls = require 'luasnip'
839 -- Expand snippet or jump to next placeholder
840 vim.keymap.set({ 'i', 's' }, '<c-k>', function()
841 if ls.expand_or_jumpable() then
842 ls.expand_or_jump()
843 end
844 end, { silent = true })
845
846 -- Go back to previous placeholder
847 vim.keymap.set({ 'i', 's' }, '<c-j>', function()
848 if ls.jumpable(-1) then
849 ls.jump(-1)
850 end
851 end, { silent = true })
852
853 -- Toggle options in snippets
854 vim.keymap.set('i', '<c-l>', function()
855 if ls.choice_active() then
856 ls.change_choice()
857 end
858 end)
859
837 -- LSP config 860 -- LSP config
838 local lsp = require 'lspconfig' 861 local lsp = require 'lspconfig'
839 local null_ls = require 'null-ls' 862 local null_ls = require 'null-ls'
840 863
841 local on_attach = function(client) 864 local on_attach = function(client)
861 silent = true, 884 silent = true,
862 buffer = 0, 885 buffer = 0,
863 }) 886 })
864 887
865 vim.bo.formatexpr = 'v:lua.vim.lsp.formatexpr()' 888 vim.bo.formatexpr = 'v:lua.vim.lsp.formatexpr()'
866
867 map('i', '<c-l>', vim.lsp.buf.signature_help, { silent = true, buffer = 0 })
868 889
869 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) 890 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' })
870 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) 891 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' })
871 end 892 end
872 893