From bce0373dfbf7c9f70608a4baa46833fcb8f65f17 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 5 Dec 2022 14:44:29 +0100 Subject: [PATCH] move some keymaps to the corresponding plugin configs --- lua/setup/comment.lua | 16 ++++- lua/setup/my_legendary.lua | 116 ++++++++----------------------------- lua/setup/neogen.lua | 49 +++++++++------- lua/setup/telescope.lua | 71 +++++++++++++++++++++++ 4 files changed, 138 insertions(+), 114 deletions(-) diff --git a/lua/setup/comment.lua b/lua/setup/comment.lua index 9438d50..09302fb 100644 --- a/lua/setup/comment.lua +++ b/lua/setup/comment.lua @@ -1,3 +1,13 @@ -require('Comment').setup({ - mappings = false, -}) +require('Comment').setup({ + mappings = false, +}) +require('legendary').keymap( + { + '', + { + n = '(comment_toggle_linewise_current)', + v = '(comment_toggle_linewise_visual)gv' + }, + description = 'Toggle comment' + } +) diff --git a/lua/setup/my_legendary.lua b/lua/setup/my_legendary.lua index 63f01b1..221bd8e 100644 --- a/lua/setup/my_legendary.lua +++ b/lua/setup/my_legendary.lua @@ -1,94 +1,36 @@ require('legendary').setup({ + default_opts = { + keymaps = { silent = true }, + commands = {}, + autocmds = {}, + }, keymaps = { { 'p', - ':Legendary keymaps', + function() + require("legendary").find() + end, description = 'legendary keymaps', mode = { 'n', 'x', 'i' } }, { - 'F2', - 'tabnew .', + '', + ':tabnew .', description = 'Open a new tab', }, { '', - 'vsplit .', + ':vsplit .', description = 'Open a new vertical split', }, { '', - 'split .', + ':split .', description = 'Open a new horizontal split', }, - { - 'n', - 'Neogen', - description = 'Add comment', - }, - { - 'p', - 'Telescope projects', - description = 'Select project', - }, - { - 'f', - 'lua require("telescope.builtin").find_files({no_ignore=true})', - description = 'Find file', - }, - { - 'g', - 'lua project_files()', - description = 'Find git files', - }, - { - 'o', - 'Telescope oldfiles', - description = 'Find old files', - }, - { - 'h', - 'Telescope command_history', - description = 'Open command history', - }, - { - 'b', - 'Telescope buffers', - description = 'Select buffer', - }, - { - 'q', - 'Telescope quickfix', - description = 'Quickfix list with telescope', - }, - { - 'l', - 'Telescope live_grep', - description = 'Search in project', - }, - { - '', - 'Telescope neoclip', - description = 'Open clipboard history', - }, - { - 'j', - 'Telescope jumplist', - description = 'Open jumplist', - }, - { - '', - 'Telescope current_buffer_fuzzy_find', - description = 'Find in buffer', - }, - { - 'd', - 'Telescope grep_string', - description = 'Find in workspace', - }, { 'g', - 'lua _lazygit_toggle()', + ':lua _lazygit_toggle()', description = 'Open lazygit', }, { @@ -111,64 +53,56 @@ require('legendary').setup({ '(YankyCycleBackward)', description = 'Yanky cycle backward', }, - { - '', - { - n = '(comment_toggle_linewise_current)', - v = '(comment_toggle_linewise_visual)gv' - }, - description = 'Toggle comment' - }, { 's', - 'AerialToggle', + ':AerialToggle', description = 'Symbols outline', }, }, commands = { { - 'Octo pr list', + ':Octo pr list', description = 'Github list PRs', }, { - 'Octo pr checkout', + ':Octo pr checkout', description = 'Github checkout PR', }, { - 'Octo pr browser', + ':Octo pr browser', description = 'Github open PR in browser', }, { - 'set guifont=JetBrainsMonoNL\\ NF:h12', + ':set guifont=JetBrainsMonoNL\\ NF:h12', description = 'Big font size', }, { - 'set guifont=JetBrainsMonoNL\\ NF:h9', + ':set guifont=JetBrainsMonoNL\\ NF:h9', description = 'Reset font size', }, { - 'CMake build_all', + ':CMake build_all', description = 'CMake build all', }, { - 'CMake configure', + ':CMake configure', description = 'CMake configure', }, { - 'CMake select_target', + ':CMake select_target', description = 'CMake select target', }, { - 'CMake clear_cache', + ':CMake clear_cache', description = 'CMake clear cache', }, { - 'LuaSnipListAvailable', + ':LuaSnipListAvailable', description = 'List snippets', }, { - "lua require('telescope.builtin').live_grep({ prompt_title = 'find string in open buffers...', grep_open_files = true })", + ":lua require('telescope.builtin').live_grep({ prompt_title = 'find string in open buffers...', grep_open_files = true })", description = 'Search in open files', }, diff --git a/lua/setup/neogen.lua b/lua/setup/neogen.lua index 4968fec..df16773 100644 --- a/lua/setup/neogen.lua +++ b/lua/setup/neogen.lua @@ -1,20 +1,29 @@ -require('neogen').setup({ - enabled = true, - languages = { - cpp = { - template = { - annotation_convention = 'custom', - custom = { - { nil, '/// file', { no_results = true, type = { 'file' } } }, - { nil, '/// $1', { no_results = true, type = { 'func', 'file' } } }, - { nil, '', { no_results = true, type = { 'file' } } }, - - { nil, '/// $1', { type = { 'func' } } }, - { 'tparam', '/// \\tparam %s $1' }, - { 'parameters', '/// \\param %s $1' }, - { 'return_statement', '/// \\return $1' }, - }, - }, - }, - }, -}) +require('neogen').setup({ + enabled = true, + languages = { + cpp = { + template = { + annotation_convention = 'custom', + custom = { + { nil, '/// file', { no_results = true, type = { 'file' } } }, + { nil, '/// $1', { no_results = true, type = { 'func', 'file' } } }, + { nil, '', { no_results = true, type = { 'file' } } }, + + { nil, '/// $1', { type = { 'func' } } }, + { 'tparam', '/// \\tparam %s $1' }, + { 'parameters', '/// \\param %s $1' }, + { 'return_statement', '/// \\return $1' }, + }, + }, + }, + }, +}) +require('legendary').keymaps( + { + { + 'n', + ':Neogen', + description = 'Add comment', + } + } +) diff --git a/lua/setup/telescope.lua b/lua/setup/telescope.lua index d379eb6..ce7abbc 100644 --- a/lua/setup/telescope.lua +++ b/lua/setup/telescope.lua @@ -53,3 +53,74 @@ require('telescope').setup({ }) require('telescope').load_extension('fzf') + +Project_files = function() + local opts = {} -- define here if you want to define something + local ok = pcall(require "telescope.builtin".git_files, opts) + if not ok then require "telescope.builtin".find_files(opts) end +end + +require('legendary').keymaps( + { + { + 'p', + ':Telescope projects', + description = 'Select project', + }, + { + 'f', + ':lua require("telescope.builtin").find_files({no_ignore=true})', + description = 'Find file', + }, + { + 'g', + ':lua Project_files()', + description = 'Find git files', + }, + { + 'o', + ':Telescope oldfiles', + description = 'Find old files', + }, + { + 'h', + ':Telescope command_history', + description = 'Open command history', + }, + { + 'b', + ':Telescope buffers', + description = 'Select buffer', + }, + { + 'q', + ':Telescope quickfix', + description = 'Quickfix list with telescope', + }, + { + 'l', + ':Telescope live_grep', + description = 'Search in project', + }, + { + '', + ':Telescope neoclip', + description = 'Open clipboard history', + }, + { + 'j', + ':Telescope jumplist', + description = 'Open jumplist', + }, + { + '', + ':Telescope current_buffer_fuzzy_find', + description = 'Find in buffer', + }, + { + 'd', + ':Telescope grep_string', + description = 'Find in workspace', + } + } +)