From 2cf8580eb79b24a3d565aba8bb3305417811f2c8 Mon Sep 17 00:00:00 2001 From: "Ian S. Pringle" Date: Sat, 26 Jun 2021 14:31:40 -0400 Subject: Updated where leader key is set and made var in lv-settings (#474) - Setting leader-key in the init.lua file. You want to set the leader as soon as possible so that it's the same everywhere. With the leader being set in the lua/lv-which-key/init.lua it resulted in mappings that used `` in the lua/keymappings.lua mapping the the defualt leader-key of `\` - Added the O.leader_key to the lv-settings.lua file so the leader-key can be set there, which seems to make more sense. - Added handling for when the leader-key is ``. This could be made more robust to include other special keys, but I don't think many/any of the other special keys would be used as a leader-key (ie , , , , , etc.) Co-authored-by: Christian Chiarulli --- init.lua | 12 ++++++++++-- lua/lv-which-key/init.lua | 5 ----- lv-settings.lua | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 2ef7203d..f241f264 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,15 @@ require('lv-globals') vim.cmd('luafile '..CONFIG_PATH..'/lv-settings.lua') + +-- Set leader +if O.leader_key == ' ' or O.leader_key == 'space' then + vim.api.nvim_set_keymap('n', '', '', {noremap = true, silent = true}) + vim.g.mapleader = ' ' +else + vim.api.nvim_set_keymap('n', O.leader_key, '', {noremap = true, silent = true}) + vim.g.mapleader = O.leader_key +end + require('settings') require('lv-gitblame') require('lv-matchup') @@ -34,8 +44,6 @@ if O.extras then require('lv-vimtex') end - - -- TODO is there a way to do this without vimscript vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 2f60e0d5..02401ff0 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -43,11 +43,6 @@ local opts = { nowait = false -- use `nowait` when creating keymaps } --- Set leader -vim.api.nvim_set_keymap('n', '', '', {noremap = true, silent = true}) -vim.g.mapleader = ' ' - - -- no hl vim.api.nvim_set_keymap('n', 'h', ':let @/=""', {noremap = true, silent = true}) diff --git a/lv-settings.lua b/lv-settings.lua index 2d96715d..5425c9a7 100644 --- a/lv-settings.lua +++ b/lv-settings.lua @@ -15,6 +15,7 @@ O.wrap_lines = false O.timeoutlen = 100 O.document_highlight = true O.extras = true +O.leader_key = ' ' -- dashboard -- O.dashboard.custom_header = {""} -- cgit v1.2.3