convert some keybindings to command center

This commit is contained in:
Oliver Hartmann 2022-04-13 23:40:53 +02:00
parent 3dc493ff7e
commit 257d2fffcf
7 changed files with 163 additions and 36 deletions

View File

@ -14,10 +14,6 @@ utils.map('n', '<leader>y', '"+y')
utils.map('n', '<leader>yy', '"+yy')
-- Tabs
utils.map('n', '<F2>', ':tabnew .<CR>', { noremap = true, silent = true })
utils.map('i', '<F2>', '<Esc>:tabnew .<CR>', { noremap = true, silent = true })
-- utils.map('n', '<S-Right>', ':BufferLineCycleNext<CR>')
-- utils.map('n', '<S-Left>', ':BufferLineCyclePrev<CR>')
utils.map('n', '<S-Right>', ':tabnext<CR>', { noremap = true, silent = true })
utils.map('n', '<S-Left>', ':tabprevious<CR>', { noremap = true, silent = true })
-- Split movement
@ -25,12 +21,6 @@ utils.map('n', '<A-Up>', ':wincmd k<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Down>', ':wincmd j<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Left>', ':wincmd h<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Right>', ':wincmd l<CR>', { noremap = true, silent = true })
-- Open a new vertical split window with Ctrl - F2
utils.map('n', '<C-F2>', ':vsplit .<CR>', { noremap = true, silent = true })
utils.map('i', '<C-F2>', '<Esc>:vsplit .<CR>', { noremap = true, silent = true })
-- Open a new horizontal split window with Shift - F2
utils.map('n', '<S-F2>', ':split .<CR>', { noremap = true, silent = true })
utils.map('i', '<S-F2>', '<Esc>:split .<CR>', { noremap = true, silent = true })
utils.map('n', '<C-S>', ':wa<CR>')

View File

@ -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', '<F5>', ':CMake build<CR>:copen<CR>')
-- msbuild errorformat
opt.errorformat:append('\\ %#%f(%l\\\\\\,%c):\\ %m')
-- cl.exe errorformat

View File

@ -1,5 +1,163 @@
require("telescope").load_extension('command_center')
require('telescope').load_extension('command_center')
local command_center = require("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', '<Leader>p', noremap },
{ 'v', '<Leader>p', noremap },
},
},
{
description = 'Open a new tab',
command = 'tabnew .',
keybindings = {
{ 'n', 'F2', silent_noremap },
},
},
{
description = 'Open a new vertical split',
command = 'vsplit .',
keybindings = {
{ 'n', '<C-F2>', silent_noremap },
},
},
{
description = 'Open a new horizontal split',
command = 'split .',
keybindings = {
{ 'n', '<S-F2>', 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', '<leader>n', silent_noremap },
},
},
{
description = 'Select project',
command = 'Telescope projects',
keybindings = {
{ 'n', '<space>p', silent_noremap },
},
},
{
description = 'Find file',
command = 'lua require("telescope.builtin").find_files({no_ignore=true})',
keybindings = {
{ 'n', '<leader>f', silent_noremap },
},
},
{
description = 'Find file (with gitignore)',
command = 'lua require("telescope.builtin").find_files({no_ignore=false})',
keybindings = {
{ 'n', '<C-p>', silent_noremap },
},
},
{
description = 'Find git files',
command = 'Telescope git_files',
keybindings = {
{ 'n', '<leader>g', silent_noremap },
},
},
{
description = 'Find old files',
command = 'Telescope oldfiles',
keybindings = {
{ 'n', '<leader>o', silent_noremap },
},
},
{
description = 'Open command history',
command = 'Telescope command_history',
keybindings = {
{ 'n', '<leader>h', silent_noremap },
},
},
{
description = 'Select buffer',
command = 'Telescope buffers',
keybindings = {
{ 'n', '<leader>b', silent_noremap },
},
},
{
description = 'Quickfix list with telescope',
command = 'Telescope quickfix',
keybindings = {
{ 'n', '<leader>q', silent_noremap },
},
},
{
description = 'Search in project',
command = 'Telescope live_grep',
keybindings = {
{ 'n', '<leader>l', silent_noremap },
{ 'n', '<c-s-f>', silent_noremap },
},
},
{
description = 'Open clipboard history',
command = 'Telescope neoclip',
keybindings = {
{ 'n', '<C-y>', silent_noremap },
},
},
{
description = 'Open jumplist',
command = 'Telescope jumplist',
keybindings = {
{ 'n', '<leader>j', silent_noremap },
},
},
{
description = 'Find in buffer',
command = 'Telescope current_buffer_fuzzy_find',
keybindings = {
{ 'n', '<c-f>', silent_noremap },
},
},
{
description = 'Open lazygit',
command = 'lua _lazygit_toggle()',
keybindings = {
{ 'n', '<Space>g', silent_noremap },
},
},
})

View File

@ -20,4 +20,3 @@ require('neogen').setup({
})
local utils = require('utils')
utils.map('n', '<leader>n', '<cmd>Neogen<cr>', { noremap = true, silent = true })

View File

@ -4,4 +4,3 @@ require('project_nvim').setup({
ignore_lsp = { 'null-ls' },
})
require('telescope').load_extension('projects')
utils.map('n', '<space>p', '<cmd>Telescope projects<cr>')

View File

@ -50,18 +50,3 @@ require('telescope').setup({
require('telescope').load_extension('fzf')
local utils = require('utils')
utils.map('n', '<leader>f', "<cmd>lua require('telescope.builtin').find_files({no_ignore=true})<cr>")
utils.map('n', '<C-p>', '<cmd>lua require("telescope.builtin").find_files({no_ignore=true})<cr>')
utils.map('n', '<leader>g', '<cmd>Telescope git_files<cr>')
utils.map('n', '<leader>o', '<cmd>Telescope oldfiles<cr>')
utils.map('n', '<leader>h', '<cmd>Telescope command_history<cr>')
utils.map('v', '<leader>h', '<cmd>Telescope command_history<cr>')
utils.map('n', '<C-S-p>', '<cmd>Telescope commands<cr>')
utils.map('n', '<leader>b', '<cmd>Telescope buffers<cr>')
utils.map('n', '<leader>q', '<cmd>Telescope quickfix<cr>')
utils.map('n', '<leader>l', '<cmd>Telescope live_grep<cr>')
utils.map('n', '<c-s-f>', '<cmd>Telescope live_grep<cr>')
utils.map('n', '<C-y>', '<cmd>Telescope neoclip<cr>')
utils.map('n', '<leader>j', '<cmd>Telescope jumplist<cr>')
utils.map('n', '<c-f>', '<cmd>Telescope current_buffer_fuzzy_find<cr>')

View File

@ -28,5 +28,3 @@ local lazygit = Terminal:new({
function _lazygit_toggle()
lazygit:toggle()
end
vim.api.nvim_set_keymap('n', '<Space>g', '<cmd>lua _lazygit_toggle()<CR>', { noremap = true, silent = true })