modularization

This commit is contained in:
Dominic DiTaranto 2025-11-25 16:16:39 -05:00
parent 562b8065ec
commit 9c3e8ec512
16 changed files with 306 additions and 302 deletions

333
init.lua
View file

@ -14,7 +14,8 @@ vim.o.inccommand = 'split'
vim.o.cursorline = true
vim.o.showmode = true
vim.o.hlsearch = false
vim.o.tabstop = 4
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.g.have_nerd_font = true
vim.o.scrolloff = 10
vim.g.border = "rounded"
@ -25,12 +26,27 @@ vim.o.mouse = "a"
vim.o.undofile = true
vim.o.spell = false
-- diagnostic config
vim.diagnostic.config({
virtual_text = false,
float = { source = "always", border = "rounded" },
})
require("config.keymaps")
require("config.plugins.autosave")
require("config.plugins.barbar")
require("config.plugins.blink")
require("config.plugins.dashboard")
require("config.plugins.lualine")
require("config.plugins.mason")
require("config.plugins.mini")
require("config.plugins.nvim-lspconfig")
require("config.plugins.nvim-tree")
require("config.plugins.prettier")
require("config.plugins.telescope")
require("config.plugins.theme")
require("config.plugins.treesitter")
require("config.plugins.venv-selector")
-- Highlight On Yank
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
@ -40,237 +56,24 @@ vim.api.nvim_create_autocmd("TextYankPost", {
end,
})
-- unset space so it can be used as leader
vim.keymap.set("n", " ", "", { silent = true, remap = false })
-- source config
vim.keymap.set("n", "<leader>o", ":source $HOME/.config/nvim/init.lua<CR>")
-- move around windows
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "focus to l window" })
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "focus to r window" })
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "focus to dwn window" })
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "focus to up window" })
-- move lines up and down
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
-- quote around highlighted words
vim.keymap.set('v', "'", "c''<Esc>P")
vim.keymap.set('v', '"', 'c""<Esc>P')
-- non-floating terminal
vim.keymap.set('n', 'T', ":belowright split | terminal<CR> | :resize 8<CR>i")
-- toggle spellcheck
vim.keymap.set('n', '<leader>st', ':set spell!<CR>')
-- toggle nvim tree
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")
-- barbar
vim.keymap.set("n", "<leader>x", ":BufferClose<CR>")
-- (I need both options, one for windows, one for linux)
vim.keymap.set("n", "<A-h>", ":BufferPrevious<CR>")
vim.keymap.set("n", "<A-l>", ":BufferNext<CR>")
vim.keymap.set("n", "<A-,>", "<Cmd>BufferPrevious<CR>")
vim.keymap.set("n", "<A-.>", "<Cmd>BufferNext<CR>")
-- format
vim.keymap.set("n", "<leader>f", ":lua vim.lsp.buf.format()<CR>")
-- diagnostics
vim.keymap.set("n", "<leader>ds", ":lua vim.diagnostic.open_float()<CR>")
vim.keymap.set("n", "<leader>dn", function() vim.diagnostic.jump({ count = 1 }) end)
vim.keymap.set("n", "<leader>dp", function() vim.diagnostic.jump({ count = -1 }) end)
-- VIM PACKS
vim.pack.add({
-- theme
{ src = "https://github.com/neanias/everforest-nvim.git" },
-- lsp
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/mason-org/mason.nvim" },
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
{ src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" },
-- treesitter
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate",
lazy = false,
},
-- bar and icons at the top
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
{ src = "https://github.com/romgrk/barbar.nvim" },
-- file tree
{ src = "https://github.com/nvim-tree/nvim-tree.lua" },
-- auto save
{ src = "https://github.com/Pocco81/auto-save.nvim" },
-- completion
{ src = "https://github.com/saghen/blink.cmp" },
-- lualine
{ src = "https://github.com/nvim-lualine/lualine.nvim" },
-- mini.nvim
{ src = "https://github.com/echasnovski/nvim-mini/mini.nvim" },
-- telescope
{ src = "https://github.com/nvim-lua/plenary.nvim" },
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
-- venv-selector
{ src = "https://github.com/mfussenegger/nvim-dap" },
{ src = "https://github.com/mfussenegger/nvim-dap-python" },
{ src = "https://github.com/linux-cultist/venv-selector.nvim" },
-- dashboard
{ src = "https://github.com/nvimdev/dashboard-nvim" },
-- prettier
{ src = "https://github.com/MunifTanjim/prettier.nvim" },
-- python specific
vim.api.nvim_create_autocmd("FileType", {
pattern = "python",
command = "setlocal shiftwidth=4 tabstop=4"
})
-- telescope (sadly these configs need to be after vimpack)
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
local enable_providers = {
"python3_provider",
}
require("dap-python").setup("python3")
require("venv-selector").setup({
-- Optional: Customize search paths for virtual environments
search = {
-- Example: Add a custom search path
-- { path = "~/my_projects/venvs", depth = 1 },
},
-- Optional: Customize plugin options
options = {
-- Example: Set a default picker (e.g., "telescope")
-- picker = "telescope",
},
})
require("nvim-treesitter.configs").setup({
ensure_installed = {},
modules = {},
sync_install = false,
auto_install = true,
ignore_install = {},
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
})
for _, plugin in pairs(enable_providers) do
vim.g["loaded_" .. plugin] = nil
vim.cmd("runtime " .. plugin)
end
vim.cmd("colorscheme everforest")
require("barbar").setup()
require("mini.ai").setup()
require("mini.surround").setup()
require("mini.pairs").setup({
modes = {
insert = true,
command = true,
terminal = false,
},
})
require("nvim-tree").setup()
require("auto-save").setup()
require("blink.cmp").setup({
keymap = {
preset = "enter",
["<CR>"] = { "select_and_accept", "fallback" },
},
})
require("lualine").setup({
options = {
icons_enabled = true,
theme = "everforest",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
always_show_tabline = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
refresh_time = 16, -- ~60fps
events = {
"WinEnter",
"BufEnter",
"BufWritePost",
"SessionLoadPost",
"FileChangedShellPost",
"VimResized",
"Filetype",
"CursorMoved",
"CursorMovedI",
"ModeChanged",
},
},
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-tool-installer").setup({
ensure_installed = {
"basedpyright",
"biome",
"djlint",
"emmet-language-server",
"html-lsp",
"lua-language-server",
"lwc-language-server",
"omnisharp",
"prettier",
"prettierd",
"python-lsp-server",
"ruff",
"selene",
"stylua",
"typescript-language-server",
},
})
vim.g.loaded_python3_provider = nil
-- lua... I need to move this
vim.lsp.config("lua_ls", {
settings = {
Lua = {
@ -292,77 +95,3 @@ vim.lsp.config("lua_ls", {
},
},
})
local logo =
[[
]]
logo = string.rep("\n", 8) .. logo .. "\n\n"
require("dashboard").setup({
theme = "hyper",
hide = {
statusline = true,
tabline = true,
winbar = true,
},
config = {
shortcut = {
{ desc = "変わっていく季節、変わらない毎日。" },
},
header = vim.split(logo, "\n"),
packages = { enable = false },
project = { enable = false },
mru = { enable = true, limit = 10, label = "最近使ったファイル:", cwd_only = false },
footer = function()
return { "" }
end,
},
})
local enable_providers = {
"python3_provider",
}
for _, plugin in pairs(enable_providers) do
vim.g["loaded_" .. plugin] = nil
vim.cmd("runtime " .. plugin)
end
vim.g.loaded_python3_provider = nil
require("prettier").setup({
bin = 'prettier', -- or `'prettierd'` (v0.23.3+)
filetypes = {
"css",
"graphql",
"html",
"javascript",
"javascriptreact",
"json",
"less",
"markdown",
"scss",
"typescript",
"typescriptreact",
"yaml",
},
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "htmldjango",
command = "setlocal shiftwidth=2 tabstop=2"
})

47
lua/config/keymaps.lua Normal file
View file

@ -0,0 +1,47 @@
-- unset space so it can be used as leader
vim.keymap.set("n", " ", "", { silent = true, remap = false })
-- source config
vim.keymap.set("n", "<leader>o", ":source $HOME/.config/nvim/init.lua<CR>")
-- move around windows
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "focus to l window" })
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "focus to r window" })
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "focus to dwn window" })
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "focus to up window" })
-- move lines up and down
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
-- quote around highlighted words
vim.keymap.set('v', "'", "c''<Esc>P")
vim.keymap.set('v', '"', 'c""<Esc>P')
-- non-floating terminal
vim.keymap.set('n', 'T', ":belowright split | terminal<CR> | :resize 8<CR>i")
-- toggle spellcheck
vim.keymap.set('n', '<leader>st', ':set spell!<CR>')
-- toggle nvim tree
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")
-- barbar
vim.keymap.set("n", "<leader>x", ":BufferClose<CR>")
-- (I need both options, one for windows, one for linux)
vim.keymap.set("n", "<A-h>", ":BufferPrevious<CR>")
vim.keymap.set("n", "<A-l>", ":BufferNext<CR>")
vim.keymap.set("n", "<A-,>", "<Cmd>BufferPrevious<CR>")
vim.keymap.set("n", "<A-.>", "<Cmd>BufferNext<CR>")
-- format
vim.keymap.set("n", "<leader>f", ":lua vim.lsp.buf.format()<CR>")
-- diagnostics
vim.keymap.set("n", "<leader>ds", ":lua vim.diagnostic.open_float()<CR>")
vim.keymap.set("n", "<leader>dn", function() vim.diagnostic.jump({ count = 1 }) end)
vim.keymap.set("n", "<leader>dp", function() vim.diagnostic.jump({ count = -1 }) end)

View file

@ -0,0 +1,3 @@
vim.pack.add{"https://github.com/Pocco81/auto-save.nvim"}
require("auto-save").setup()

View file

@ -0,0 +1,6 @@
vim.pack.add({
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
{ src = "https://github.com/romgrk/barbar.nvim" },
})
require("barbar").setup()

View file

@ -0,0 +1,8 @@
vim.pack.add{"https://github.com/saghen/blink.cmp"}
require("blink.cmp").setup({
keymap = {
preset = "enter",
["<CR>"] = { "select_and_accept", "fallback" },
},
})

View file

@ -0,0 +1,41 @@
vim.pack.add{"https://github.com/nvimdev/dashboard-nvim"}
local logo =
[[
]]
logo = string.rep("\n", 8) .. logo .. "\n\n"
require("dashboard").setup({
theme = "hyper",
hide = {
statusline = true,
tabline = true,
winbar = true,
},
config = {
shortcut = {
{ desc = "変わっていく季節、変わらない毎日。" },
},
header = vim.split(logo, "\n"),
packages = { enable = false },
project = { enable = false },
mru = { enable = true, limit = 10, label = "最近使ったファイル:", cwd_only = false },
footer = function()
return { "" }
end,
},
})

View file

@ -0,0 +1,57 @@
vim.pack.add{"https://github.com/nvim-lualine/lualine.nvim"}
require("lualine").setup({
options = {
icons_enabled = true,
theme = "everforest",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
always_show_tabline = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
refresh_time = 16, -- ~60fps
events = {
"WinEnter",
"BufEnter",
"BufWritePost",
"SessionLoadPost",
"FileChangedShellPost",
"VimResized",
"Filetype",
"CursorMoved",
"CursorMovedI",
"ModeChanged",
},
},
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})

View file

@ -0,0 +1,27 @@
vim.pack.add({
{ src = "https://github.com/mason-org/mason.nvim" },
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
{ src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" },
})
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-tool-installer").setup({
ensure_installed = {
"basedpyright",
"biome",
"djlint",
"emmet-language-server",
"html-lsp",
"lua-language-server",
"lwc-language-server",
"omnisharp",
"prettier",
"prettierd",
"python-lsp-server",
"ruff",
"selene",
"stylua",
"typescript-language-server",
},
})

View file

@ -0,0 +1,11 @@
vim.pack.add{"https://github.com/echasnovski/nvim-mini/mini.nvim"}
require("mini.ai").setup()
require("mini.surround").setup()
require("mini.pairs").setup({
modes = {
insert = true,
command = true,
terminal = false,
},
})

View file

@ -0,0 +1 @@
vim.pack.add{"https://github.com/neovim/nvim-lspconfig"}

View file

@ -0,0 +1,3 @@
vim.pack.add{"https://github.com/nvim-tree/nvim-tree.lua"}
require("nvim-tree").setup()

View file

@ -0,0 +1,19 @@
vim.pack.add{"https://github.com/MunifTanjim/prettier.nvim"}
require("prettier").setup({
bin = 'prettier', -- or `'prettierd'` (v0.23.3+)
filetypes = {
"css",
"graphql",
"html",
"javascript",
"javascriptreact",
"json",
"less",
"markdown",
"scss",
"typescript",
"typescriptreact",
"yaml",
},
})

View file

@ -0,0 +1,10 @@
vim.pack.add({
{ src = "https://github.com/nvim-lua/plenary.nvim" },
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
})
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })

View file

@ -0,0 +1,3 @@
vim.pack.add{"https://github.com/neanias/everforest-nvim.git"}
vim.cmd("colorscheme everforest")

View file

@ -0,0 +1,20 @@
vim.pack.add({
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate",
lazy = false,
},
})
require("nvim-treesitter.configs").setup({
ensure_installed = {},
modules = {},
sync_install = false,
auto_install = true,
ignore_install = {},
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
})

View file

@ -0,0 +1,19 @@
vim.pack.add({
{ src = "https://github.com/mfussenegger/nvim-dap" },
{ src = "https://github.com/mfussenegger/nvim-dap-python" },
{ src = "https://github.com/linux-cultist/venv-selector.nvim" },
})
require("dap-python").setup("python3")
require("venv-selector").setup({
-- Optional: Customize search paths for virtual environments
search = {
-- Example: Add a custom search path
-- { path = "~/my_projects/venvs", depth = 1 },
},
-- Optional: Customize plugin options
options = {
-- Example: Set a default picker (e.g., "telescope")
-- picker = "telescope",
},
})