local keymap = vim.api.nvim_set_keymap local opts = { noremap = true, silent = true } local term_opts = { silent = true } --Remap space as leader key keymap('', '', '', opts) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Modes -- normal_mode = 'n', -- insert_mode = 'i', -- visual_mode = 'v', -- visual_block_mode = 'x', -- term_mode = 't', -- command_mode = 'c', -- Normal -- -- Shortcutting split navigation keymap('n', '', 'h', opts) keymap('n', '', 'j', opts) keymap('n', '', 'k', opts) keymap('n', '', 'l', opts) -- Resize with arrows keymap('n', '', 'resize -2', opts) keymap('n', '', 'resize +2', opts) keymap('n', '', 'vertical resize -2', opts) keymap('n', '', 'vertical resize +2', opts) -- Navigate buffers keymap('n', '', 'bnext', opts) keymap('n', '', 'bprevious', opts) -- Move text up and down keymap('n', '', 'm .+1==gi', opts) keymap('n', '', 'm .-2==gi', opts) -- Insert -- -- Press jk fast to exit insert mode keymap('i', 'jk', '', opts) -- Visual -- -- Stay in indent mode keymap('v', '<', '', '>gv', opts) -- Move text up and down keymap('v', '', 'm .+1==', opts) keymap('v', '', 'm .-2==', opts) keymap('v', 'p', '"_dP', opts) -- Visual Block -- -- Move text up and down keymap('x', 'J', 'move ">+1gv-gv', opts) keymap('x', 'K', 'move "<-2gv-gv', opts) keymap('x', '', 'move ">+1gv-gv', opts) keymap('x', '', 'move "<-2gv-gv', opts) -- Terminal -- -- Better terminal navigation -- keymap('t', '', 'h', term_opts) -- keymap('t', '', 'j', term_opts) -- keymap('t', '', 'k', term_opts) -- keymap('t', '', 'l', term_opts) keymap('n', 'n', ':NvimTreeFocus', opts) keymap('n', 'C-t', ':NvimTreeToggle', opts) keymap('n', 'C-f', ':NvimTreeFindFile', opts) keymap('n', '', ':NvimTreeRefresh', opts) -- Enable/Disable auto comment keymap('', 'c', 'setlocal formatoption-=CRo', {}) keymap('', 'C', 'setlocal formatoption=CRo', {}) -- Enable spell checking, s for spell check keymap('', 's', 'setlocal spell! spelllang=eu_us', {}) -- Enable / Disable auto indent keymap('', 'i', 'setlocal autoindent', {}) keymap('', 'I', 'setlocal noautoindent', {}) -- Moving line up or down by one line keymap('', '', 'm -2', opts) keymap('', '', 'm -2', opts) keymap('', '', 'm +1', opts) keymap('', '', 'm +1', opts) -- Find files using Telescope command-line keymap('n', 'ff', 'Telescope find_files hidden=true', opts) keymap('n', 'fg', 'Telescope live_grep', opts) keymap('n', 'fb', 'Telescope buffers', opts) keymap('n', 'fh', 'Telescope help_tags', opts) -- Alias 'replace all' to S keymap('n', 'S', 's%//', opts) -- " run current script with python3 by CTRL+R in command and insert mode -- autocmd FileType python map wexec '!python3' shellescape(@%, 1) -- autocmd FileType python imap wexec '!python3' shellescape(@%, 1) -- autocmd FileType rust map wexec '!cargo run' -- autocmd FileType rust imap wexec '!cargo run' -- autocmd BufWritePre,InsertLeave *.{py,rs,html,css,md,lua} Neoformat -- let g:neoformat_enabled_python = ['autopep8'] -- let g:neoformat_try_node_exe = 1