summaryrefslogtreecommitdiff
path: root/lua/core/keymaps.lua
diff options
context:
space:
mode:
authorlistout <listout@protonmail.com>2022-08-02 01:10:05 +0530
committerlistout <listout@protonmail.com>2022-09-01 16:26:25 +0530
commit18edf9861d1b38591b51b42465b224d77736db04 (patch)
treed3c47be47a0bb532444556f307a33465f9cf79fe /lua/core/keymaps.lua
parentb5d497da359e7d5224e0462bd5b55c3d1caefd26 (diff)
nvim: moving init to lua
Signed-off-by: listout <listout@protonmail.com>
Diffstat (limited to 'lua/core/keymaps.lua')
-rw-r--r--lua/core/keymaps.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua
new file mode 100644
index 0000000..ca80862
--- /dev/null
+++ b/lua/core/keymaps.lua
@@ -0,0 +1,52 @@
+-----------------------------------------------------------
+-- Define keymaps of Neovim and installed plugins.
+-----------------------------------------------------------
+
+local function map(mode, lhs, rhs, opts)
+ local options = { noremap = true, silent = true }
+ if opts then
+ options = vim.tbl_extend('force', options, opts)
+ end
+ vim.api.nvim_set_keymap(mode, lhs, rhs, options)
+end
+
+-- Change leader to a comma
+vim.g.mapleader = ','
+
+-----------------------------------------------------------
+-- Neovim shortcuts
+-----------------------------------------------------------
+
+-- Disable arrow keys
+map('', '<up>', '<nop>')
+map('', '<down>', '<nop>')
+map('', '<left>', '<nop>')
+map('', '<right>', '<nop>')
+
+-- Reload configuration without restart nvim
+map('n', '<leader>r', ':so %<CR>')
+
+-- Change split orientation
+map('n', '<leader>tk', '<C-w>t<C-w>K') -- change vertical to horizontal
+map('n', '<leader>th', '<C-w>t<C-w>H') -- change horizontal to vertical
+
+map('n', 'M-j', ':resize -2<CR>')
+map('n', 'M-k', ':resize +2<CR>')
+map('n', 'M-l', ':vertical resize -2<CR>')
+map('n', 'M-h', ':vertical resize +2<CR>')
+
+map('t', 'C-w', '<C-\\><C-n><C-w>')
+
+map('n', '<leader>b', ':Buffers<CR>');
+map('n', '<leader>n', ':Files<CR>');
+
+vim.cmd([[
+ let $FZF_DEFAULT_COMMAND = "find * -path
+ \ '*/\.*' -prune -o -path 'node_modules/**'
+ \ -prune -o -path 'target/**' -prune -o -path
+ \'dist/**' -prune -o -type f -print -o -type
+ \ l -print 2> /dev/null"
+]])
+
+map('n', '<silent><leader>l', ':Buffers<CR>')
+