From 302817f9dd7e81e0e26ec1d1f0c4cc78f3f9712e Mon Sep 17 00:00:00 2001 From: rootiest Date: Tue, 16 Jul 2024 17:35:52 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20Better=20Lazy=20Config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use proper directory structure - Loading order improved --- init.lua | 2 -- lua/config/autocmds.lua | 19 +++++++++++++++++ lua/config/{keybinds.lua => keymaps.lua} | 20 ------------------ lua/config/{preload.lua => options.lua} | 14 ++++++++++++- lua/config/user.lua | 26 ++++++++---------------- 5 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 lua/config/autocmds.lua rename lua/config/{keybinds.lua => keymaps.lua} (88%) rename lua/config/{preload.lua => options.lua} (64%) diff --git a/init.lua b/init.lua index c21e073..a35124c 100644 --- a/init.lua +++ b/init.lua @@ -49,8 +49,6 @@ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ Configuration ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ --- --------------------------------- PRE-LOAD ---------------------------------- -require("config.preload") -- ---------------------------------- LAZY ------------------------------------- require("config.lazy") diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..fb54623 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,19 @@ +-- -------------------------------- Commands ----------------------------------- +-- Make :Q close all of the buffers +vim.api.nvim_create_user_command("Q", function() + vim.cmd.bdelete() + vim.cmd.qall() +end, { force = true }) + +-- ------------------------------ Auto-Commands -------------------------------- +-- Autosave Colorscheme +vim.api.nvim_create_autocmd("ColorScheme", { + desc = "Store colorscheme name", + callback = function() + print("colorscheme:", vim.g.colors_name) + vim.fn.writefile( + { vim.g.colors_name }, + vim.fn.stdpath("config") .. "/.colorscheme" + ) + end, +}) diff --git a/lua/config/keybinds.lua b/lua/config/keymaps.lua similarity index 88% rename from lua/config/keybinds.lua rename to lua/config/keymaps.lua index 6e17002..685d328 100644 --- a/lua/config/keybinds.lua +++ b/lua/config/keymaps.lua @@ -2,26 +2,6 @@ -- -------------------------------- KEYBINDS ----------------------------------- -- ----------------------------------------------------------------------------- --- -------------------------------- Commands ----------------------------------- --- Make :Q close all of the buffers -vim.api.nvim_create_user_command("Q", function() - vim.cmd.bdelete() - vim.cmd.qall() -end, { force = true }) - --- ------------------------------ Auto-Commands -------------------------------- --- Autosave Colorscheme -vim.api.nvim_create_autocmd("ColorScheme", { - desc = "Store colorscheme name", - callback = function() - print("colorscheme:", vim.g.colors_name) - vim.fn.writefile( - { vim.g.colors_name }, - vim.fn.stdpath("config") .. "/.colorscheme" - ) - end, -}) - -- --------------------------------- Keymaps ----------------------------------- local wk = require("which-key") wk.add({ diff --git a/lua/config/preload.lua b/lua/config/options.lua similarity index 64% rename from lua/config/preload.lua rename to lua/config/options.lua index 776747a..4ccc70e 100644 --- a/lua/config/preload.lua +++ b/lua/config/options.lua @@ -1,8 +1,10 @@ -- ----------------------------------------------------------------------------- --- -------------------------------- PRE-LOAD ----------------------------------- +-- --------------------------------- OPTIONS ----------------------------------- -- ----------------------------------------------------------------------------- + -- Set Default Leader Key vim.g.mapleader = " " + -- Restore Leader Key if vim.fn.filereadable(vim.fn.stdpath("config") .. "/.leader") == 1 then -- Load Stored Leader Key @@ -19,3 +21,13 @@ else KITTY_THEME = os.getenv("KITTY_THEME") end end + +-- ----------------------------------- LSP -------------------------------------- +vim.g.loaded_perl_provider = 0 +vim.g.lazyvim_python_lsp = "basedpyright" + +-- ------------------------------- CLIENT APPS --------------------------------- +if vim.g.neovide then + -- ----------------------- Neovide ------------------------- + require("config.neovide") +end diff --git a/lua/config/user.lua b/lua/config/user.lua index 8922bf9..782917a 100644 --- a/lua/config/user.lua +++ b/lua/config/user.lua @@ -1,20 +1,12 @@ -- ----------------------------------------------------------------------------- --- --------------------------------- OPTIONS ----------------------------------- +-- ---------------------------------- USER ------------------------------------- -- ----------------------------------------------------------------------------- - --- ----------------------------------- LSP -------------------------------------- -vim.g.loaded_perl_provider = 0 -vim.g.lazyvim_python_lsp = "basedpyright" - -- ---------------------------------- STYLE ------------------------------------ --- Apply the colorscheme -vim.cmd.colorscheme(STORED_THEME or KITTY_THEME or "catppuccin-frappe") - --- ------------------------------- CLIENT APPS --------------------------------- -if vim.g.neovide then - -- ----------------------- Neovide ------------------------- - require("config.neovide") -end - --- -------------------------------- KEYBINDS ----------------------------------- -require("config.keybinds") +----------- Apply the colorscheme ----------- +-- 1. Restore last colorscheme if it exists +-- 2. Use kitty theme if it exists +-- 3. Fallback to Catppuccin Frappe +-- 4. Fallback to Tokyonight +vim.cmd.colorscheme( + STORED_THEME or KITTY_THEME or "catppuccin-frappe" or "tokyonight" +)