From fcfb8e6e00f32fc37ccf7efe2200aea182494be4 Mon Sep 17 00:00:00 2001 From: rootiest Date: Tue, 16 Jul 2024 14:37:11 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A0=20Reorganize=20packaging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Better organized and more efficient --- .leader | 1 + LICENSE | 2 +- init.lua | 56 +++--------------------- lua/config/keybinds.lua | 2 +- lua/config/lazy.lua | 40 +++++++++++++++++ lua/config/neovide.lua | 5 ++- lua/config/{style.lua => preload.lua} | 21 +++++---- lua/config/user.lua | 20 +++++++++ lua/plugins/coding.lua | 63 +++++++++++++++++++++++++++ lua/plugins/editor.lua | 16 +++++++ lua/plugins/lang.lua | 1 + lua/themes/auto-dark-mode.lua | 26 ----------- lua/ui/ui.lua | 23 ++++++++++ 13 files changed, 185 insertions(+), 91 deletions(-) create mode 100644 .leader create mode 100644 lua/config/lazy.lua rename lua/config/{style.lua => preload.lua} (57%) create mode 100644 lua/config/user.lua delete mode 100644 lua/themes/auto-dark-mode.lua diff --git a/.leader b/.leader new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/.leader @@ -0,0 +1 @@ + diff --git a/LICENSE b/LICENSE index bae94e1..be3f7b2 100644 --- a/LICENSE +++ b/LICENSE @@ -658,4 +658,4 @@ specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see -. \ No newline at end of file +. diff --git a/init.lua b/init.lua index d5b8fb3..c21e073 100644 --- a/init.lua +++ b/init.lua @@ -49,57 +49,11 @@ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ Configuration ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +-- --------------------------------- PRE-LOAD ---------------------------------- +require("config.preload") -- ---------------------------------- LAZY ------------------------------------- -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" --- Bootstrap lazy.nvim -if not vim.uv.fs_stat(lazypath) then - -- stylua: ignore - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", lazypath - }) -end -vim.opt.rtp:prepend(vim.env.LAZY or lazypath) +require("config.lazy") --- -------------------------------- DISABLED ----------------------------------- -vim.g.loaded_perl_provider = 0 - --- --------------------------------- PLUGINS ----------------------------------- -require("lazy").setup({ - spec = { - { "LazyVim/LazyVim", import = "lazyvim.plugins" }, - { import = "ui" }, - { import = "plugins" }, - { import = "themes" }, - }, - defaults = { lazy = false, version = false }, - checker = { enabled = true }, - performance = { - rtp = { - disabled_plugins = { - "gzip", - "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, -}) - --- ---------------------------------- STYLE ------------------------------------ -require("config/style") - --- ------------------------------- CLIENT APPS --------------------------------- -if vim.g.neovide then - -- ----------------------- Neovide ------------------------- - require("config/neovide") -end - --- -------------------------------- KEYBINDS ----------------------------------- -require("config/keybinds") +-- ---------------------------------- USER ------------------------------------- +require("config.user") diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua index 01e5838..b3b51cb 100644 --- a/lua/config/keybinds.lua +++ b/lua/config/keybinds.lua @@ -221,4 +221,4 @@ wk.add({ }) -- ---------------------------- Spell Correction ------------------------------- -require("config/spellcheck") +require("config.spellcheck") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..b61c0d9 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,40 @@ +-- ----------------------------------------------------------------------------- +-- ---------------------------------- LAZY ------------------------------------- +-- ----------------------------------------------------------------------------- +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.uv.fs_stat(lazypath) then + -- stylua: ignore + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", lazypath + }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +-- --------------------------------- PLUGINS ----------------------------------- +require("lazy").setup({ + spec = { + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + { import = "ui" }, + { import = "plugins" }, + { import = "themes" }, + }, + defaults = { lazy = false, version = false }, + checker = { enabled = true }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/lua/config/neovide.lua b/lua/config/neovide.lua index 35e9c5b..2c46c2d 100644 --- a/lua/config/neovide.lua +++ b/lua/config/neovide.lua @@ -1,6 +1,8 @@ -- ----------------------------------------------------------------------------- -- --------------------------------- NeoVide ----------------------------------- -- ----------------------------------------------------------------------------- +-- Set GUI font +vim.opt.guifont = "Iosevka:#e-subpixelantialias:h12" -- refresh rate and translucency vim.g.neovide_refresh_rate = 170 vim.g.neovide_transparency = 0.85 @@ -39,4 +41,5 @@ vim.cmd(":cnoremap +") vim.cmd(":cnoremap +") -- and in insert mode vim.cmd(":inoremap +") -vim.cmd(":inoremap +") \ No newline at end of file +vim.cmd(":inoremap +") + diff --git a/lua/config/style.lua b/lua/config/preload.lua similarity index 57% rename from lua/config/style.lua rename to lua/config/preload.lua index 61fa632..b645cdd 100644 --- a/lua/config/style.lua +++ b/lua/config/preload.lua @@ -1,8 +1,16 @@ -- ----------------------------------------------------------------------------- --- ---------------------------------- Style ------------------------------------ +-- -------------------------------- PRE-LOAD ----------------------------------- -- ----------------------------------------------------------------------------- +-- Restore Leader Key +if vim.fn.filereadable(vim.fn.stdpath("config") .. "/.leader") == 1 then + -- Load Stored Leader Key + vim.g.mapleader = vim.fn.readfile(vim.fn.stdpath("config") .. "/.leader")[1] +else + -- Set Default Leader Key + vim.g.mapleader = " " +end --- Restore Colorscheme +-- Restore Colorscheme to variable if vim.fn.filereadable(vim.fn.stdpath("config") .. "/.colorscheme") == 1 then -- Load the stored colorscheme STORED_THEME = vim.fn.readfile(vim.fn.stdpath("config") .. "/.colorscheme")[1] @@ -13,12 +21,3 @@ else end end --- Apply the colorscheme -vim.cmd.colorscheme(STORED_THEME or KITTY_THEME or "catppuccin-frappe") - --- Set GUI font -vim.opt.guifont = "Iosevka:#e-subpixelantialias:h12" -vim.g.have_nerd_font = true - --- Set Leader Key -vim.g.mapleader = " " diff --git a/lua/config/user.lua b/lua/config/user.lua new file mode 100644 index 0000000..8922bf9 --- /dev/null +++ b/lua/config/user.lua @@ -0,0 +1,20 @@ +-- ----------------------------------------------------------------------------- +-- --------------------------------- OPTIONS ----------------------------------- +-- ----------------------------------------------------------------------------- + +-- ----------------------------------- 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") diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index aa6b46b..96cd2ad 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -4,8 +4,71 @@ return { { import = "lazyvim.plugins.extras.coding.codeium" }, + { import = "lazyvim.plugins.extras.coding.tabnine" }, { import = "lazyvim.plugins.extras.coding.yanky" }, { import = "lazyvim.plugins.extras.coding.mini-surround" }, + { import = "lazyvim.plugins.extras.vscode" }, + { + "echasnovski/mini.align", + config = function() + require("mini.align").setup() + end, + }, + { -- Emoji completion + "hrsh7th/nvim-cmp", + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, { name = "emoji" }) + end, + dependencies = { "hrsh7th/cmp-emoji" }, + }, + { -- Supertab completion + -- Use for completion and snippets + "hrsh7th/nvim-cmp", + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 + and vim.api + .nvim_buf_get_lines(0, line - 1, line, true)[1] + :sub(col, col) + :match("%s") + == nil + end + + local cmp = require("cmp") + + opts.mapping = vim.tbl_extend("force", opts.mapping, { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + -- You could replace select_next_item() with confirm({ select = true }) to get VS Code autocompletion behavior + cmp.select_next_item() + elseif vim.snippet.active({ direction = 1 }) then + vim.schedule(function() + vim.snippet.jump(1) + end) + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif vim.snippet.active({ direction = -1 }) then + vim.schedule(function() + vim.snippet.jump(-1) + end) + else + fallback() + end + end, { "i", "s" }), + }) + end, + }, { "norcalli/nvim-colorizer.lua", config = function() diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index d2d1e9a..7e4ebf0 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -12,6 +12,22 @@ return { "folke/which-key.nvim", opts = { preset = "modern", + modes = { + n = true, -- Normal mode + i = true, -- Insert mode + x = true, -- Visual mode + s = true, -- Select mode + o = true, -- Operator pending mode + t = true, -- Terminal mode + c = true, -- Command mode + -- Start hidden and wait for a key to be pressed before showing the popup + -- Only used by enabled xo mapping modes. + -- Set to false to show the popup immediately (after the delay) + defer = { + [""] = false, + V = false, + }, + }, }, }, { diff --git a/lua/plugins/lang.lua b/lua/plugins/lang.lua index f479225..08972ee 100644 --- a/lua/plugins/lang.lua +++ b/lua/plugins/lang.lua @@ -10,4 +10,5 @@ return { { import = "lazyvim.plugins.extras.lang.python" }, { import = "lazyvim.plugins.extras.lang.toml" }, { import = "lazyvim.plugins.extras.lang.yaml" }, + { import = "lazyvim.plugins.extras.lang.clangd" }, } diff --git a/lua/themes/auto-dark-mode.lua b/lua/themes/auto-dark-mode.lua deleted file mode 100644 index 7aeb191..0000000 --- a/lua/themes/auto-dark-mode.lua +++ /dev/null @@ -1,26 +0,0 @@ --- ----------------------------------------------------------------------------- --- ----------------------------- auto-dark-mode -------------------------------- --- ----------------------------------------------------------------------------- -return { - "f-person/auto-dark-mode.nvim", - lazy = true, - opts = { - update_interval = 1000, - set_dark_mode = function() - vim.o.background = "dark" - local kitty_theme = os.getenv("KITTY_THEME") - vim.cmd.colorscheme(kitty_theme or "catppuccin-frappe") - end, - set_light_mode = function() - vim.o.background = "light" - local kitty_theme = os.getenv("KITTY_THEME") - vim.cmd.colorscheme(kitty_theme or "catppuccin-latte") - end, - }, - cond = function() -- Not Using SSH or root - local ssh = os.getenv("SSH_TTY") - local user = os.getenv("USER") - local root = string.find(user, "root") - return not ssh and not root - end, -} \ No newline at end of file diff --git a/lua/ui/ui.lua b/lua/ui/ui.lua index c0247e0..e8ecfd8 100644 --- a/lua/ui/ui.lua +++ b/lua/ui/ui.lua @@ -128,4 +128,27 @@ return { }) end, }, + { + "f-person/auto-dark-mode.nvim", + lazy = true, + opts = { + update_interval = 1000, + set_dark_mode = function() + vim.o.background = "dark" + local kitty_theme = os.getenv("KITTY_THEME") + vim.cmd.colorscheme(kitty_theme or "catppuccin-frappe") + end, + set_light_mode = function() + vim.o.background = "light" + local kitty_theme = os.getenv("KITTY_THEME") + vim.cmd.colorscheme(kitty_theme or "catppuccin-latte") + end, + }, + cond = function() -- Not Using SSH or root + local ssh = os.getenv("SSH_TTY") or false + local user = os.getenv("USER") or "" + local root = string.find(user, "root") + return not ssh and not root + end, + }, }