From 257d2fffcfe9234b64e22c6498b75bfafd53940d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Apr 2022 23:40:53 +0200 Subject: [PATCH] convert some keybindings to command center --- lua/my_keymappings.lua | 10 -- lua/setup/cmake.lua | 2 - lua/setup/my_command_center.lua | 168 +++++++++++++++++++++++++++++++- lua/setup/neogen.lua | 1 - lua/setup/project.lua | 1 - lua/setup/telescope.lua | 15 --- lua/setup/toggleterm.lua | 2 - 7 files changed, 163 insertions(+), 36 deletions(-) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua index 2523321..28cac05 100644 --- a/lua/my_keymappings.lua +++ b/lua/my_keymappings.lua @@ -14,10 +14,6 @@ utils.map('n', 'y', '"+y') utils.map('n', 'yy', '"+yy') -- Tabs -utils.map('n', '', ':tabnew .', { noremap = true, silent = true }) -utils.map('i', '', ':tabnew .', { noremap = true, silent = true }) --- utils.map('n', '', ':BufferLineCycleNext') --- utils.map('n', '', ':BufferLineCyclePrev') utils.map('n', '', ':tabnext', { noremap = true, silent = true }) utils.map('n', '', ':tabprevious', { noremap = true, silent = true }) -- Split movement @@ -25,12 +21,6 @@ utils.map('n', '', ':wincmd k', { noremap = true, silent = true }) utils.map('n', '', ':wincmd j', { noremap = true, silent = true }) utils.map('n', '', ':wincmd h', { noremap = true, silent = true }) utils.map('n', '', ':wincmd l', { noremap = true, silent = true }) --- Open a new vertical split window with Ctrl - F2 -utils.map('n', '', ':vsplit .', { noremap = true, silent = true }) -utils.map('i', '', ':vsplit .', { noremap = true, silent = true }) --- Open a new horizontal split window with Shift - F2 -utils.map('n', '', ':split .', { noremap = true, silent = true }) -utils.map('i', '', ':split .', { noremap = true, silent = true }) utils.map('n', '', ':wa') diff --git a/lua/setup/cmake.lua b/lua/setup/cmake.lua index f800b95..663d5fe 100644 --- a/lua/setup/cmake.lua +++ b/lua/setup/cmake.lua @@ -5,8 +5,6 @@ require('cmake').setup({ parameters_file = 'neovim.json', -- JSON file to store information about selected target, run arguments and build type. build_dir = '{cwd}/build_nvim', -- Build directory. The expressions `{cwd}`, `{os}` and `{build_type}` will be expanded with the corresponding text values. }) -utils.map('n', '', ':CMake build:copen') - -- msbuild errorformat opt.errorformat:append('\\ %#%f(%l\\\\\\,%c):\\ %m') -- cl.exe errorformat diff --git a/lua/setup/my_command_center.lua b/lua/setup/my_command_center.lua index 4be83c3..7299636 100644 --- a/lua/setup/my_command_center.lua +++ b/lua/setup/my_command_center.lua @@ -1,5 +1,163 @@ -require("telescope").load_extension('command_center') - -local command_center = require("command_center") -local noremap = {noremap = true} -local silent_noremap = {noremap = true, silent = true} +require('telescope').load_extension('command_center') + +local command_center = require('command_center') +local noremap = { noremap = true } +local silent_noremap = { noremap = true, silent = true } + +command_center.add({ + { + description = 'Open command_center', + command = 'Telescope command_center', + keybindings = { + { 'n', 'p', noremap }, + { 'v', 'p', noremap }, + }, + }, + { + description = 'Open a new tab', + command = 'tabnew .', + keybindings = { + { 'n', 'F2', silent_noremap }, + }, + }, + { + description = 'Open a new vertical split', + command = 'vsplit .', + keybindings = { + { 'n', '', silent_noremap }, + }, + }, + { + description = 'Open a new horizontal split', + command = 'split .', + keybindings = { + { 'n', '', silent_noremap }, + }, + }, + { + description = 'CMake build all', + command = 'CMake build_all', + }, + { + description = 'CMake build selected target', + command = 'CMake build', + keybindings = { + { 'n', 'F5', silent_noremap }, + }, + }, + { + description = 'CMake configure', + command = 'CMake configure', + }, + { + description = 'CMake select target', + command = 'CMake select_target', + }, + { + description = 'CMake clear cache', + command = 'CMake clear_cache', + }, + { + description = 'List snippets', + command = 'LuaSnipListAvailable', + }, + { + description = 'Add comment', + command = 'Neogen', + keybindings = { + { 'n', 'n', silent_noremap }, + }, + }, + { + description = 'Select project', + command = 'Telescope projects', + keybindings = { + { 'n', 'p', silent_noremap }, + }, + }, + { + description = 'Find file', + command = 'lua require("telescope.builtin").find_files({no_ignore=true})', + keybindings = { + { 'n', 'f', silent_noremap }, + }, + }, + { + description = 'Find file (with gitignore)', + command = 'lua require("telescope.builtin").find_files({no_ignore=false})', + keybindings = { + { 'n', '', silent_noremap }, + }, + }, + { + description = 'Find git files', + command = 'Telescope git_files', + keybindings = { + { 'n', 'g', silent_noremap }, + }, + }, + { + description = 'Find old files', + command = 'Telescope oldfiles', + keybindings = { + { 'n', 'o', silent_noremap }, + }, + }, + { + description = 'Open command history', + command = 'Telescope command_history', + keybindings = { + { 'n', 'h', silent_noremap }, + }, + }, + { + description = 'Select buffer', + command = 'Telescope buffers', + keybindings = { + { 'n', 'b', silent_noremap }, + }, + }, + { + description = 'Quickfix list with telescope', + command = 'Telescope quickfix', + keybindings = { + { 'n', 'q', silent_noremap }, + }, + }, + { + description = 'Search in project', + command = 'Telescope live_grep', + keybindings = { + { 'n', 'l', silent_noremap }, + { 'n', '', silent_noremap }, + }, + }, + { + description = 'Open clipboard history', + command = 'Telescope neoclip', + keybindings = { + { 'n', '', silent_noremap }, + }, + }, + { + description = 'Open jumplist', + command = 'Telescope jumplist', + keybindings = { + { 'n', 'j', silent_noremap }, + }, + }, + { + description = 'Find in buffer', + command = 'Telescope current_buffer_fuzzy_find', + keybindings = { + { 'n', '', silent_noremap }, + }, + }, + { + description = 'Open lazygit', + command = 'lua _lazygit_toggle()', + keybindings = { + { 'n', 'g', silent_noremap }, + }, + }, +}) diff --git a/lua/setup/neogen.lua b/lua/setup/neogen.lua index 42d4128..5a10946 100644 --- a/lua/setup/neogen.lua +++ b/lua/setup/neogen.lua @@ -20,4 +20,3 @@ require('neogen').setup({ }) local utils = require('utils') -utils.map('n', 'n', 'Neogen', { noremap = true, silent = true }) diff --git a/lua/setup/project.lua b/lua/setup/project.lua index 9030be2..dbde7f7 100644 --- a/lua/setup/project.lua +++ b/lua/setup/project.lua @@ -4,4 +4,3 @@ require('project_nvim').setup({ ignore_lsp = { 'null-ls' }, }) require('telescope').load_extension('projects') -utils.map('n', 'p', 'Telescope projects') diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index be0b5a8..777a2e5 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -50,18 +50,3 @@ require('telescope').setup({ require('telescope').load_extension('fzf') -local utils = require('utils') -utils.map('n', 'f', "lua require('telescope.builtin').find_files({no_ignore=true})") -utils.map('n', '', 'lua require("telescope.builtin").find_files({no_ignore=true})') -utils.map('n', 'g', 'Telescope git_files') -utils.map('n', 'o', 'Telescope oldfiles') -utils.map('n', 'h', 'Telescope command_history') -utils.map('v', 'h', 'Telescope command_history') -utils.map('n', '', 'Telescope commands') -utils.map('n', 'b', 'Telescope buffers') -utils.map('n', 'q', 'Telescope quickfix') -utils.map('n', 'l', 'Telescope live_grep') -utils.map('n', '', 'Telescope live_grep') -utils.map('n', '', 'Telescope neoclip') -utils.map('n', 'j', 'Telescope jumplist') -utils.map('n', '', 'Telescope current_buffer_fuzzy_find') diff --git a/lua/setup/toggleterm.lua b/lua/setup/toggleterm.lua index 2bb2040..b0b22c4 100644 --- a/lua/setup/toggleterm.lua +++ b/lua/setup/toggleterm.lua @@ -28,5 +28,3 @@ local lazygit = Terminal:new({ function _lazygit_toggle() lazygit:toggle() end - -vim.api.nvim_set_keymap('n', 'g', 'lua _lazygit_toggle()', { noremap = true, silent = true })