refactor: 🚚 Prefer Lazy Configs

Make better use of Lazy and define configs inside the plugin def
This commit is contained in:
2024-07-06 06:23:28 -04:00
parent 59af690b22
commit e93a334c70
3 changed files with 178 additions and 152 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
lazy-lock.json lazy-lock.json
.luarc.json .luarc.json
.neoconf.json .neoconf.json
lazyvim.j lazyvim.json
debug/
+8 -7
View File
@@ -1,4 +1,4 @@
# Rootiest NVim Configuration # Rootiest NeoVim Configuration
```none ```none
██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗
@@ -7,13 +7,12 @@
██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║ ██║ ██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║ ██║
██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝
███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║
██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║
██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║
██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
███╗ ██╗██╗ ██╗██╗███╗ ███╗
████╗ ██║██║ ██║██║████╗ ████║
██╔██╗ ██║██║ ██║██║██╔████╔██║
██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║
██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║
╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
``` ```
The rootiest neovim configuration you will ever see! The rootiest neovim configuration you will ever see!
@@ -50,6 +49,8 @@ The rootiest neovim configuration you will ever see!
- Detects SSH sessions and disables certain plugins for speed and compatibility - Detects SSH sessions and disables certain plugins for speed and compatibility
- ToggleTerm, fzf, telescope, neotree, etc. for quick access to files and terminal - ToggleTerm, fzf, telescope, neotree, etc. for quick access to files and terminal
- LSP support for many languages and automatic setup for many more - 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
## Credits ## Credits
+168 -144
View File
@@ -64,16 +64,44 @@ require("lazy").setup({
"nvimdev/dashboard-nvim", "nvimdev/dashboard-nvim",
lazy = false, lazy = false,
opts = function() opts = function()
local logo = [[ -- if line length is greater than 80, use fancy mode
if vim.fn.winwidth(0) >= 100 then
LOGO = [[
]] ]]
elseif vim.fn.winwidth(0) >= 80 then
LOGO = [[
logo = string.rep("\n", 8) .. logo .. "\n\n" ]]
else
LOGO = [[
]]
end
LOGO = string.rep("\n", 8) .. LOGO .. "\n\n"
local opts = { local opts = {
theme = "doom", theme = "doom",
@@ -83,7 +111,7 @@ require("lazy").setup({
statusline = false, statusline = false,
}, },
config = { config = {
header = vim.split(logo, "\n"), header = vim.split(LOGO, "\n"),
-- stylua: ignore -- stylua: ignore
center = { center = {
{ action = 'lua LazyVim.pick()()', desc = " Find File", icon = "", key = "f" }, { action = 'lua LazyVim.pick()()', desc = " Find File", icon = "", key = "f" },
@@ -134,6 +162,56 @@ require("lazy").setup({
return opts return opts
end, end,
}, },
{
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
require("catppuccin").setup({
integrations = {
cmp = true,
diffview = true,
dashboard = true,
gitsigns = true,
nvimtree = true,
neotree = true,
treesitter = true,
markdown = true,
sandwich = true,
which_key = true,
telescope = { enabled = true, style = "nvchad" },
illuminate = { enabled = true, lsp = true },
notify = true,
notifier = true,
dap = true,
dap_ui = true,
ts_rainbow2 = true,
rainbow_delimiters = true,
lsp_trouble = true,
noice = true, -- codespell:ignore noice
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
ok = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
ok = { "underline" },
},
inlay_hints = { background = true },
},
mini = { enabled = true, indentscope_color = "mauve" },
},
})
end,
},
{ {
"folke/persistence.nvim", "folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened event = "BufReadPre", -- this will only start session saving when an actual file was opened
@@ -143,9 +221,30 @@ require("lazy").setup({
"gorbit99/codewindow.nvim", "gorbit99/codewindow.nvim",
version = false, version = false,
config = function() config = function()
local codewindow = require("codewindow") require("codewindow").setup({
codewindow.setup() active_in_terminals = false, -- Should the minimap activate for terminal buffers
codewindow.apply_default_keybinds() auto_enable = true, -- Automatically open the minimap when entering a (non-excluded) buffer (accepts a table of filetypes)
exclude_filetypes = { "help", "dashboard" }, -- Choose certain filetypes to not show minimap on
max_minimap_height = nil, -- The maximum height the minimap can take (including borders)
max_lines = nil, -- If auto_enable is true, don't open the minimap for buffers which have more than this many lines.
minimap_width = 10, -- The width of the text part of the minimap
use_lsp = true, -- Use the builtin LSP to show errors and warnings
use_treesitter = true, -- Use nvim-treesitter to highlight the code
use_git = true, -- Show small dots to indicate git additions and deletions
width_multiplier = 4, -- How many characters one dot represents
z_index = 1, -- The z-index the floating window will be on
show_cursor = true, -- Show the cursor position in the minimap
screen_bounds = "background", -- How the visible area is displayed, "lines": lines above and below, "background": background color
window_border = "none", -- The border style of the floating window (accepts all usual options)
relative = "win", -- What will be the minimap be placed relative to, "win": the curre
events = {
"TextChanged",
"InsertLeave",
"DiagnosticChanged",
"FileWritePost",
}, -- Events that update the code window
})
require("codewindow").apply_default_keybinds()
end, end,
}, },
{ {
@@ -187,9 +286,61 @@ require("lazy").setup({
end, { expr = true, silent = true }) end, { expr = true, silent = true })
end, end,
}, },
{ "numToStr/Comment.nvim" }, {
"numToStr/Comment.nvim",
config = function()
require("Comment").setup()
end,
},
{ "shellRaining/hlchunk.nvim", lazy = true }, { "shellRaining/hlchunk.nvim", lazy = true },
{ "akinsho/toggleterm.nvim", version = false, lazy = false }, {
"akinsho/toggleterm.nvim",
version = false,
lazy = false,
config = function()
require("toggleterm").setup({
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
return 10
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<c-\>]],
hide_numbers = true,
autochdir = true,
shade_terminals = false,
start_in_insert = true,
insert_mappings = true,
terminal_mappings = true,
persist_size = true,
persist_mode = true,
direction = "horizontal",
close_on_exit = true,
shell = vim.o.shell,
auto_scroll = true,
float_opts = {
border = "curved",
winblend = 3,
title_pos = "left",
},
winbar = {
enabled = true,
name_formatter = function(term) -- term: Terminal
return term.name
end,
},
})
-- Keybinds
vim.api.nvim_set_keymap(
"n",
"<c-/>",
":ToggleTerm<cr>",
{ noremap = true, desc = " Open Terminal" }
)
end,
},
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
lazy = true, lazy = true,
@@ -198,6 +349,14 @@ require("lazy").setup({
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
}, },
config = function()
require("neo-tree").setup({
source_selector = {
winbar = true,
statusline = false,
},
})
end,
}, },
{ "lewis6991/gitsigns.nvim" }, { "lewis6991/gitsigns.nvim" },
{ {
@@ -408,50 +567,6 @@ require("lazy").setup({
}, },
}) })
require("catppuccin").setup({
integrations = {
cmp = true,
diffview = true,
dashboard = true,
gitsigns = true,
nvimtree = true,
neotree = true,
treesitter = true,
markdown = true,
sandwich = true,
which_key = true,
telescope = { enabled = true, style = "nvchad" },
illuminate = { enabled = true, lsp = true },
notify = true,
notifier = true,
dap = true,
dap_ui = true,
ts_rainbow2 = true,
rainbow_delimiters = true,
lsp_trouble = true,
noice = true, -- codespell:ignore noice
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
ok = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
ok = { "underline" },
},
inlay_hints = { background = true },
},
mini = { enabled = true, indentscope_color = "mauve" },
},
})
-- Apply the default colorscheme -- Apply the default colorscheme
local kitty_theme = os.getenv("KITTY_THEME") local kitty_theme = os.getenv("KITTY_THEME")
vim.cmd.colorscheme(kitty_theme or "catppuccin-frappe") vim.cmd.colorscheme(kitty_theme or "catppuccin-frappe")
@@ -517,48 +632,9 @@ else
-- SSH -- SSH
vim.cmd(":TransparentDisable") vim.cmd(":TransparentDisable")
end end
-- Kitty Bindings
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
vim.cmd("let g:kitty_navigator_no_mappings = 1")
vim.cmd(":nnoremap <silent> {Left-Mapping} :KittyNavigateLeft<cr>")
vim.cmd(":nnoremap <silent> {Down-Mapping} :KittyNavigateDown<cr>")
vim.cmd(":nnoremap <silent> {Up-Mapping} :KittyNavigateUp<cr>")
vim.cmd(":nnoremap <silent> {Right-Mapping} :KittyNavigateRight<cr>")
end end
end end
-- ------------------------------- CodeWindow ----------------------------------
require("codewindow").setup({
active_in_terminals = false, -- Should the minimap activate for terminal buffers
auto_enable = true, -- Automatically open the minimap when entering a (non-excluded) buffer (accepts a table of filetypes)
exclude_filetypes = { "help" }, -- Choose certain filetypes to not show minimap on
max_minimap_height = nil, -- The maximum height the minimap can take (including borders)
max_lines = nil, -- If auto_enable is true, don't open the minimap for buffers which have more than this many lines.
minimap_width = 10, -- The width of the text part of the minimap
use_lsp = true, -- Use the builtin LSP to show errors and warnings
use_treesitter = true, -- Use nvim-treesitter to highlight the code
use_git = true, -- Show small dots to indicate git additions and deletions
width_multiplier = 4, -- How many characters one dot represents
z_index = 1, -- The z-index the floating window will be on
show_cursor = true, -- Show the cursor position in the minimap
screen_bounds = "background", -- How the visible area is displayed, "lines": lines above and below, "background": background color
window_border = "none", -- The border style of the floating window (accepts all usual options)
relative = "win", -- What will be the minimap be placed relative to, "win": the curre
events = {
"TextChanged",
"InsertLeave",
"DiagnosticChanged",
"FileWritePost",
}, -- Events that update the code window
})
require("codewindow").apply_default_keybinds()
-- --------------------------------- Comment -----------------------------------
require("Comment").setup()
-- --------------------------------- Hlchunk ----------------------------------- -- --------------------------------- Hlchunk -----------------------------------
require("hlchunk").setup({ require("hlchunk").setup({
chunk = { chunk = {
@@ -582,14 +658,6 @@ vim.api.nvim_create_user_command("Q", function()
vim.cmd.qall() vim.cmd.qall()
end, { force = true }) end, { force = true })
-- Toggle Terminal
vim.api.nvim_set_keymap(
"n",
"<c-/>",
":ToggleTerm<cr>",
{ noremap = true, desc = " Open Terminal" }
)
-- Navigate panels with Alt-direction like kitty -- Navigate panels with Alt-direction like kitty
vim.api.nvim_set_keymap( vim.api.nvim_set_keymap(
"n", "n",
@@ -647,42 +715,6 @@ require("trouble").setup({
}, },
}) })
-- ------------------------------- ToggleTerm ----------------------------------
require("toggleterm").setup({
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
return 10
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<c-\>]],
hide_numbers = true,
autochdir = true,
shade_terminals = false,
start_in_insert = true,
insert_mappings = true,
terminal_mappings = true,
persist_size = true,
persist_mode = true,
direction = "horizontal",
close_on_exit = true,
shell = vim.o.shell,
auto_scroll = true,
float_opts = {
border = "curved",
winblend = 3,
title_pos = "left",
},
winbar = {
enabled = true,
name_formatter = function(term) -- term: Terminal
return term.name
end,
},
})
-- -------------------------------- Telescope ---------------------------------- -- -------------------------------- Telescope ----------------------------------
require("telescope").setup({ require("telescope").setup({
defaults = { defaults = {
@@ -701,11 +733,3 @@ require("telescope").setup({
}, },
}) })
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
-- -------------------------------- Neo-tree -----------------------------------
require("neo-tree").setup({
source_selector = {
winbar = true,
statusline = false,
},
})