From 0b5f3fc96eddcd603de17644da8a962e0a93c04a Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Sun, 29 Dec 2024 13:55:26 +0530 Subject: moving global settings to plugin folder, for autoloading Signed-off-by: Brahmajit Das --- plugin/keymaps.lua | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 plugin/keymaps.lua (limited to 'plugin/keymaps.lua') diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua new file mode 100644 index 0000000..e47ff11 --- /dev/null +++ b/plugin/keymaps.lua @@ -0,0 +1,61 @@ +----------------------------------------------------------- +-- 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('', '', '') +map('', '', '') +map('', '', '') +map('', '', '') + +-- Reload configuration without restart nvim +map('n', 'r', ':so %') + +-- Change split orientation +map('n', 'tk', 'tK') -- change vertical to horizontal +map('n', 'th', 'tH') -- change horizontal to vertical + +map('n', 'M-j', ':resize -2') +map('n', 'M-k', ':resize +2') +map('n', 'M-l', ':vertical resize -2') +map('n', 'M-h', ':vertical resize +2') + +map('t', 'C-w', '') + +map('n', 'B', ':Buffers') -- FZF show open buffers +map('n', 'F', ':Files') -- FZF show files +map('n', 'A', ':Rg') -- FZF call ripgrep +map('n', 'C', ':Commits') -- FZF show git commits +map('n', 'M', ':Maps') -- FZF show normal mode mappings + +map('n', 'E', ':NvimTreeToggle') + +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } +keymap("i", "", "lua require'luasnip'.jump(1)", opts) +keymap("s", "", "lua require'luasnip'.jump(1)", opts) +keymap("i", "", "lua require'luasnip'.jump(-1)", opts) +keymap("s", "", "lua require'luasnip'.jump(-1)", opts) + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +-- vim.keymap.set('n', '[d', vim.diagnostic.jump({count=1, float=true})) +-- vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.diagnostic.config({ jump = { float = true }}) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- cgit v1.2.3