From bdc40625de565a0c7c2ea05fe99897f0181ae67f Mon Sep 17 00:00:00 2001 From: Rootiest Date: Sat, 6 Jul 2024 07:27:44 -0400 Subject: [PATCH] feat: :sparkles: Introduce additional UI and integration features Added more kitty-specific functionality and some additional UI improvements and further refined plugin loading --- README.md | 4 +- init.lua | 246 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 168 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index d218333..d6b5a0b 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,17 @@ The rootiest neovim configuration you will ever see! - Comfortable keybindings and IDE-like features - Designed to be quick to load and easy to use without compromising on features -- Leans heavily on lazy and luarocks for plugin management +- Leans heavily on lazy and luarocks for plugin management and lazy-loading - Catppuccino theme is default but tokyonight is also included - Automatic light/dark mode switching based on system theme - Extensive special configurations for kitty, including theme matching - Image support for kitty when conditions are met +- Kitty scrollback and keybinding support - Special configuration for neovide - Detects terminal client and adjusts accordingly - Detects SSH sessions and disables certain plugins for speed and compatibility - ToggleTerm, fzf, telescope, neotree, etc. for quick access to files and terminal +- Many UI elements to enhance the experience - LSP support for many languages and automatic setup for many more - Remotely spawn a neovim instance over ssh, in a container, or from a git repo - Dashboard logo adjusts to the size of the window diff --git a/init.lua b/init.lua index a09820d..8add482 100644 --- a/init.lua +++ b/init.lua @@ -19,14 +19,14 @@ -- ██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║ ██║ -- ██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ -- ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ --- [[ ]] --- [[ ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ]] --- [[ ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ]] --- [[ ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ]] --- [[ ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ]] --- [[ ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ]] --- [[ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ]] --- [[ ]] +-- +-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +-- -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ Rootiest NVim ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ @@ -34,6 +34,7 @@ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ +-- ---------------------------------- LAZY ------------------------------------- local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -- Bootstrap lazy.nvim if not vim.uv.fs_stat(lazypath) then @@ -48,6 +49,7 @@ if not vim.uv.fs_stat(lazypath) then end vim.opt.rtp:prepend(vim.env.LAZY or lazypath) +-- --------------------------------- PLUGINS ----------------------------------- require("lazy").setup({ -- Setup lazy spec = { @@ -102,12 +104,9 @@ require("lazy").setup({ ]] end LOGO = string.rep("\n", 8) .. LOGO .. "\n\n" - local opts = { theme = "doom", hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file statusline = false, }, config = { @@ -140,12 +139,10 @@ require("lazy").setup({ end, }, } - for _, button in ipairs(opts.config.center) do button.desc = button.desc .. string.rep(" ", 43 - #button.desc) button.key_format = " %s" end - -- open dashboard after closing lazy if vim.o.filetype == "lazy" then vim.api.nvim_create_autocmd("WinClosed", { @@ -158,7 +155,6 @@ require("lazy").setup({ end, }) end - return opts end, }, @@ -214,9 +210,31 @@ require("lazy").setup({ }, { "folke/persistence.nvim", - event = "BufReadPre", -- this will only start session saving when an actual file was opened + event = "BufReadPre", opts = {}, }, + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("telescope").setup({ + defaults = { + dynamic_preview_title = true, + prompt_prefix = " ", + selection_caret = " ", + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + }, + }) + end, + }, { "gorbit99/codewindow.nvim", version = false, @@ -292,7 +310,24 @@ require("lazy").setup({ require("Comment").setup() end, }, - { "shellRaining/hlchunk.nvim", lazy = true }, + { + "shellRaining/hlchunk.nvim", + lazy = true, + config = function() + require("hlchunk").setup({ + chunk = { + style = { + { fg = "#90FDA9" }, + }, + enable = true, + }, + indent = { + enable = true, + }, + line_num = { style = "#806d9c", enable = false }, + }) + end, + }, { "akinsho/toggleterm.nvim", version = false, @@ -494,6 +529,9 @@ require("lazy").setup({ { "nvim-telescope/telescope-fzf-native.nvim", build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release", + config = function() + require("telescope").load_extension("fzf") + end, }, { "amitds1997/remote-nvim.nvim", @@ -505,6 +543,46 @@ require("lazy").setup({ }, config = true, }, + { + "folke/trouble.nvim", + config = function() + require("trouble").setup({ + modes = { + preview_float = { + mode = "diagnostics", + preview = { + type = "float", + relative = "editor", + border = "rounded", + title = "Preview", + title_pos = "center", + position = { 0, -2 }, + size = { width = 0.3, height = 0.3 }, + zindex = 200, + }, + }, + }, + }) + end, + }, + { + "Bekaboo/deadcolumn.nvim", + lazy = true, + }, + { + "mikesmithgh/kitty-scrollback.nvim", + enabled = true, + lazy = true, + cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, + event = { "User KittyScrollbackLaunch" }, + -- version = '*', -- latest stable version, may have breaking changes if major version changed + -- version = '^5.0.0', -- pin major version, include fixes and features that do not have breaking changes + config = function() + if vim.env.KITTY_SCROLLBACK_NVIM == "true" then + require("kitty-scrollback").setup() + end + end, + }, { "mistricky/codesnap.nvim", build = "make", @@ -546,13 +624,9 @@ require("lazy").setup({ }, }, }, - defaults = { lazy = false, version = false }, - install = { colorscheme = {} }, - checker = { enabled = true }, - performance = { rtp = { disabled_plugins = { @@ -567,18 +641,75 @@ require("lazy").setup({ }, }) +-- ---------------------------------- STYLE ------------------------------------ + -- Apply the default colorscheme local kitty_theme = os.getenv("KITTY_THEME") vim.cmd.colorscheme(kitty_theme or "catppuccin-frappe") +if vim.g.colors_name == "catppuccin-frappe" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("frappe") +elseif vim.g.colors_name == "catppuccin-latte" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("latte") +elseif vim.g.colors_name == "catppuccin-mocha" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("mocha") +elseif vim.g.colors_name == "catppuccin-macchiato" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("macchiato") +elseif vim.g.colors_name == "tokyonight-night" or "tokyonight" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("mocha") +elseif vim.g.colors_name == "tokyonight-day" then + THEMEPALETTE = require("catppuccin.palettes").get_palette("latte") +else + THEMEPALETTE = { + bg = "#282c34", + fg = "#abb2bf", + overlay0 = "#abb2bf", + yellow = "#ECBE7B", + cyan = "#008080", + darkblue = "#081633", + green = "#98be65", + orange = "#FF8800", + violet = "#a9a1e1", + magenta = "#c678dd", + blue = "#51afef", + red = "#ec5f67", + } +end -- Set GUI font vim.opt.guifont = "MonaspiceKr Nerd Font Mono:#e-subpixelantialias:h13" vim.g.have_nerd_font = true --- Client Apps +-- DeadColumn + +local dead_opts = { + scope = "line", ---@type string|fun(): integer + ---@type string[]|fun(mode: string): boolean + modes = function(mode) + return mode:find("^[ictRss\x13]") ~= nil + end, + blending = { + threshold = 0.9, + colorcode = THEMEPALETTE.overlay0, + hlgroup = { "Normal", "bg" }, + }, + warning = { + alpha = 0.4, + offset = 0, + colorcode = THEMEPALETTE.error, + hlgroup = { "Error", "bg" }, + }, + extra = { + ---@type string? + follow_tw = "80", + }, +} +require("deadcolumn").setup(dead_opts) +vim.cmd(":set colorcolumn=120") + +-- ------------------------------- CLIENT APPS --------------------------------- if vim.g.neovide then - -- Neovide + -- ----------------------- Neovide ------------------------- -- refresh rate and translucency vim.g.neovide_refresh_rate = 170 vim.g.neovide_transparency = 0.85 @@ -622,7 +753,7 @@ if vim.g.neovide then vim.cmd(":inoremap +") else if vim.env.TERM:find("kitty") then - --Kitty + -- ------------------------ Kitty -------------------------- if not vim.env.SSH_TTY then -- Image Preview require("image").setup() @@ -632,24 +763,15 @@ else -- SSH vim.cmd(":TransparentDisable") end + vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") + vim.cmd("let g:kitty_navigator_no_mappings = 1") + vim.cmd(":nnoremap {Left-Mapping} :KittyNavigateLeft") + vim.cmd(":nnoremap {Down-Mapping} :KittyNavigateDown") + vim.cmd(":nnoremap {Up-Mapping} :KittyNavigateUp") + vim.cmd(":nnoremap {Right-Mapping} :KittyNavigateRight") end end --- --------------------------------- Hlchunk ----------------------------------- -require("hlchunk").setup({ - chunk = { - style = { - - { fg = "#90FDA9" }, - }, - enable = true, - }, - indent = { - enable = true, - }, - line_num = { style = "#806d9c", enable = false }, -}) - -- ------------------------------ KEY BINDINGS --------------------------------- -- Make :Q close all of the buffers @@ -658,29 +780,29 @@ vim.api.nvim_create_user_command("Q", function() vim.cmd.qall() end, { force = true }) --- Navigate panels with Alt-direction like kitty +-- Panel Navigation vim.api.nvim_set_keymap( "n", "", - [[h]], + [[wincmd h]], { noremap = true, desc = " Go to Window Left" } ) vim.api.nvim_set_keymap( "n", "", - [[j]], + [[wincmd j]], { noremap = true, desc = " Go to Window Up" } ) vim.api.nvim_set_keymap( "n", "", - [[k]], + [[wincmd k]], { noremap = true, desc = " Go to Window Down" } ) vim.api.nvim_set_keymap( "n", "", - [[l]], + [[wincmd l]], { noremap = true, desc = " Go to Window Right" } ) @@ -695,41 +817,3 @@ function _G.set_terminal_keymaps() vim.keymap.set("t", "", [[wincmd l]], opts) vim.keymap.set("t", "", [[]], opts) end - --- --------------------------------- Trouble ----------------------------------- -require("trouble").setup({ - modes = { - preview_float = { - mode = "diagnostics", - preview = { - type = "float", - relative = "editor", - border = "rounded", - title = "Preview", - title_pos = "center", - position = { 0, -2 }, - size = { width = 0.3, height = 0.3 }, - zindex = 200, - }, - }, - }, -}) - --- -------------------------------- Telescope ---------------------------------- -require("telescope").setup({ - defaults = { - dynamic_preview_title = true, - prompt_prefix = " ", - selection_caret = " ", - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - -- the default case_mode is "smart_case" - }, - }, -}) -require("telescope").load_extension("fzf")