feat: improve nvim keymaps, add trouble

This commit is contained in:
Fabio Lenherr / DashieTM 2022-11-03 23:40:33 +01:00
parent d42d294c95
commit 76534ab4cb
13 changed files with 315 additions and 20 deletions

View file

@ -8,9 +8,27 @@ if not snip_status_ok then
return
end
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
luasnip.config.set_config({
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true,
ext_opts = {
[require("luasnip.util.types").choiceNode] = {
active = {
virt_text = { {
Snippet = "",
"Snippet",
} },
},
},
},
})
vim.cmd('let g:snipMate = {"snippet_version" : 1 }')
require("luasnip/loaders/from_vscode").lazy_load()
require("luasnip.loaders.from_snipmate").lazy_load()
--require("luasnip.loaders.from_snipmate").lazy_load()
local check_backspace = function()
local col = vim.fn.col(".") - 1
@ -47,6 +65,11 @@ local kind_icons = {
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
--local has_words_before = function()
-- 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
cmp.setup({
snippet = {
expand = function(args)
@ -55,7 +78,7 @@ cmp.setup({
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
--["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
@ -64,13 +87,25 @@ cmp.setup({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
-- mapping = cmp.mapping.preset.insert({
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-Space>'] = cmp.mapping.complete(),
-- ['<C-e>'] = cmp.mapping.abort(),
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- }),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
else
fallback()
end
end, { "i", "s" }),
["<C-j>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
@ -84,9 +119,7 @@ cmp.setup({
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()