return function()
  require('legendary').setup {
    select_prompt = " Command Palette ",
    keymaps = {
      -- Development
      {
        ',u',
        ':<C-u>Lazy update<CR>',
        mode = 'n',
        description = '[System] Update plugins',
        opts = { silent = true, remap = false },
      },
      {
        ',s',
        ':<C-u>source %<CR>',
        mode = 'n',
        description = '[System] Load vim config',
        opts = { silent = true, remap = false },
      },
      {
        '*',
        "<Plug>(asterisk-*)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'n',
        description = '[Search] hlslens *',
        opts = { silent = true, remap = true },
      },
      {
        '*',
        "<Plug>(asterisk-*)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'v',
        description = '[Search] hlslens *',
        opts = { silent = true, remap = true },
      },
      {
        '#',
        "<Plug>(asterisk-#)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'n',
        description = '[Search] hlslens #',
        opts = { silent = true, remap = true },
      },
      {
        '#',
        "<Plug>(asterisk-#)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'v',
        description = '[Search] hlslens #',
        opts = { silent = true, remap = true },
      },
      {
        'g*',
        "<Plug>(asterisk-g*)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'n',
        description = '[Search] hlslens g*',
        opts = { silent = true, remap = true },
      },
      {
        'g*',
        "<Plug>(asterisk-g*)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'v',
        description = '[Search] hlslens g*',
        opts = { silent = true, remap = true },
      },
      {
        'g*',
        "<Plug>(asterisk-g*)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'v',
        description = '[Search] hlslens g*',
        opts = { silent = true, remap = true },
      },
      {
        'g#',
        "<Plug>(asterisk-g#)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'n',
        description = '[Search] hlslens g#',
        opts = { silent = true, remap = true },
      },
      {
        'g#',
        "<Plug>(asterisk-g#)<Cmd>lua require('hlslens').start()<CR>",
        mode = 'v',
        description = '[Search] hlslens g#',
        opts = { silent = true, remap = true },
      },
      -- <leader>
      {
        '<leader><space>',
        ':<C-u>HopChar1<CR>',
        mode = '',
        description = '[Motion] Hop anywhere with 1 char match',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>a',
        ':lua vim.lsp.buf.code_action()<CR>',
        mode = 'n',
        description = '[LSP] Code Action',
        opts = { remap = false, silent = true },
      },
      {
        "<leader>b",
        ":<C-u>Telescope file_browser<CR>",
        mode = "n",
        description = '[File] Open file browser at root',
        opts = { remap = false, silent = true },
      },
      {
        "<leader>B",
        ":<C-u>Telescope file_browser path=%:p:h select_buffer=true<CR>",
        mode = "n",
        description = '[File] Open file browser at current dir',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>c',
        ':<C-u>noh<CR>',
        mode = "n",
        description = '[Search] Clear search',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>d',
        ':lua vim.lsp.buf.definition()<CR>',
        mode = 'n',
        description = '[LSP] Go to definition',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>f',
        ':<C-u>Telescope current_buffer_fuzzy_find<CR>',
        mode = 'n',
        description = '[Search] Find in file',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>F',
        ':<C-u>Telescope live_grep<CR>',
        mode = 'n',
        description = '[Search] Find in project',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>h',
        '<cmd>lua require("spectre").open_file_search()<CR>',
        mode = 'n',
        description = '[Search] Open search/replace pane for file',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>H',
        '<cmd>lua require("spectre").open()<CR>',
        mode = 'n',
        description = '[Search] Open search/replace pane for project',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>i',
        ':lua vim.lsp.buf.implementation()<CR>',
        mode = 'n',
        description = '[LSP] Go to implementation',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>dj',
        ':lua vim.diagnostic.goto_next()<CR>',
        mode = 'n',
        description = '[Diagnostic] Go to next',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>dk',
        ':lua vim.diagnostic.goto_prev()<CR>',
        mode = 'n',
        description = '[Diagnostic] Go to previous',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>l',
        ':lua vim.lsp.buf.format { async = true }<CR>',
        mode = 'n',
        description = '[LSP] Format',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>m',
        ':lua vim.lsp.buf.rename()<CR>',
        mode = 'n',
        description = '[Refactor] Rename',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>m',
        ':lua vim.lsp.buf.rename()<CR>',
        mode = 'v',
        description = '[Refactor] Rename',
        opts = { remap = false, silent = true },
      },
      {
        "<Leader>nf",
        ":lua require('neogen').generate()<CR>",
        mode = "n",
        description = '[Comment] Generate doc for function',
        opts = { remap = false, silent = true },
      },
      {
        "<Leader>nc",
        ":lua require('neogen').generate({ type = 'class' }}<CR>",
        mode = "n",
        description = '[Comment] Generate doc for class',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>p',
        ':<C-u> Legendary keymaps<CR>',
        mode = 'n',
        description = '[Keymap] Find command',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>r',
        ':<C-u>Telescope lsp_references<CR>',
        mode = 'n',
        description = '[LSP] Go to reference',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>sh',
        ":<C-u>SidewaysLeft<CR>",
        mode = "n",
        description = '[Edit] Move argument to left',
        opts = { remap = false, silent = true },
      },
      {
        "<leader>sl",
        ":<C-u>SidewaysRight<CR>",
        mode = "n",
        description = '[Edit] Move argument to right',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>ss',
        "<cmd>lua require'substitute'.operator()<CR>",
        mode = "n",
        description = '[Edit] Replace chats with operator',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>ss',
        "<cmd>lua require'substitute'.visual()<CR>",
        mode = "x",
        description = '[Edit] Replace chats with operator',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>t',
        ':lua vim.lsp.buf.type_definition()<CR>',
        mode = 'n',
        description = '[LSP] Go to type definition',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>v',
        '<cmd>lua require("spectre").open_visual({select_word=true}<CR>',
        mode = 'n',
        description = '[Search] Open search/replace pane at cursor',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>V',
        '<cmd>lua require("spectre").open_visual({select_word=true}<CR>',
        mode = 'v',
        description = '[Search] Open search/replace pane at cursor',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>/',
        '<Plug>(comment_toggle_linewise_current)',
        mode = 'n',
        description = '[Comment] Toggle comment',
        opts = { remap = true, silent = true },
      },
      {
        '<leader>/',
        '<Plug>(comment_toggle_blockwise_visual)',
        mode = 'v',
        description = '[Comment] Toggle comment',
        opts = { remap = true, silent = true },
      },
      {
        '<leader>;',
        ':<C-u>CommaOrSemiColon<CR>',
        mode = 'n',
        description = '[Edit] Add comma or semicolon at the end',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>,',
        ':<C-u>SplitjoinSplit<CR>',
        mode = 'n',
        description = '[Edit] Convert single line to multi lines',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>.',
        ':<C-u>SplitjoinJoin<CR>',
        mode = 'n',
        description = '[Edit] Convert multi lines to single line',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gj',
        "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'",
        mode = 'n',
        description = '[Git] Go to next hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gk',
        "&diff ? ']c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'",
        mode = 'n',
        description = '[Git] Go to prev hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gs',
        '<cmd>lua require"gitsigns".stage_hunk()<CR>',
        mode = 'n',
        description = '[Git] Stage hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gs',
        '<cmd>lua require"gitsigns".stage_hunk()<CR>',
        mode = 'v',
        description = '[Git] Stage hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gu',
        '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
        mode = 'n',
        description = '[Git] Undo stage hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gr',
        '<cmd>lua require"gitsigns".reset_hunk()<CR>',
        mode = 'n',
        description = '[Git] Reset hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gr',
        '<cmd>lua require"gitsigns".reset_hunk()<CR>',
        mode = 'v',
        description = '[Git] Reset hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gp',
        '<cmd>lua require"gitsigns".preview_hunk()<CR>',
        mode = 'n',
        description = '[Git] Preview hunk',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gb',
        '<cmd>lua require"gitsigns".blame_line()<CR>',
        mode = 'n',
        description = '[Git] Blame line',
        opts = { remap = false, silent = true },
      },
      {
        '<leader>gd',
        '<cmd>lua require"gitsigns".diffthis()<CR>',
        mode = 'n',
        description = '[Git] Show Diff',
        opts = { remap = false, silent = true },
      },

      -- <A->
      {
        '<A-a>',
        ':<C-u>EasyAlign<CR>',
        mode = 'n',
        description = '[Edit] Align code',
        opts = { remap = false, silent = false },
      },
      {
        '<A-a>',
        ':<C-u>EasyAlign<CR>',
        mode = 'v',
        description = '[Edit] Align code',
        opts = { remap = false, silent = false },
      },
      {
        '<A-b>',
        ':<C-u>Telescope git_branches<CR>',
        mode = 'n',
        description = '[Git] Show Branches',
        opts = { remap = false, silent = true },
      },
      {
        '<A-c>',
        ':<C-u>Telescope commands<CR>',
        mode = 'n',
        description = '[Command] Show List',
        opts = { remap = false, silent = true },
      },
      {
        "<A-d>",
        "<cmd>FloatermNew lazydocker<CR>",
        mode = "n",
        description = '[Docker] Open lazydocker',
        opts = { remap = false, silent = true },
      },
      {
        '<A-e>',
        ':<C-u>Telescope buffers<CR>',
        mode = 'n',
        description = '[Buffer] Search buffer',
        opts = { remap = false, silent = true },
      },
      {
        "<A-g>",
        "<cmd>FloatermNew lazygit<CR>",
        mode = "n",
        description = '[Git] Open lazygit',
        opts = { remap = false, silent = true },
      },
      {
        '<A-G>',
        ":<C-u>GHInteractive<CR>",
        mode = 'n',
        description = '[Git] Open current line in GitHub',
        opts = { remap = false, silent = true },
      },
      {
        '<A-h>',
        ':<C-u>Telescope command_history<CR>',
        mode = 'n',
        description = '[Command] Search hisotory',
        opts = { remap = false, silent = true },
      },
      {
        '<A-i>',
        ':<C-u>Telescope diagnostics<CR>',
        mode = 'n',
        description = '[Diagnostic] Show list',
        opts = { remap = false, silent = true },
      },
      {
        "<A-j>",
        ":m .+1<CR>==",
        mode = "n",
        description = '[Edit] Move current line down',
        opts = { remap = false, silent = true },
      },
      {
        "<A-j>",
        ":m '>+1<CR>gv=gv",
        mode = "v",
        description = '[Edit] Move current block down',
        opts = { remap = false, silent = true },
      },
      {
        "<A-k>",
        ":m .-2<CR>==",
        mode = "n",
        description = '[Edit] Move current line up',
        opts = { remap = false, silent = true },
      },
      {
        "<A-k>",
        ":m '<-2<CR>gv=gv",
        mode = "v",
        description = '[Edit] Move current block up',
        opts = { remap = false, silent = true },
      },
      {
        '<A-l>',
        ':<C-u>Octo actions<CR>',
        mode = 'n',
        description = '[Git] Show exexutable actions',
        opts = { remap = false, silent = true },
      },
      {
        '<A-m>',
        ':<C-u>Telescope marks<CR>',
        mode = 'n',
        description = '[Search] Go to bookmark',
        opts = { remap = false, silent = true },
      },
      {
        '<A-n>',
        ':<C-u>bnext<CR>',
        mode = 'n',
        description = '[Buffer] Go to next',
        opts = { remap = false, silent = true },
      },
      {
        '<A-o>',
        ':<C-u>Telescope find_files find_command=fd,-HLE.git,-tf<CR>',
        mode = 'n',
        description = '[File] Search file',
        opts = { remap = false, silent = true },
      },
      {
        '<A-p>',
        ':<C-u>bprev<CR>',
        mode = 'n',
        description = '[Buffer] Go to previous',
        opts = { remap = false, silent = true },
      },
      {
        '<A-s>',
        '<Cmd>lua require"telescope.builtin".lsp_document_symbols{}<CR>',
        mode = 'n',
        description = '[LSP] Go to symbol in file',
        opts = { remap = false, silent = true },
      },
      {
        '<A-S>',
        '<Cmd>lua require"telescope.builtin".lsp_workspace_symbols{}<CR>',
        mode = 'n',
        description = '[LSP] Go to symbol in project',
        opts = { remap = false, silent = true },
      },
      {
        "<A-t>",
        ":<C-u>NeoTreeFloatToggle<CR>",
        mode = "n",
        description = '[File] Open file tree on left',
        opts = { remap = false, silent = true },
      },
      {
        '<A-w>',
        ":<C-u>Bdelete<CR>",
        mode = 'n',
        description = '[Buffer] Delete current buffer',
        opts = { remap = false, silent = true },
      },
      {
        "<A-x>",
        "<cmd>FloatermToggle<CR>",
        mode = "n",
        description = '[Terminal] Toggle window',
        opts = { remap = false, silent = true },
      },
      {
        "<A-x>",
        "<cmd>FloatermToggle<CR>",
        mode = "t",
        description = '[Terminal] Toggle window',
        opts = { remap = false, silent = true },
      },
      {
        '<A-y>',
        ':<C-u>Telescope registers<CR>',
        mode = 'n',
        description = '[Register] Show list',
        opts = { remap = false, silent = true },
      },
      {
        '<A-;>',
        'g%',
        mode = 'n',
        description = '[Motion] Move to paired blacket',
        opts = { remap = true, silent = true },
      },
      {
        '<A-;>',
        'g%',
        mode = 'v',
        description = '[Motion] Move to paired blacket',
        opts = { remap = true, silent = true },
      },
    },
    -- Enhanced move
    -- { 'w',               '<Plug>CamelCaseMotion_w',                                         mode = '',  description = '[Motion] CamelCaseMotion w',                    opts = { silent = true, remap = true } },
    -- { 'b',               '<Plug>CamelCaseMotion_b',                                         mode = '',  description = '[Motion] CamelCaseMotion b',                    opts = { silent = true, remap = true } },
    -- { 'e',               '<Plug>CamelCaseMotion_e',                                         mode = '',  description = '[Motion] CamelCaseMotion e',                    opts = { silent = true, remap = true } },
    -- { 'ge',              '<Plug>CamelCaseMotion_ge',                                        mode = '',  description = '[Motion] CamelCaseMotion ge',                   opts = { silent = true, remap = true } },
  }
end
