From a5a5a8220cf9ccea12f3c6850a1dd6bdd667f245 Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Sat, 4 Sep 2021 14:34:16 +1000 Subject: [PATCH] refactor: clean & small reorgnaisation of default_config --- lua/core/default_config.lua | 21 ++++++++------------- lua/core/mappings.lua | 15 +++++++++++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 069faeb..554b171 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -7,10 +7,8 @@ M.ui, M.options, M.plugin_status, M.mappings, M.custom = {}, {}, {}, {}, {} -- non plugin ui configs, available without any plugins M.ui = { italic_comments = false, - -- theme to be used, to see all available themes, open the theme switcher by + th theme = "onedark", - -- theme toggler, toggle between two themes, see theme_toggleer mappings theme_toggler = { enabled = false, @@ -19,7 +17,6 @@ M.ui = { "one-light", }, }, - -- Enable this only if your terminal has the colorscheme set which nvchad uses -- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal transparency = false, @@ -53,6 +50,7 @@ M.options = { hidden = true, ignorecase = true, insert_nav = true, -- navigation in insertmode + window_nav = true, mapleader = " ", mouse = "a", number = true, @@ -105,7 +103,6 @@ M.mappings = { -- close current focused buffer close_buffer = "x", copy_whole_file = "", -- copy all contents of the current buffer - -- navigation in insert mode, only if enabled in options insert_nav = { backward = "", @@ -115,13 +112,18 @@ M.mappings = { prev_line = "", top_of_line = "", }, - + window_nav = { + --better window movement + moveLeft = "", + moveRight = "", + moveUp = "", + moveDown = "", + }, line_number_toggle = "n", -- show or hide line number new_buffer = "", -- open a new buffer new_tab = "b", -- open a new vim tab save_file = "", -- save file using :w theme_toggler = "tt", -- for theme toggler, see in ui.theme_toggler - -- terminal related mappings terminal = { -- multiple mappings can be given for esc_termmode and esc_hide_termmode @@ -137,7 +139,6 @@ M.mappings = { new_vertical = "v", new_window = "w", }, - -- update nvchad from nvchad, chadness 101 update_nvchad = "uu", } @@ -148,12 +149,6 @@ M.mappings.plugin = { bufferline = { next_buffer = "", -- next buffer prev_buffer = "", -- previous buffer - --TODO move out of bufferline - --better window movement - moveLeft = "", - moveRight = "", - moveUp = "", - moveDown = "", }, cheatsheet = { default_keys = "dk", diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 3a41a83..8de91d7 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -3,6 +3,7 @@ local hooks = require "core.hooks" local config = utils.load_config() local map = utils.map + local maps = config.mappings local plugin_maps = maps.plugin @@ -52,6 +53,16 @@ M.misc = function() map("i", inav.top_of_line, "^i") end + -- easier navigation between windows + if config.options.window_nav then + local wnav = maps.window_nav + + map("n", wnav.moveLeft, "h") + map("n", wnav.moveRight, "l") + map("n", wnav.moveUp, "k") + map("n", wnav.moveDown, "j") + end + -- check the theme toggler if config.ui.theme_toggler.enabled then map( @@ -126,10 +137,6 @@ M.bufferline = function() map("n", m.next_buffer, ":BufferLineCycleNext ") map("n", m.prev_buffer, ":BufferLineCyclePrev ") - map("n", m.moveLeft, "h") - map("n", m.moveRight, "l") - map("n", m.moveUp, "k") - map("n", m.moveDown, "j") end M.cheatsheet = function()