Skip to content

Commit

Permalink
Revert "home-manager/neovim: use vim.keymap.set instead vim.cmd"
Browse files Browse the repository at this point in the history
This reverts commit e62e753.
  • Loading branch information
thiagokokada committed Feb 13, 2024
1 parent 46f6d5a commit e55592a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions home-manager/editor/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,21 @@ in
{
# Workaround issue with those mappings being overwritten by some
# plugins, needs to be Lua since it needs to load later than
# vimscript
# vimscript, however for some reason vim.keymap.set is giving errors
# here
plugin = pkgs.writeText "50-completion-maps" "";
type = "lua";
config = /* lua */ ''
local opts = { silent = true, expr = true }
local keys = { 'i', 'c' }
vim.keymap.set(keys, '<C-j>', function() return vim.fn.pumvisible() ~= 0 and '<C-n>' or '<C-j>' end, opts)
vim.keymap.set(keys, '<C-k>', function() return vim.fn.pumvisible() ~= 0 and '<C-p>' or '<C-k>' end, opts)
vim.keymap.set(keys, '<CR>', function() return vim.fn.pumvisible() ~= 0 and '<C-y>' or '<CR>' end, opts)
vim.cmd [[
" insert mode
inoremap <expr> <C-j> pumvisible() ? "<C-n>" : "<C-j>"
inoremap <expr> <C-k> pumvisible() ? "<C-p>" : "<C-k>"
inoremap <expr> <CR> pumvisible() ? "<C-y>" : "<CR>"
" command line
cnoremap <expr> <C-j> pumvisible() ? "<C-n>" : "<C-j>"
cnoremap <expr> <C-k> pumvisible() ? "<C-p>" : "<C-k>"
cnoremap <expr> <CR> pumvisible() ? "<C-y>" : "<CR>"
]]
'';
}
]
Expand Down

0 comments on commit e55592a

Please sign in to comment.