fix: nvim tab and c-i keys

This commit is contained in:
Max Hohlfeld 2023-08-16 14:05:48 +02:00
parent d80d64c5f3
commit b1a8f70058
2 changed files with 7 additions and 15 deletions

View File

@ -73,6 +73,9 @@ map('n', '<Space>w', '<cmd>w<cr>', { noremap = true })
map('n', '<Space>q', '<cmd>wq<cr>', { noremap = true })
map('n', '<Esc><Esc>', '<cmd>let @/ = ""<cr>', { noremap = true })
-- fix interpreting C-I as Tab
map('n', '<C-I>', '<C-I>', { noremap = true })
-- Splits
map('n', '<C-h>', '<C-w>h', { noremap = true })
map('n', '<C-j>', '<C-w>j', { noremap = true })
@ -218,12 +221,6 @@ ls.config.set_config({
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/snippets" })
local has_words_before = function()
unpack = unpack or table.unpack
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
-- Completion
local cmp = require('cmp')
cmp.setup {
@ -236,20 +233,14 @@ cmp.setup {
['<CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
['<C-Space>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif ls.expand_or_locally_jumpable() then
if ls.expand_or_locally_jumpable() then
ls.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif ls.locally_jumpable(-1) then
if ls.locally_jumpable(-1) then
ls.jump(-1)
else
fallback()

View File

@ -3,6 +3,7 @@ env:
key_bindings:
- { key: N, mods: Control|Shift, action: SpawnNewInstance }
- { key: I, mods: Control, chars: "\x1b[105;5u" }
font:
normal: