nvim: put map() into functions and add more options

This commit is contained in:
tastytea 2022-08-16 04:23:12 +02:00
parent b7928beb48
commit 9afc3d3316
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
5 changed files with 14 additions and 6 deletions

View File

@ -1,7 +1,8 @@
require('my/plugins')
require('my/keymaps')
require('my/tools')
local map = require('my.functions').map
require('Comment').setup({
toggler = {
line = '<Leader>cc',

View File

@ -1,5 +1,12 @@
local M = {}
function M.map(mode, shortcut, command, description, buffer)
local opts = { noremap = true, silent = true }
opts.desc = description or nil
opts.buffer = buffer or nil
vim.keymap.set(mode, shortcut, command, opts)
end
function M.remove_trailing_whitespace()
local curpos = vim.api.nvim_win_get_cursor(0)
vim.cmd([[keeppatterns %s/\s\+$//e]])

View File

@ -1,6 +1,4 @@
function map(mode, shortcut, command)
vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true })
end
local map = require('my.functions').map
vim.g.mapleader = ' ' -- <Leader>
vim.g.maplocalleader = ' ' -- <LocalLeader> (2 spaces)

View File

@ -1,7 +1,8 @@
require('my/plugins')
require('my/keymaps')
require('my/completion')
local map = require('my.functions').map
-- only do this after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function map(mode, shortcut, command) -- overwrite function in keymaps

View File

@ -1,7 +1,8 @@
require('my/plugins')
require('my/keymaps')
require('my/filetypes')
local map = require('my.functions').map
require('which-key').setup{}
local telescope = require('telescope')