~havi/nvim.d

ref: d3651941249eede9be3e5c8d6b63888a04c949c1 nvim.d/lua/mappings/core.lua -rw-r--r-- 7.0 KiB
d3651941havi fix(mappings/lsp): update deprecated mapping 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
-- vim: filetype=lua syntax=lua softtabstop=3 tabstop=3 shiftwidth=3 fileencoding=utf-8 smartindent autoindent expandtab
-- code: language=lua insertSpaces=true tabSize=3
local pluginman = require("lib.plugin-manager")
return function(register)
   if not register then
      return
   end
   -- ─── NORMAL ─────────────────────────────────────────────────────────────────────
   -- TODO see if this can be mapped in packer directly
   register({
      ["<CR>"] = {
         function()
            local module_name = "fine-cmdline"
            local plugin_name = "fine-cmdline.nvim"
            local plug = pluginman:load_plugin(plugin_name, module_name)
            if plug then
               plug.open()
            end
         end,
         "Open Command",
      },
      ["<BS>"] = { "i<BS><ESC>l", "remove last character" },
      ["<leader><leader>"] = { "<esc>q", "Toggle recording mode" },
      ["<A-BS>"] = { "dvb", "Remove last word" },
      ["<A-Down>"] = { "<cmd>m .+1<cr>==g", "Swap Line Upwards" },
      ["<A-Up>"] = { "<cmd>m .-2<cr>==g", "Swap Line Downwards" },

      -- ["<C-Up>"] = { "<C-w>k", "<ctrl+up> moves cursor above current pane" },
      ["<C-Up>"] = { "<CMD>FocusSplitUp<CR>", "<ctrl+up> moves cursor above current pane" },
      -- ["<C-Down>"] = { "<C-w>j", "<ctrl+down> moves cursor below current pane" },
      ["<C-Down>"] = { "<CMD>FocusSplitDown<CR>", "<ctrl+down> moves cursor below current pane" },
      -- ["<C-Left>"] = { "<C-w>h", "<ctrl+left> moves cursor to the left of current pane" },
      ["<C-Left>"] = { "<CMD>FocusSplitLeft<CR>", "<ctrl+left> moves cursor to the left of current pane" },
      -- ["<C-Right>"] = { "<C-w>l", "<ctrl+right> moves cursor to the right of current pane" },
      ["<C-Right>"] = { "<CMD>FocusSplitRight<CR>", "<ctrl+right> moves cursor to the right of current pane" },
      ["<C-a>"] = { "^", "Move to First Real Character in Line" },
      ["<C-e>"] = { "$", "Move to EOL" },
      -- ──────────────────────────────────────────────────────────────────────
      -- luacheck: max line length 200
      -- howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/#:~:text=Ctrl%2BE%20or%20End%3A%20Go,left%20(back)%20one%20word.
      -- luacheck: max line length 120
      ["<C-l>"] = { "<cmd>nohlsearch<cr>", "Clear Search" },
      -- ──────────────────────────────────────────────────────────────────────
      ["<A-j>"] = { ":resize -2<CR>", "Resize up with 'ctrl + h' " },
      ["<A-l>"] = { ":vertical resize +2<CR>", "Resize right with 'ctrl +l'" },
      ["<A-k>"] = { ":resize +2<CR>", "Resize down with 'ctrl + j'" },
      ["<A-h>"] = { ":vertical resize -2<CR>", "Resize left with 'ctrl + k'" },
      ["<C-s>"] = { "<cmd>w<cr>", "Save current buffer" },
      -- ["<CS-s>"] = { "<cmd>wa<cr>", "Save all open buffers" },
      -- [ TODO ] => move somewhere else
      ["<Leader>q"] = {
         name = "+Quickfix movement",
         ["n"] = { ":cnext<CR>", "Next quickfix list" },
         ["p"] = { ":cprev<CR>", "Previous quickfix list" },
      },
      ["t"] = {
         name = "+Tabs",
         ["n"] = { "<Cmd>tabnew<CR>", "New" },
         ["o"] = { "<Cmd>tabonly<CR>", "Close all other" },
         ["q"] = { "<Cmd>tabclose<CR>", "Close" },
         ["<Right>"] = { "<Cmd>tabnext<CR>", "Next" },
         ["<Left>"] = { "<Cmd>tabprevious<CR>", "Previous" },
      },
      -- [ TODO ] => add commands to select a block
      ["v"] = {
         name = "+Visual",
         -- https://stackoverflow.com/questions/7406949/vim-faster-way-to-select-blocks-of-text-in-visual-mode
         ["p"] = { [[Vap]], "select paragraph under the cursor" },
         ["v"] = { [[viw]], "select word under cursor" },
         ['"'] = { [[vi"]], "select word inside double quotes" },
         ["'"] = { [[vi']], "select word inside single quotes" },
      },
   }, {
      mode = "n",
      buffer = nil,
      silent = true,
      noremap = true,
      nowait = true,
   })
   -- luacheck: max line length 190
   register({
      ["<A-Up>"] = { [[<cmd>m '>+1<cr>gv=gv]], "Swap Line Upwards" },
      -- [ TODO ] => make it behave more like spacevim
      -- --  https://superuser.com/questions/310417/how-to-keep-in-visual-mode-after-identing-by-shift-in-vim
      -- ["<"] = { [[ <cmd>\<gv<cr> ]], "Indent left" }, --- sane indentation that does not exit visual mode after one indent
      -- [">"] = { [[ <cmd>\>gv<cr> ]], "Indent right" }, --- sane indentation that does not exit visual mode after one indent
   }, {
      mode = "v", --- visual mode
      buffer = nil, --- Global mappings. Specify a buffer number for buffer local mappings
      silent = true, --- use `silent` when creating keymaps
      noremap = true, --- use `noremap` when creating keymaps
      nowait = true, --- use `nowait` when creating keymaps
   })
   -- luacheck: max line length 120
   -- ────────────────────────────────────────────────────────────────────────────────
   register({
      ["<C-s>"] = { "<esc><cmd>w<cr>", "Save current buffer" },
      ["<A-BS>"] = { "<esc>dvbi", "Remove last word" },
      ["<A-Down>"] = { "<esc><cmd>m .+1<cr>==gi", "Swap Line Upwards" },
      ["<A-Up>"] = { "<esc><cmd>m .-2<cr>==gi", "Swap Line Downwards" },

      -- ["<CS-s>"] = { "<esc><cmd>wa<cr>i", "Save all opened buffer" },
   }, {
      mode = "i",
      buffer = nil, --- Global mappings. Specify a buffer number for buffer local mappings
      silent = true, --- use `silent` when creating keymaps
      noremap = true, --- use `noremap` when creating keymaps
      nowait = true, --- use `nowait` when creating keymaps
   })

   -- ────────────────────────────────────────────────────────────────────────────────
   -- [ NOTE ] => clearing 'q' mapping.
   -- vim.api.nvim_set_keymap("n", "q", "<Nop>", { noremap = false })
   vim.api.nvim_set_keymap("n", "q", "<cmd>q<cr>", { noremap = true })
   -- ────────────────────────────────────────────────────────────────────────────────
   -- -- [ FIXME ]
   -- lvim.keys.normal_mode["<S-l>"] = ":BufferNext<CR>"
   -- lvim.keys.normal_mode["<S-h>"] = ":BufferPrevious<CR>"

   -- -- [ FIXME ]
   -- lvim.keys.normal_mode["<C-q>"] = ":call QuickFixToggle()<CR>"
end