dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

keymappings.lua (1255B)


      1 -- Globals.
      2 vim.g.mapleader=' '                    -- Set <leader> key.
      3 
      4 -- Kill arrow keys, for great justice.
      5 vim.keymap.set('n', '<Up>', '<NOP>')
      6 vim.keymap.set('n', '<Down>', '<NOP>')
      7 vim.keymap.set('n', '<Left>', '<NOP>')
      8 vim.keymap.set('n', '<Right>', '<NOP>')
      9 
     10 -- In terminal, ESC returns to normal mode.
     11 vim.keymap.set('t', '<Esc>', '<C-\\><C-n>')
     12 
     13 -- Retain selection on <,>.
     14 vim.keymap.set('v', '<', '<gv')
     15 vim.keymap.set('v', '>', '>gv')
     16 
     17 -- Configure fzf-lua.
     18 vim.keymap.set('n', '<leader>b', '<cmd>FzfLua buffers<CR>')
     19 vim.keymap.set('n', '<leader>f', '<cmd>FzfLua files<CR>')
     20 vim.keymap.set('n', '<leader>g', '<cmd>FzfLua grep<CR>')
     21 vim.keymap.set('n', '<leader>l', '<cmd>FzfLua live_grep<CR>')
     22 vim.keymap.set('n', '<leader>c', '<cmd>FzfLua builtin commands<CR>')
     23 vim.keymap.set('n', '<leader>q', function() vim.diagnostic.setqflist() end)
     24 
     25 -- Function to toggle absolute/relative numbering
     26 local function toggle_numbering()
     27   local opt = vim.opt
     28   if opt.number:get() == false then
     29     opt.number = true
     30   elseif opt.relativenumber:get() == false then
     31     opt.relativenumber = true
     32   else
     33     opt.relativenumber = false
     34     opt.number = false
     35   end
     36 end
     37 
     38 -- Key mapping to toggle numbering
     39 vim.keymap.set('n', '<leader>n', toggle_numbering)