From 7ee9da2291d3fff50f6b918910b6dbbe2868db06 Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Tue, 28 Nov 2023 13:39:41 +0100 Subject: [PATCH] update --- after/plugin/luasnip.lua | 44 +++++++++++++++++++++++++++++++++------ lua/lennartalff/remap.lua | 5 +++++ lua/plugins/lsp/init.lua | 2 +- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua index e888ecd..61579e6 100644 --- a/after/plugin/luasnip.lua +++ b/after/plugin/luasnip.lua @@ -1,14 +1,46 @@ -require('luasnip').config.set_config({ +local ls = require('luasnip') +local ll = require('luasnip.loaders.from_lua') +local types = require('luasnip.util.types') + +ls.config.set_config({ enable_autosnippets = true, store_selection_keys = '', history = true, updateevents = 'TextChanged,TextChangedI', delete_check_events = 'TextChanged', + ext_opts = { + [types.insertNode] = { + active = {}, + unvisited = { + virt_text = { { '<- insert', 'DiagnosticVirtualTextHint' } } + }, + visited = {}, + passive = {}, + snippet_passive = {}, + }, + [types.choiceNode] = { + active = { + virt_text = { { '<- insert', 'DiagnosticVirtualTextError' } }, + }, + } + }, }) -require('luasnip.loaders.from_lua').load({ paths = { vim.fn.stdpath('config') .. '/snippets' } }) +ll.load({ paths = { vim.fn.stdpath('config') .. '/snippets' } }) -local keymap = vim.api.nvim_set_keymap -local opts = { noremap = true, silent = true } -keymap('i', '', 'lua require("luasnip").jump(1)', opts) -keymap('i', '', 'lua require("luasnip").jump(-1)', opts) +vim.keymap.set({ 'i', 's' }, '', function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) + +vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) + +vim.keymap.set('n', 's', function() + vim.cmd('source ' .. vim.fn.stdpath('config') .. '/after/plugin/luasnip.lua') + vim.notify('Sourced snippets', 'info', { title = 'LuaSnip' }) +end) diff --git a/lua/lennartalff/remap.lua b/lua/lennartalff/remap.lua index 51ebf7a..fa05557 100644 --- a/lua/lennartalff/remap.lua +++ b/lua/lennartalff/remap.lua @@ -42,6 +42,11 @@ local function quickfix() end vim.keymap.set('n', 'qf', quickfix) +vim.keymap.set('v', 'dgh', "diffget LOCAL") +vim.keymap.set('v', 'dgl', "diffget REMOTE") + +vim.keymap.set('n', 'dgh', "diffget LOCAL") +vim.keymap.set('n', 'dgl', "diffget REMOTE") -- stay in visual mode after indenting/dedenting vim.keymap.set('v', '<', '