From 801f9725b46ecff0674262576874cea0c755de40 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 30 Oct 2020 11:38:04 +0530 Subject: [PATCH] nvim: Add easy-align --- nvim/.config/nvim/lua/modules/easyalign.lua | 21 +++++++++++++++++++++ nvim/.config/nvim/lua/plugins.lua | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 nvim/.config/nvim/lua/modules/easyalign.lua diff --git a/nvim/.config/nvim/lua/modules/easyalign.lua b/nvim/.config/nvim/lua/modules/easyalign.lua new file mode 100644 index 0000000..c2aef34 --- /dev/null +++ b/nvim/.config/nvim/lua/modules/easyalign.lua @@ -0,0 +1,21 @@ +vim.api.nvim_set_keymap('x', 'ga', '(EasyAlign)', {}) +vim.api.nvim_set_keymap('n', 'ga', '(EasyAlign)', {}) + +vim.g.easy_align_delimiters = { + [';'] = { pattern = ';' , left_margin = 0 }, + ['['] = { pattern = '[' , left_margin = 1, right_margin = 0 }, + [']'] = { pattern = ']' , left_margin = 0, right_margin = 1 }, + [','] = { pattern = ',' , left_margin = 0, right_margin = 1 }, + [')'] = { pattern = ')' , left_margin = 0, right_margin = 0 }, + ['('] = { pattern = '(' , left_margin = 0, right_margin = 0 }, + ['='] = { pattern = [[<\?=>\?]], left_margin = 1, right_margin = 1 }, + ['|'] = { pattern = [[|\?|]] , left_margin = 1, right_margin = 1 }, + ['&'] = { pattern = [[&\?&]] , left_margin = 1, right_margin = 1 }, + [':'] = { pattern = ':' , left_margin = 1, right_margin = 1 }, + ['?'] = { pattern = '?' , left_margin = 1, right_margin = 1 }, + ['<'] = { pattern = '<' , left_margin = 1, right_margin = 0 }, + ['\\'] = { pattern = '\\' , left_margin = 1, right_margin = 0 }, + ['+'] = { pattern = '+' , left_margin = 1, right_margin = 1 }, + ['>'] = { pattern = '->' , left_margin = 1, right_margin = 1 }, + ['#'] = { pattern = '#-' , left_margin = 1, right_margin = 1 } +} diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index aee77aa..23df5ff 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -115,6 +115,11 @@ local init = function () use 'lambdalisue/edita.vim' -- Take care of sudo use 'lambdalisue/suda.vim' + -- Alignment + use { + 'junegunn/vim-easy-align', + config = "require('modules.easyalign')" + } -- LSP use { 'neovim/nvim-lspconfig',