vim: use vim.keymap instead of custom functions
`vim.keymap` was introduced in nvim 0.7, so this is the minimum version required for this to work.
This commit is contained in:
parent
0be2a1b45e
commit
97839fa58b
4 changed files with 13 additions and 24 deletions
|
@ -1,3 +1,3 @@
|
||||||
local nmap = require 'fs.util'.buf_nmap
|
local nmap = require 'fs.util'.nmap
|
||||||
nmap { 'q', '<cmd>q<cr>' }
|
nmap { 'q', '<cmd>q<cr>', { buffer = true } }
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
vim.bo.tabstop = 2
|
vim.bo.tabstop = 2
|
||||||
|
|
||||||
local nmap = require 'fs.util'.buf_nmap
|
local nmap = require 'fs.util'.nmap
|
||||||
|
local buffer = { buffer = true }
|
||||||
|
|
||||||
-- execute the current line
|
-- execute the current line
|
||||||
nmap { '<leader>x', [[<cmd>call luaeval(getline("."))<cr>]] }
|
nmap { '<leader>x', [[<cmd>call luaeval(getline("."))<cr>]], buffer }
|
||||||
|
|
||||||
-- save and execute the current file
|
-- save and execute the current file
|
||||||
nmap { '<leader><leader>x', '<cmd>silent write | luafile %<cr>' }
|
nmap { '<leader><leader>x', '<cmd>silent write | luafile %<cr>', buffer }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local nmap = require'fs.util'.buf_nmap
|
local nmap = require'fs.util'.nmap
|
||||||
|
|
||||||
local setup = function()
|
local setup = function()
|
||||||
-- Disable concealling on italic, bold, etc.
|
-- Disable concealling on italic, bold, etc.
|
||||||
|
@ -13,9 +13,9 @@ local setup = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = function()
|
local config = function()
|
||||||
nmap { '<leader>+', '<cmd>.,.HeaderIncrease<cr>' }
|
nmap { '<leader>+', '<cmd>.,.HeaderIncrease<cr>', { buffer = true } }
|
||||||
nmap { '<leader>=', '<cmd>.,.HeaderIncrease<cr>' }
|
nmap { '<leader>=', '<cmd>.,.HeaderIncrease<cr>', { buffer = true } }
|
||||||
nmap { '<leader>-', '<cmd>.,.HeaderDecrease<cr>' }
|
nmap { '<leader>-', '<cmd>.,.HeaderDecrease<cr>', { buffer = true } }
|
||||||
end
|
end
|
||||||
|
|
||||||
return { setup = setup, config = config }
|
return { setup = setup, config = config }
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local map = function(mode, lhs, rhs, opts)
|
M.nmap = function(tbl) vim.keymap.set('n', tbl[1], tbl[2], tbl[3]) end
|
||||||
local opts = vim.tbl_extend('keep', opts or {}, { noremap = true })
|
M.imap = function(tbl) vim.keymap.set('i', tbl[1], tbl[2], tbl[3]) end
|
||||||
vim.api.nvim_set_keymap(mode, lhs, rhs, opts)
|
M.vmap = function(tbl) vim.keymap.set('v', tbl[1], tbl[2], tbl[3]) end
|
||||||
end
|
|
||||||
|
|
||||||
local buf_map = function(mode, lhs, rhs, opts)
|
|
||||||
local opts = vim.tbl_extend('keep', opts or {}, { noremap = true })
|
|
||||||
vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.nmap = function(tbl) map('n', tbl[1], tbl[2], tbl[3]) end
|
|
||||||
M.imap = function(tbl) map('i', tbl[1], tbl[2], tbl[3]) end
|
|
||||||
M.vmap = function(tbl) map('v', tbl[1], tbl[2], tbl[3]) end
|
|
||||||
M.buf_nmap = function(tbl) buf_map('n', tbl[1], tbl[2], tbl[3]) end
|
|
||||||
M.buf_imap = function(tbl) buf_map('i', tbl[1], tbl[2], tbl[3]) end
|
|
||||||
|
|
||||||
M.colors = function(gui)
|
M.colors = function(gui)
|
||||||
if gui or vim.opt.termguicolors:get() then
|
if gui or vim.opt.termguicolors:get() then
|
||||||
|
|
Loading…
Add table
Reference in a new issue