feat: switch from lazy to vim.pack

This commit is contained in:
2026-04-10 14:42:25 +02:00
parent 190b3ecebd
commit 28c45c8390
35 changed files with 1168 additions and 1455 deletions
+2 -7
View File
@@ -1,12 +1,7 @@
local lsp = require("lsp") local lsp = require("lsp")
local util = require("util")
local lua_library_paths = { local lua_library_paths = require("plugin").get_paths()
vim.env.VIMRUNTIME, table.insert(lua_library_paths, vim.env.VIMRUNTIME)
}
for _, plugin in ipairs(require("lazy").plugins()) do
table.insert(lua_library_paths, plugin.dir)
end
---@type vim.lsp.Config ---@type vim.lsp.Config
return { return {
+28 -40
View File
@@ -21,45 +21,33 @@ for _, file in ipairs(files) do
end end
end end
local ok, err = pcall(require, "bootstrap") require("plugin").setup({
if not ok then "https://github.com/navarasu/onedark.nvim",
log.error("Error during bootstrap") "https://github.com/nvim-lua/plenary.nvim",
log.error(err:gsub("\t", " ")) "https://github.com/rcarriga/nvim-notify",
return "https://github.com/debugloop/telescope-undo.nvim",
end {
"https://github.com/nvim-telescope/telescope-fzf-native.nvim",
---@type LazyConfig build = { "make" },
local opts = {
install = {
colorscheme = { "onedark" },
}, },
ui = { "https://github.com/nvim-telescope/telescope.nvim",
icons = { {
cmd = "", "https://github.com/saghen/blink.cmp",
config = "", version = vim.version.range("^1"),
event = "",
favorite = "",
ft = "",
init = "",
import = "",
keys = "",
lazy = "",
loaded = "",
not_loaded = "",
plugin = "",
runtime = "",
require = " ",
source = "",
start = "",
task = "",
list = {
"",
"",
"",
"",
},
},
}, },
} "https://github.com/neovim/nvim-lspconfig",
"https://github.com/mason-org/mason.nvim",
require("lazy").setup("plugins", opts) "https://github.com/owallb/mason-auto-install.nvim",
"https://github.com/mfussenegger/nvim-dap",
"https://github.com/igorlfs/nvim-dap-view",
"https://github.com/nvim-treesitter/nvim-treesitter",
"https://github.com/numToStr/Comment.nvim",
"https://github.com/j-hui/fidget.nvim",
"https://github.com/rbong/vim-flog",
"https://github.com/tpope/vim-fugitive",
"https://github.com/lewis6991/gitsigns.nvim",
"https://github.com/MagicDuck/grug-far.nvim",
"https://github.com/nvim-tree/nvim-tree.lua",
"https://github.com/stevearc/oil.nvim",
"https://github.com/hedyhli/outline.nvim",
})
-32
View File
@@ -1,32 +0,0 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"aerial.nvim": { "branch": "master", "commit": "7a6a42791eb2b54a7115c7db4488981f93471770" },
"blink.cmp": { "branch": "main", "commit": "4b18c32adef2898f95cdef6192cbd5796c1a332d" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"gitsigns.nvim": { "branch": "main", "commit": "1ce96a464fdbc24208e24c117e2021794259005d" },
"grug-far.nvim": { "branch": "main", "commit": "275dbedc96e61a6b8d1dfb28ba51586ddd233dcf" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"mason-auto-install.nvim": { "branch": "main", "commit": "6c9175845c91a416d643ab86214466b8caf8d43b" },
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
"nvim-colorizer.lua": { "branch": "master", "commit": "51cf7c995ed1eb6642aecf19067ee634fa1b6ba2" },
"nvim-dap": { "branch": "master", "commit": "e47878dcf1ccc30136b30d19ab19fe76946d61cd" },
"nvim-dap-repl-highlights": { "branch": "master", "commit": "f31deba47fe3ee6ff8d2f13d9dbd06b2d1ae06b5" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-lspconfig": { "branch": "master", "commit": "66fd02ad1c7ea31616d3ca678fa04e6d0b360824" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"nvim-tree.lua": { "branch": "master", "commit": "037d89e60fb01a6c11a48a19540253b8c72a3c32" },
"nvim-treesitter": { "branch": "main", "commit": "45a07f869b0cffba342276f2c77ba7c116d35db8" },
"nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" },
"oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" },
"onedark.nvim": { "branch": "master", "commit": "213c23ae45a04797572242568d5d51937181792d" },
"orgmode": { "branch": "master", "commit": "e448c72ebc3d7a10d00a865b41b25336122a2c67" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
"telescope-undo.nvim": { "branch": "main", "commit": "928d0c2dc9606e01e2cc547196f48d2eaecf58e5" },
"telescope.nvim": { "branch": "master", "commit": "ad7d9580338354ccc136e5b8f0aa4f880434dcdc" },
"undotree": { "branch": "master", "commit": "fc28931fbfba66ab75d9af23fe46ffbbb9de6e8c" },
"vim-dispatch": { "branch": "master", "commit": "a2ff28abdb2d89725192db5b8562977d392a4d3f" },
"vim-flog": { "branch": "master", "commit": "665b16ac8915f746bc43c9572b4581a5e9047216" },
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }
}
-37
View File
@@ -1,37 +0,0 @@
local version = vim.version()
if version.major == 0 then
if version.minor < 11 then
error(
"Neovim version 0.11 or above is required with this configuration."
)
end
end
local util = require("util")
-- Install lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
util.assert_installed("git")
if not os.getenv("CC") then
util.assert_installed("cc")
end
util.assert_installed("make")
util.assert_any_installed({ "curl", "wget" })
util.assert_installed("unzip")
util.assert_installed("tar")
util.assert_installed("gzip")
local resp = vim.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
}):wait()
assert(resp.code == 0, "Failed to download lazy")
end
vim.opt.rtp:prepend(lazypath)
+4
View File
@@ -177,6 +177,10 @@ vim.keymap.set("n", "<leader>dl", vim.diagnostic.setloclist)
vim.keymap.set("n", "grt", vim.lsp.buf.type_definition) vim.keymap.set("n", "grt", vim.lsp.buf.type_definition)
vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "<leader>pp", function()
vim.pack.update(nil, { offline = true })
end)
-- Default bindings that are good to know: -- Default bindings that are good to know:
-- insert mode: -- insert mode:
-- <C-T> - indent, see :h i_CTRL-T -- <C-T> - indent, see :h i_CTRL-T
+165
View File
@@ -0,0 +1,165 @@
local log = require("log")
---@class ow.Plugin.Spec
---@field [1] string
---@field name? string
---@field version? string | vim.VersionRange
---@field lazy? boolean
---@field build? string[] | fun(self: ow.Plugin): boolean
---@class ow.Plugin : ow.Plugin.Spec
---@field path string
---@type ow.Plugin[]
local plugins = {}
---@param plugin ow.Plugin
local function load(plugin)
vim.cmd.packadd(plugin.name)
local name = plugin.name:match("[^.]+"):lower()
local path = string.format(
"%s/lua/plugins/%s.lua",
vim.fn.stdpath("config"),
name
)
if vim.uv.fs_stat(path) then
local ok, err = pcall(dofile, path)
if not ok then
log.error("Failed to load %s: %s", name, err)
end
end
end
---@param spec string | ow.Plugin.Spec
---@return vim.pack.Spec
local function to_pack_spec(spec)
if type(spec) == "string" then
return { src = spec }
end
return {
src = spec[1],
name = spec.name,
version = spec.version,
data = {
lazy = spec.lazy,
build = spec.build,
},
}
end
---@param plugin ow.Plugin
---@return boolean success
local function run_build(plugin)
if type(plugin.build) == "function" then
return plugin.build(plugin)
elseif type(plugin.build) == "table" then
local ret = vim.system(
plugin.build --[[@as table]],
{ cwd = plugin.path }
):wait()
return ret.code == 0 and ret.signal == 0
end
log.error("invalid build parameter for %s", plugin.name)
return false
end
---@class ow.Plugin.PackEvent.Data
---@field active boolean
---@field kind "install" | "update" | "delete"
---@field spec vim.pack.Spec
---@field path string
---@class ow.Plugin.PackEvent : vim.api.keyset.create_autocmd.callback_args
---@field data ow.Plugin.PackEvent.Data
---@param plugin ow.Plugin
---@param events ow.Plugin.PackEvent[]
---@return boolean success
local function handle_pack_events(plugin, events)
if not plugin.build then
return true
end
for _, ev in ipairs(events) do
if ev.data.spec.name == plugin.name
and ev.event == "PackChanged"
and (ev.data.kind == "install" or ev.data.kind == "update")
then
vim.cmd.packadd(plugin.name)
return run_build(plugin)
end
end
return true
end
local M = {}
function M.get_paths()
local paths = {}
for _, plugin in ipairs(plugins) do
table.insert(paths, plugin.path)
end
return paths
end
---@param specs (string | ow.Plugin.Spec)[]
function M.setup(specs)
---@type ow.Plugin.PackEvent[]
local events = {}
local id = vim.api.nvim_create_autocmd(
{ "PackChangedPre", "PackChanged" },
{
---@param ev ow.Plugin.PackEvent
callback = function(ev)
table.insert(events, ev)
end
}
)
vim.pack.add(vim.tbl_map(to_pack_spec, specs), {
load = function(data)
local d = data.spec.data or {}
---@type ow.Plugin
local plugin = {
[1] = data.spec.src,
name = data.spec.name,
version = data.spec.version,
lazy = d.lazy or false,
build = d.build,
path = data.path,
}
table.insert(plugins, plugin)
end
})
vim.api.nvim_del_autocmd(id)
local lazy_plugins = {}
for _, plugin in ipairs(plugins) do
if not handle_pack_events(plugin, events) then
return
end
if plugin.lazy then
table.insert(lazy_plugins, plugin)
else
load(plugin)
end
end
vim.api.nvim_create_autocmd("UIEnter", {
once = true,
callback = vim.schedule_wrap(function()
for _, plugin in ipairs(lazy_plugins) do
load(plugin)
end
end)
})
end
return M
+81 -89
View File
@@ -1,96 +1,88 @@
---@type LazyPluginSpec require("blink.cmp").setup({
return { completion = {
"saghen/blink.cmp", documentation = {
-- use a release tag to download pre-built binaries auto_show = true,
version = "1.*",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
completion = {
documentation = {
auto_show = true,
window = {
winhighlight = "",
},
},
ghost_text = {
enabled = true,
},
list = {
selection = {
preselect = false,
auto_insert = false,
},
},
menu = {
border = "none",
draw = {
align_to = "simple_label",
columns = {
{ "simple_label" },
{ "kind_icon", "label_description", gap = 1 },
},
components = {
simple_label = {
width = { fill = true, max = 60 },
text = function(ctx)
return ctx.label
end,
highlight = function(ctx)
local highlights = {
{
0,
#ctx.label,
group = ctx.deprecated
and "BlinkCmpLabelDeprecated"
or "BlinkCmpLabel",
},
}
for _, idx in ipairs(ctx.label_matched_indices) do
table.insert(highlights, {
idx,
idx + 1,
group = "BlinkCmpLabelMatch",
})
end
return highlights
end,
},
},
},
},
},
fuzzy = {
implementation = "prefer_rust_with_warning",
},
signature = {
enabled = true,
window = { window = {
winhighlight = "", winhighlight = "",
show_documentation = false,
}, },
}, },
sources = { ghost_text = {
default = { enabled = true,
"lsp",
"path",
},
transform_items = function(_, items)
return vim.tbl_filter(function(item)
return item.kind
~= require("blink.cmp.types").CompletionItemKind.Snippet
end, items)
end,
}, },
keymap = { list = {
preset = "none", selection = {
["<Tab>"] = { "insert_next", "fallback" }, preselect = false,
["<S-Tab>"] = { "insert_prev", "fallback" }, auto_insert = false,
["<CR>"] = { "accept", "fallback" }, },
["<C-k>"] = { "show_signature", "hide_signature", "fallback" }, },
["<C-n>"] = { "snippet_forward", "fallback" }, menu = {
["<C-p>"] = { "snippet_backward", "fallback" }, border = "none",
draw = {
align_to = "simple_label",
columns = {
{ "simple_label" },
{ "kind_icon", "label_description", gap = 1 },
},
components = {
simple_label = {
width = { fill = true, max = 60 },
text = function(ctx)
return ctx.label
end,
highlight = function(ctx)
local highlights = {
{
0,
#ctx.label,
group = ctx.deprecated
and "BlinkCmpLabelDeprecated"
or "BlinkCmpLabel",
},
}
for _, idx in ipairs(ctx.label_matched_indices) do
table.insert(highlights, {
idx,
idx + 1,
group = "BlinkCmpLabelMatch",
})
end
return highlights
end,
},
},
},
}, },
}, },
} fuzzy = {
implementation = "prefer_rust_with_warning",
},
signature = {
enabled = true,
window = {
winhighlight = "",
show_documentation = false,
},
},
sources = {
default = {
"lsp",
"path",
},
transform_items = function(_, items)
return vim.tbl_filter(function(item)
return item.kind
~= require("blink.cmp.types").CompletionItemKind.Snippet
end, items)
end,
},
keymap = {
preset = "none",
["<Tab>"] = { "insert_next", "fallback" },
["<S-Tab>"] = { "insert_prev", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<C-k>"] = { "show_signature", "hide_signature", "fallback" },
["<C-n>"] = { "snippet_forward", "fallback" },
["<C-p>"] = { "snippet_backward", "fallback" },
},
})
+5 -11
View File
@@ -1,11 +1,5 @@
-- https://github.com/numToStr/Comment.nvim ---@diagnostic disable-next-line: missing-fields
require("Comment").setup({
---@type LazyPluginSpec --ignore empty lines
return { ignore = "^$",
"numToStr/Comment.nvim", })
event = "VeryLazy",
opts = {
--ignore empty lines
ignore = "^$",
},
}
+1 -9
View File
@@ -1,9 +1 @@
-- https://github.com/j-hui/fidget.nvim require("fidget").setup()
---@type LazyPluginSpec
return {
"j-hui/fidget.nvim",
tag = "legacy",
event = "LspAttach",
config = true,
}
-10
View File
@@ -1,10 +0,0 @@
-- https://github.com/rbong/vim-flog
---@type LazyPluginSpec
return {
"rbong/vim-flog",
---@type LazyKeysSpec[]
keys = {
{ "<leader>gl", vim.cmd.Flog, mode = "n" },
},
}
-99
View File
@@ -1,99 +0,0 @@
-- https://github.com/tpope/vim-fugitive
local function open_git_status()
local previous_win = vim.api.nvim_get_current_win()
vim.cmd("leftabove vertical G")
vim.api.nvim_win_set_width(0, 50)
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
vim.api.nvim_set_current_win(previous_win)
end
local function get_git_status_win()
local current_tabpage = vim.api.nvim_get_current_tabpage()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
local buf = vim.api.nvim_win_get_buf(win)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if
buftype == "nowrite"
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
then
return win
end
end
end
local function toggle_git_status()
local win = get_git_status_win()
if win then
vim.api.nvim_win_close(win, false)
return
end
open_git_status()
end
---@type LazyPluginSpec
return {
"tpope/vim-fugitive",
event = "VeryLazy",
---@type LazyKeysSpec[]
keys = {
{
"<leader>gd",
vim.cmd.Gvdiffsplit,
mode = "n",
},
{
"<leader>gD",
function()
vim.cmd.Gvdiffsplit("HEAD")
end,
mode = "n",
},
{
"<leader>gh",
vim.cmd.Ghdiffsplit,
mode = "n",
},
{
"<leader>gH",
function()
vim.cmd.Ghdiffsplit("HEAD")
end,
mode = "n",
},
{
"<leader>gc",
function()
vim.cmd.G("commit")
end,
mode = "n",
},
{
"<leader>ga",
function()
vim.cmd.G("commit --amend")
end,
mode = "n",
},
{
"<leader>gp",
function()
vim.cmd.G("push")
end,
mode = "n",
},
{
"<leader>gg",
toggle_git_status,
mode = "n",
},
},
config = function()
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
vim.fn["fugitive#ReloadStatus"]()
end,
})
end,
}
+57 -64
View File
@@ -1,65 +1,58 @@
-- https://github.com/lewis6991/gitsigns.nvim require("gitsigns").setup({
preview_config = {
---@type LazyPluginSpec border = "single",
return {
"lewis6991/gitsigns.nvim",
event = "VeryLazy",
opts = {
preview_config = {
border = "single",
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set(
"n",
"<leader>gv",
gs.select_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr })
vim.keymap.set("x", "<leader>gs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { buffer = bufnr })
vim.keymap.set(
{ "n", "x" },
"<leader>gu",
gs.undo_stage_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>g?",
gs.preview_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gb", function()
gs.blame_line({ full = true, ignore_whitespace = true })
end, { buffer = bufnr })
vim.keymap.set({ "n", "x" }, "]g", function()
gs.next_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
vim.keymap.set({ "n", "x" }, "[g", function()
gs.prev_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
end,
attach_to_untracked = true,
sign_priority = 100,
}, },
} on_attach = function(bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set(
"n",
"<leader>gv",
gs.select_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr })
vim.keymap.set("x", "<leader>gs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { buffer = bufnr })
vim.keymap.set(
{ "n", "x" },
"<leader>gu",
gs.undo_stage_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>g?",
gs.preview_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gb", function()
gs.blame_line({ full = true, ignore_whitespace = true })
end, { buffer = bufnr })
vim.keymap.set({ "n", "x" }, "]g", function()
gs.next_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
vim.keymap.set({ "n", "x" }, "[g", function()
gs.prev_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
end,
attach_to_untracked = true,
sign_priority = 100,
})
+1 -5
View File
@@ -1,5 +1 @@
---@type LazyPluginSpec require("grug-far").setup()
return {
"MagicDuck/grug-far.nvim",
config = true,
}
-5
View File
@@ -1,5 +0,0 @@
---@type LazyPluginSpec
return {
"neovim/nvim-lspconfig",
config = require("lsp").setup,
}
+50 -58
View File
@@ -1,60 +1,52 @@
---@type LazyPluginSpec require("mason-auto-install").setup({
return { packages = {
"owallb/mason-auto-install.nvim", {
dependencies = { "bash-language-server",
"neovim/nvim-lspconfig", dependencies = { "shellcheck", "shfmt" },
},
---@type MasonAutoInstall.Config
opts = {
packages = {
{
"bash-language-server",
dependencies = { "shellcheck", "shfmt" },
},
-- "clangd",
{
"cmake-language-server",
dependencies = { "golines" },
},
"gopls",
"hyprls",
{
"intelephense",
dependencies = { "phpcs" },
},
"jedi-language-server",
{
"lemminx",
dependencies = { "xmlformatter" },
},
"lua-language-server",
"mesonlsp",
"oxfmt",
"oxlint",
"ruff",
"pyright",
"pyrefly",
{
"prettier",
filetypes = {
"json",
"jsonc",
"markdown",
"html",
"css",
"scss",
"less",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
},
"rust-analyzer",
"svelte-language-server",
"tailwindcss-language-server",
"tsgo",
"zls",
}, },
-- "clangd",
{
"cmake-language-server",
dependencies = { "golines" },
},
"gopls",
"hyprls",
{
"intelephense",
dependencies = { "phpcs" },
},
"jedi-language-server",
{
"lemminx",
dependencies = { "xmlformatter" },
},
"lua-language-server",
"mesonlsp",
"oxfmt",
"oxlint",
"ruff",
"pyright",
"pyrefly",
{
"prettier",
filetypes = {
"json",
"jsonc",
"markdown",
"html",
"css",
"scss",
"less",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
},
"rust-analyzer",
"svelte-language-server",
"tailwindcss-language-server",
"tsgo",
"zls",
}, },
} })
+1 -8
View File
@@ -1,8 +1 @@
-- https://github.com/williamboman/mason.nvim require("mason").setup()
---@type LazyPluginSpec
return {
"williamboman/mason.nvim",
event = "VeryLazy",
config = true,
}
-17
View File
@@ -1,17 +0,0 @@
-- https://github.com/rcarriga/nvim-notify
---@type LazyPluginSpec
return {
"rcarriga/nvim-notify",
priority = 900,
lazy = false,
opts = {
render = "default",
stages = "static",
},
config = function(_, opts)
---@type notify
vim.notify = require("notify")
vim.notify.setup(opts)
end,
}
-19
View File
@@ -1,19 +0,0 @@
-- https://github.com/NvChad/nvim-colorizer.lua
---@type LazyPluginSpec
return {
"NvChad/nvim-colorizer.lua",
enabled = false,
opts = {
user_default_options = {
names = false,
RGB = false,
RRGGBB = true,
RRGGBBAA = true,
AARRGGBB = true,
rgb_fn = true,
hsl_fn = true,
mode = "virtualtext",
},
},
}
-93
View File
@@ -1,93 +0,0 @@
-- https://github.com/igorlfs/nvim-dap-view
---@type LazyPluginSpec
return {
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
keys = {
{
"<Leader>du",
function()
require("dapui").toggle()
end,
},
{
"<Leader>de",
function()
---@diagnostic disable-next-line: missing-fields
require("dapui").eval(nil, { context = "hover", enter = true })
end,
mode = { "x", "n" },
},
{
"<Leader>dw",
function()
require("dapui").elements.watches.add(vim.fn.expand("<cexpr>"))
end,
},
},
opts = {
controls = {
element = "repl",
enabled = false,
},
expand_lines = true,
floating = {
border = "single",
mappings = {
close = { "q", "<Esc>" },
},
},
force_buffers = true,
icons = {
collapsed = "+",
current_frame = "*",
expanded = "-",
},
layouts = {
{
elements = {
{
id = "scopes",
size = 0.25,
},
{
id = "breakpoints",
size = 0.25,
},
{
id = "stacks",
size = 0.25,
},
{
id = "watches",
size = 0.25,
},
},
position = "right",
size = 50,
},
{
elements = {
{
id = "repl",
},
},
position = "bottom",
size = 15,
},
},
mappings = {
edit = "e",
expand = { "<CR>", "<2-LeftMouse>", "<Tab>" },
open = "o",
remove = "d",
repl = "r",
toggle = "t",
},
render = {
indent = 1,
max_value_lines = 100,
},
},
}
+3
View File
@@ -0,0 +1,3 @@
local dap_view = require("dap-view")
dap_view.setup()
vim.keymap.set("n", "<Leader>du", dap_view.toggle)
+141 -206
View File
@@ -1,217 +1,152 @@
-- https://github.com/mfussenegger/nvim-dap
local hover = require("dap.hover")
local log = require("log") local log = require("log")
local dap = require("dap")
---@type LazyPluginSpec vim.api.nvim_set_hl(0, "DebugPC", {
return { bg = "NONE",
"mfussenegger/nvim-dap", fg = "NONE",
lazy = false, })
keys = {
{
"<Leader>db",
function()
require("dap").toggle_breakpoint()
end,
},
{
"<Leader>df",
function()
require("dap").focus_frame()
end,
},
{
"<PageUp>",
function()
require("dap").up()
end,
},
{
"<PageDown>",
function()
require("dap").down()
end,
},
{
"<Leader>dh",
hover,
mode = { "n", "x" },
},
{
"<Leader>dr",
function()
require("dap").repl.toggle()
end,
mode = { "n", "x" },
},
{
"<F2>",
function()
require("dap").step_into()
end,
},
{
"<F3>",
function()
require("dap").step_over()
end,
},
{
"<F4>",
function()
require("dap").step_out()
end,
},
{
"<F5>",
function()
require("dap").continue()
end,
},
{
"<F9>",
function()
require("dap").terminate()
end,
},
},
config = function()
local dap = require("dap")
vim.api.nvim_set_hl(0, "DebugPC", { vim.api.nvim_create_user_command(
bg = "NONE", "Debug",
fg = "NONE", ---@param opts vim.api.keyset.create_user_command.command_args
}) function(opts)
local cfgs = dap.configurations[vim.bo.filetype]
if not cfgs then
log.error(
"No configurations available for filetype %s",
vim.bo.filetype
)
return
end
vim.api.nvim_create_user_command( local function run_config(cfg)
"Debug", local all_args = vim.fn.split(opts.args)
---@param opts vim.api.keyset.create_user_command.command_args cfg.program = all_args[1]
function(opts)
local cfgs = dap.configurations[vim.bo.filetype]
if not cfgs then
log.error(
"No configurations available for filetype %s",
vim.bo.filetype
)
return
end
local function run_config(cfg) local args = {}
local all_args = vim.fn.split(opts.args) for i = 2, #all_args do
cfg.program = all_args[1] table.insert(args, all_args[i])
end
cfg.args = args
local args = {} dap.run(cfg)
for i = 2, #all_args do end
table.insert(args, all_args[i])
end
cfg.args = args
dap.run(cfg) if #cfgs == 1 then
end run_config(cfgs[1])
return
end
if #cfgs == 1 then local names = {}
run_config(cfgs[1]) for _, c in ipairs(cfgs) do
return table.insert(names, c.name)
end end
local names = {} vim.ui.select(names, {
for _, c in ipairs(cfgs) do prompt = "Select DAP configuration to use:",
table.insert(names, c.name) }, function(choice, idx)
end if choice and idx then
run_config(cfgs[idx])
vim.ui.select(names, { end
prompt = "Select DAP configuration to use:", end)
}, function(choice, idx)
if choice and idx then
run_config(cfgs[idx])
end
end)
end,
{
nargs = "+",
---@param ArgLead string
---@param CmdLine string
complete = function(ArgLead, CmdLine, CursorPos)
local _, spaces = CmdLine:sub(1, CursorPos):gsub("%s+", "")
if spaces == 1 then
return vim.fn.getcompletion(ArgLead, "file")
end
end,
}
)
-- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap" },
}
dap.adapters.lldb = {
type = "executable",
command = "lldb-dap",
}
dap.adapters.python = {
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.c = {
{
type = "gdb",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
-- dap.configurations.c = {
-- {
-- type = "lldb",
-- request = "launch",
-- name = "Launch",
-- program = function()
-- local path = vim.fn.input({
-- prompt = "Path to executable: ",
-- default = vim.fn.getcwd() .. "/",
-- completion = "file",
-- })
-- return (path and path ~= "") and path or dap.ABORT
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- console = "internalConsole",
-- },
-- }
dap.configurations.cpp = dap.configurations.c
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
},
}
end, end,
{
nargs = "+",
---@param ArgLead string
---@param CmdLine string
complete = function(ArgLead, CmdLine, CursorPos)
local _, spaces = CmdLine:sub(1, CursorPos):gsub("%s+", "")
if spaces == 1 then
return vim.fn.getcompletion(ArgLead, "file")
end
end,
}
)
-- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap" },
} }
dap.adapters.lldb = {
type = "executable",
command = "lldb-dap",
}
dap.adapters.python = {
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.c = {
{
type = "gdb",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
-- dap.configurations.c = {
-- {
-- type = "lldb",
-- request = "launch",
-- name = "Launch",
-- program = function()
-- local path = vim.fn.input({
-- prompt = "Path to executable: ",
-- default = vim.fn.getcwd() .. "/",
-- completion = "file",
-- })
-- return (path and path ~= "") and path or dap.ABORT
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- console = "internalConsole",
-- },
-- }
dap.configurations.cpp = dap.configurations.c
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
},
}
vim.keymap.set("n", "<Leader>db", dap.toggle_breakpoint)
vim.keymap.set("n", "<Leader>df", dap.focus_frame)
vim.keymap.set("n", "<PageUp>", dap.up)
vim.keymap.set("n", "<PageDown>", dap.down)
vim.keymap.set({ "n", "x" }, "<Leader>dh", require("dap.hover"))
vim.keymap.set({ "n", "x" }, "<Leader>dr", dap.repl.toggle)
vim.keymap.set("n", "<F2>", dap.step_into)
vim.keymap.set("n", "<F3>", dap.step_over)
vim.keymap.set("n", "<F4>", dap.step_out)
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F9>", dap.terminate)
+1
View File
@@ -0,0 +1 @@
require("lsp").setup()
+6
View File
@@ -0,0 +1,6 @@
vim.notify = require("notify")
---@diagnostic disable-next-line: missing-fields
vim.notify.setup({
render = "default",
stages = "static",
})
+207 -231
View File
@@ -34,241 +34,217 @@ local function disable_highlights()
}) })
end end
---@type LazyPluginSpec vim.keymap.set("n", "<leader>tt", function()
return { require("nvim-tree.api").tree.toggle({ find_file = true, focus = false, })
"nvim-tree/nvim-tree.lua", end)
dependencies = {
"tpope/vim-fugitive",
"nvim-tree/nvim-web-devicons",
},
event = "VimEnter",
keys = {
{
"<leader>tt",
function()
require("nvim-tree.api").tree.toggle({
find_file = true,
focus = false,
})
end,
},
{
"ga",
function()
require("nvim-tree.api").tree.open()
end,
},
},
config = function()
---@class nvim_tree.api.decorator.UserDecorator
local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
---@class GitIgnoreDecorator: nvim_tree.api.decorator.UserDecorator ---@class nvim_tree.api.decorator.UserDecorator
local GitIgnoreDecorator = UserDecorator:extend() local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
function GitIgnoreDecorator:new() ---@class GitIgnoreDecorator: nvim_tree.api.decorator.UserDecorator
self.enabled = true local GitIgnoreDecorator = UserDecorator:extend()
self.highlight_range = "name"
self.icon_placement = "none" function GitIgnoreDecorator:new()
self.file_hl = "NvimTreeGitFileIgnoredHL" self.enabled = true
self.folder_hl = "NvimTreeGitFolderIgnoredHL" self.highlight_range = "name"
self.icon_placement = "none"
self.file_hl = "NvimTreeGitFileIgnoredHL"
self.folder_hl = "NvimTreeGitFolderIgnoredHL"
end
---@param node Node
---@return string? highlight_group
function GitIgnoreDecorator:highlight_group(node)
local status = node.git_status
if not status then
return
end
if status.file == "!!" then
return self.file_hl
elseif status.dir and status.dir.direct == "!!" then
return self.folder_hl
end
end
local signs = require("lsp").diagnostic_signs
require("nvim-tree").setup({
on_attach = function(bufnr)
local function opts(desc)
return {
desc = "nvim-tree: " .. desc,
buffer = bufnr,
noremap = true,
silent = true,
nowait = true,
}
end end
---@param node Node local api = require("nvim-tree.api")
---@return string? highlight_group api.config.mappings.default_on_attach(bufnr)
function GitIgnoreDecorator:highlight_group(node)
local status = node.git_status
if not status then
return
end
if status.file == "!!" then vim.keymap.del("n", "D", { buffer = bufnr })
return self.file_hl vim.keymap.del("n", "bt", { buffer = bufnr })
elseif status.dir and status.dir.direct == "!!" then
return self.folder_hl
end
end
local signs = require("lsp").diagnostic_signs vim.keymap.set("n", "d", api.fs.trash, opts("Trash"))
require("nvim-tree").setup({ vim.keymap.set(
on_attach = function(bufnr) "n",
local function opts(desc) "bd",
return { api.marks.bulk.trash,
desc = "nvim-tree: " .. desc, opts("Trash Bookmarked")
buffer = bufnr, )
noremap = true, vim.keymap.set("n", "<C-l>", api.node.open.edit, opts("Open"))
silent = true, vim.keymap.set(
nowait = true, "n",
} "<C-h>",
end api.node.navigate.parent_close,
opts("Close Directory")
local api = require("nvim-tree.api") )
api.config.mappings.default_on_attach(bufnr)
vim.keymap.del("n", "D", { buffer = bufnr })
vim.keymap.del("n", "bt", { buffer = bufnr })
vim.keymap.set("n", "d", api.fs.trash, opts("Trash"))
vim.keymap.set(
"n",
"bd",
api.marks.bulk.trash,
opts("Trash Bookmarked")
)
vim.keymap.set("n", "<C-l>", api.node.open.edit, opts("Open"))
vim.keymap.set(
"n",
"<C-h>",
api.node.navigate.parent_close,
opts("Close Directory")
)
end,
hijack_cursor = true,
hijack_netrw = false,
view = {
width = 50,
preserve_window_proportions = true,
},
renderer = {
full_name = true,
root_folder_label = function(path)
local label = vim.fn.fnamemodify(path, ":~")
local git_head = vim.fn.FugitiveHead()
if git_head ~= "" then
label = label .. ("  %s"):format(git_head)
end
return label
end,
special_files = {},
decorators = {
"Git",
GitIgnoreDecorator,
"Open",
"Modified",
"Bookmark",
"Diagnostics",
"Copied",
"Cut",
},
highlight_modified = "icon",
highlight_bookmarks = "name",
highlight_clipboard = "all",
indent_markers = {
enable = true,
icons = {
corner = "",
none = "",
},
},
icons = {
git_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "after",
symlink_arrow = " -> ",
show = {
file = true,
folder = true,
folder_arrow = false,
bookmarks = false,
},
web_devicons = {
file = {
color = false,
},
},
glyphs = {
modified = "*",
git = {
unstaged = "M",
staged = "M",
unmerged = "!",
renamed = "R",
untracked = "?",
deleted = "D",
ignored = " ",
},
},
},
},
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
icons = {
hint = signs.text[vim.diagnostic.severity.HINT],
info = signs.text[vim.diagnostic.severity.INFO],
warning = signs.text[vim.diagnostic.severity.WARN],
error = signs.text[vim.diagnostic.severity.ERROR],
},
},
modified = {
enable = true,
},
filters = {
git_ignored = false,
custom = { "^\\.git$" },
},
live_filter = {
prefix = "Filter: ",
always_show_folders = false,
},
filesystem_watchers = {
enable = true,
},
actions = {
use_system_clipboard = false,
change_dir = {
enable = false,
},
expand_all = {
exclude = { ".venv", "build" },
},
open_file = {
window_picker = {
enable = false,
},
},
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
help = {
sort_by = "desc",
},
sync_root_with_cwd = true,
git = {
show_on_open_dirs = false,
},
})
override_highlights()
disable_highlights()
vim.api.nvim_create_autocmd("QuitPre", {
callback = function()
local tree_wins = {}
local floating_wins = {}
local wins = vim.api.nvim_list_wins()
for _, w in ipairs(wins) do
local bufname =
vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
if bufname:match("NvimTree_") ~= nil then
table.insert(tree_wins, w)
end
if vim.api.nvim_win_get_config(w).relative ~= "" then
table.insert(floating_wins, w)
end
end
if 1 == #wins - #floating_wins - #tree_wins then
-- Should quit, so we close all invalid windows.
for _, w in ipairs(tree_wins) do
vim.api.nvim_win_close(w, true)
end
end
end,
})
end, end,
} hijack_cursor = true,
hijack_netrw = false,
view = {
width = 50,
preserve_window_proportions = true,
},
renderer = {
full_name = true,
root_folder_label = function(path)
local label = vim.fn.fnamemodify(path, ":~")
local git_head = vim.fn.FugitiveHead()
if git_head ~= "" then
label = label .. ("  %s"):format(git_head)
end
return label
end,
special_files = {},
decorators = {
"Git",
GitIgnoreDecorator,
"Open",
"Modified",
"Bookmark",
"Diagnostics",
"Copied",
"Cut",
},
highlight_modified = "icon",
highlight_bookmarks = "name",
highlight_clipboard = "all",
indent_markers = {
enable = true,
icons = {
corner = "",
none = "",
},
},
icons = {
git_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "after",
symlink_arrow = " -> ",
show = {
file = true,
folder = true,
folder_arrow = false,
bookmarks = false,
},
web_devicons = {
file = {
color = false,
},
},
glyphs = {
modified = "*",
git = {
unstaged = "M",
staged = "M",
unmerged = "!",
renamed = "R",
untracked = "?",
deleted = "D",
ignored = " ",
},
},
},
},
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
icons = {
hint = signs.text[vim.diagnostic.severity.HINT],
info = signs.text[vim.diagnostic.severity.INFO],
warning = signs.text[vim.diagnostic.severity.WARN],
error = signs.text[vim.diagnostic.severity.ERROR],
},
},
modified = {
enable = true,
},
filters = {
git_ignored = false,
custom = { "^\\.git$" },
},
live_filter = {
prefix = "Filter: ",
always_show_folders = false,
},
filesystem_watchers = {
enable = true,
},
actions = {
use_system_clipboard = false,
change_dir = {
enable = false,
},
expand_all = {
exclude = { ".venv", "build" },
},
open_file = {
window_picker = {
enable = false,
},
},
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
help = {
sort_by = "desc",
},
sync_root_with_cwd = true,
git = {
show_on_open_dirs = false,
},
})
override_highlights()
disable_highlights()
vim.api.nvim_create_autocmd("QuitPre", {
callback = function()
local tree_wins = {}
local floating_wins = {}
local wins = vim.api.nvim_list_wins()
for _, w in ipairs(wins) do
local bufname =
vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
if bufname:match("NvimTree_") ~= nil then
table.insert(tree_wins, w)
end
if vim.api.nvim_win_get_config(w).relative ~= "" then
table.insert(floating_wins, w)
end
end
if 1 == #wins - #floating_wins - #tree_wins then
-- Should quit, so we close all invalid windows.
for _, w in ipairs(tree_wins) do
vim.api.nvim_win_close(w, true)
end
end
end,
})
+36 -45
View File
@@ -1,7 +1,6 @@
-- https://github.com/nvim-treesitter/nvim-treesitter local log = require("log")
local languages = { local languages = {
"dap_repl",
"bash", "bash",
"zsh", "zsh",
"python", "python",
@@ -23,54 +22,46 @@ local languages = {
"markdown", "markdown",
"go", "go",
"svelte", "svelte",
{ "scss", extra_ft = { "css" } }, "scss",
"tsx", "tsx",
"typescript", "typescript",
"yaml", "yaml",
} }
---@type LazyPluginSpec local ts = require("nvim-treesitter")
return { ts.setup({
"nvim-treesitter/nvim-treesitter", install_dir = string.format("%s/nvim-treesitter", vim.fn.stdpath("data"))
lazy = false, })
build = function() ts.install(languages):await(function(err)
local ts = require("nvim-treesitter") if err then
ts.install(languages):await(ts.update) log.error("Error: %s", err)
end, return
dependencies = { end
{
"LiadOz/nvim-dap-repl-highlights", ---@diagnostic disable-next-line: redefined-local
config = true, ts.update():await(function(err)
}, if err then
}, log.error("Error: %s", err)
config = function() return
local ts = require("nvim-treesitter") end
ts.install(languages):await(function()
local filetypes = {} local filetypes = {}
for i, value in ipairs(languages) do for _, lang in ipairs(languages) do
local lang = value for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
if type(value) == "table" then if not vim.list_contains(filetypes, ft) then
lang = value[1] table.insert(filetypes, ft)
for _, ft in ipairs(value.extra_ft) do
vim.treesitter.language.register(lang, ft)
end
filetypes[i] = lang
end
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
if not vim.list_contains(filetypes, ft) then
table.insert(filetypes, ft)
end
end end
end end
end
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes, pattern = filetypes,
callback = function() callback = function()
vim.treesitter.start() vim.treesitter.start()
vim.wo.foldmethod = "expr" vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end, end,
}) })
end) end
end, )
} end)
+31 -43
View File
@@ -1,45 +1,33 @@
---@type LazyPluginSpec require("oil").setup({
return { default_file_explorer = true,
"stevearc/oil.nvim", columns = {
keys = { -- "icon",
{ "permissions",
"<leader>fe", "size",
function() "mtime",
vim.cmd.Oil("--float")
end,
mode = "n",
},
}, },
---@type oil.SetupOpts delete_to_trash = true,
opts = { float = {
default_file_explorer = true, max_width = 80,
columns = { max_height = 20,
-- "icon",
"permissions",
"size",
"mtime",
},
delete_to_trash = true,
float = {
max_width = 80,
max_height = 20,
},
skip_confirm_for_simple_edits = true,
watch_for_changes = false,
keymaps = {
["<Esc>"] = "actions.close",
["q"] = "actions.close",
["<C-s>"] = false,
["<C-h>"] = "actions.parent",
["<C-l>"] = "actions.select",
["<C-r>"] = "actions.refresh",
},
view_options = {
show_hidden = true,
natural_order = false,
},
win_options = {
colorcolumn = "",
},
}, },
} skip_confirm_for_simple_edits = true,
watch_for_changes = false,
keymaps = {
["<Esc>"] = "actions.close",
["q"] = "actions.close",
["<C-s>"] = false,
["<C-h>"] = "actions.parent",
["<C-l>"] = "actions.select",
["<C-r>"] = "actions.refresh",
},
view_options = {
show_hidden = true,
natural_order = false,
},
win_options = {
colorcolumn = "",
},
})
vim.keymap.set("n", "<leader>fe", function() vim.cmd.Oil("--float") end)
+24 -31
View File
@@ -1,33 +1,26 @@
---@type LazyPluginSpec require("onedark").setup({ style = "darker" })
return {
"navarasu/onedark.nvim",
priority = 1000,
config = function()
require("onedark").setup({ style = "darker" })
local c = require("onedark.colors") local c = require("onedark.colors")
local highlights = { local highlights = {
["@string.special.url"] = { fg = "NONE", fmt = "NONE" }, ["@string.special.url"] = { fg = "NONE", fmt = "NONE" },
["@lsp.type.macro.gotmpl"] = { fg = "NONE", fmt = "NONE" }, ["@lsp.type.macro.gotmpl"] = { fg = "NONE", fmt = "NONE" },
Cursor = { fg = c.bg, bg = c.fg, fmt = "NONE" }, Cursor = { fg = c.bg, bg = c.fg, fmt = "NONE" },
FloatTitle = { fg = c.orange, bg = c.bg_d }, FloatTitle = { fg = c.orange, bg = c.bg_d },
NormalFloat = { bg = c.bg_d }, NormalFloat = { bg = c.bg_d },
FloatBorder = { bg = c.bg_d }, FloatBorder = { bg = c.bg_d },
TabLine = { fg = c.grey, bg = c.bg1 }, TabLine = { fg = c.grey, bg = c.bg1 },
TabLineSel = { fg = c.fg, bg = c.bg2 }, TabLineSel = { fg = c.fg, bg = c.bg2 },
TabLineFill = { bg = c.bg1 }, TabLineFill = { bg = c.bg1 },
EndOfBuffer = { fg = "NONE", bg = "NONE" }, EndOfBuffer = { fg = "NONE", bg = "NONE" },
NvimTreeIndentMarker = { fg = c.bg3 }, NvimTreeIndentMarker = { fg = c.bg3 },
TelescopeNormal = { bg = c.bg_d }, TelescopeNormal = { bg = c.bg_d },
TelescopeTitle = { fg = c.orange, bg = c.bg_d }, TelescopeTitle = { fg = c.orange, bg = c.bg_d },
TelescopePromptBorder = { fg = c.grey, bg = c.bg_d }, TelescopePromptBorder = { fg = c.grey, bg = c.bg_d },
TelescopeResultsBorder = { fg = c.grey, bg = c.bg_d }, TelescopeResultsBorder = { fg = c.grey, bg = c.bg_d },
TelescopePreviewBorder = { fg = c.grey, bg = c.bg_d }, TelescopePreviewBorder = { fg = c.grey, bg = c.bg_d },
DiffAdd = { bg = "#1a2f22" }, DiffAdd = { bg = "#1a2f22" },
DiffChange = { bg = "#15304a" }, DiffChange = { bg = "#15304a" },
DiffDelete = { bg = "#311c1e" }, DiffDelete = { bg = "#311c1e" },
}
require("onedark").set_options("highlights", highlights)
require("onedark").load()
end,
} }
require("onedark").set_options("highlights", highlights)
require("onedark").load()
+8 -15
View File
@@ -1,16 +1,9 @@
---@type LazyPluginSpec require("outline").setup({
return { outline_window = {
"hedyhli/outline.nvim", relative_width = false,
lazy = true, split_command = "aboveleft 40vsp",
cmd = { "Outline", "OutlineOpen" }, focus_on_open = false,
keys = { -- Example mapping to toggle outline
{ "<leader>o", "<cmd>Outline<CR>", desc = "Toggle outline" },
}, },
opts = { })
outline_window = {
relative_width = false, vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>")
split_command = "aboveleft 40vsp",
focus_on_open = false,
},
},
}
+168 -181
View File
@@ -1,194 +1,181 @@
-- https://github.com/nvim-telescope/telescope.nvim local telescope = require("telescope")
local builtin = require("telescope.builtin")
local actions = require("telescope.actions")
local utils = require("telescope.utils")
---@type LazyPluginSpec telescope.setup({
return { defaults = {
"nvim-telescope/telescope.nvim", mappings = {
event = "VeryLazy", n = {
dependencies = { q = actions.close,
"nvim-lua/plenary.nvim", ["<C-c>"] = actions.close,
"debugloop/telescope-undo.nvim", ["<C-l>"] = actions.select_default,
"rcarriga/nvim-notify", ["<C-u>"] = actions.results_scrolling_up,
{ ["<C-d>"] = actions.results_scrolling_down,
"nvim-telescope/telescope-fzf-native.nvim", },
build = "make", },
file_ignore_patterns = {
"^%.git/",
},
layout_config = {
height = 30,
width = 80,
scroll_speed = 3,
}, },
}, },
config = function() extensions = {
local telescope = require("telescope") undo = {
local builtin = require("telescope.builtin") mappings = {
local actions = require("telescope.actions") i = {
local utils = require("telescope.utils") ["<cr>"] = require("telescope-undo.actions").yank_deletions,
["<C-cr>"] = false,
telescope.setup({ ["<C-r>"] = false,
defaults = { ["<C-y>"] = require("telescope-undo.actions").yank_additions,
mappings = {
n = {
q = actions.close,
["<C-c>"] = actions.close,
["<C-l>"] = actions.select_default,
["<C-u>"] = actions.results_scrolling_up,
["<C-d>"] = actions.results_scrolling_down,
},
}, },
file_ignore_patterns = { n = {
"^%.git/", ["u"] = false,
},
layout_config = {
height = 30,
width = 80,
scroll_speed = 3,
}, },
}, },
extensions = { },
undo = { },
mappings = { pickers = {
i = { oldfiles = {
["<cr>"] = require("telescope-undo.actions").yank_deletions, initial_mode = "normal",
["<C-cr>"] = false, },
["<C-r>"] = false, buffers = {
["<C-y>"] = require("telescope-undo.actions").yank_additions, initial_mode = "normal",
}, mappings = {
n = { n = {
["u"] = false, ["<C-x>"] = actions.delete_buffer,
},
},
}, },
}, },
pickers = { },
oldfiles = { live_grep = {
initial_mode = "normal", layout_config = {
}, width = 160,
buffers = { preview_width = 80,
initial_mode = "normal",
mappings = {
n = {
["<C-x>"] = actions.delete_buffer,
},
},
},
live_grep = {
layout_config = {
width = 160,
preview_width = 80,
},
},
highlights = {
layout_config = {
width = 160,
preview_width = 80,
},
},
diagnostics = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_definitions = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_type_definitions = {
initial_mode = "normal",
},
lsp_implementations = {
initial_mode = "normal",
},
lsp_references = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
git_status = {
initial_mode = "normal",
},
}, },
}) },
highlights = {
layout_config = {
width = 160,
preview_width = 80,
},
},
diagnostics = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_definitions = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_type_definitions = {
initial_mode = "normal",
},
lsp_implementations = {
initial_mode = "normal",
},
lsp_references = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
git_status = {
initial_mode = "normal",
},
},
})
vim.keymap.set("n", "<leader>ff", function() vim.keymap.set("n", "<leader>ff", function()
builtin.find_files({ builtin.find_files({
hidden = true, hidden = true,
no_ignore = true, no_ignore = true,
no_ignore_parent = true, no_ignore_parent = true,
previewer = false, previewer = false,
}) })
end) end)
vim.keymap.set("n", "<leader>fr", function()
builtin.oldfiles({
only_cwd = true,
hidden = true,
previewer = false,
})
end)
vim.keymap.set("n", "<leader>fg", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
previewer = true,
})
end)
vim.keymap.set("n", "<leader>fG", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
cwd = utils.buffer_dir(),
previewer = true,
})
end)
vim.keymap.set("n", "<leader>fb", function()
builtin.buffers({ previewer = false, sort_mru = true })
end)
vim.keymap.set("n", "<leader>fd", function()
builtin.diagnostics({
bufnr = 0,
})
end)
vim.keymap.set("n", "<leader>dl", builtin.diagnostics) vim.keymap.set("n", "<leader>fr", function()
vim.keymap.set("n", "grt", builtin.lsp_type_definitions) builtin.oldfiles({
vim.keymap.set("n", "gd", builtin.lsp_definitions) only_cwd = true,
vim.keymap.set("n", "gri", builtin.lsp_implementations) hidden = true,
vim.keymap.set("n", "grr", builtin.lsp_references) previewer = false,
})
end)
telescope.load_extension("fzf") vim.keymap.set("n", "<leader>fg", function()
telescope.load_extension("notify") builtin.live_grep({
vim.keymap.set("n", "<leader>fn", function() additional_args = function(_)
telescope.extensions.notify.notify({ return {
initial_mode = "normal", "--hidden",
layout_config = { "--iglob=!.venv",
width = 160, "--iglob=!vendor",
preview_width = 80, "--iglob=!.git",
}, }
}) end,
end) previewer = true,
})
end)
telescope.load_extension("undo") vim.keymap.set("n", "<leader>fG", function()
vim.keymap.set("n", "<leader>fu", function() builtin.live_grep({
telescope.extensions.undo.undo({ additional_args = function(_)
initial_mode = "normal", return {
layout_config = { "--hidden",
width = 160, "--iglob=!.venv",
preview_width = 80, "--iglob=!vendor",
}, "--iglob=!.git",
}) }
end) end,
end, cwd = utils.buffer_dir(),
} previewer = true,
})
end)
vim.keymap.set("n", "<leader>fb", function()
builtin.buffers({ previewer = false, sort_mru = true })
end)
vim.keymap.set("n", "<leader>fd", function()
builtin.diagnostics({
bufnr = 0,
})
end)
vim.keymap.set("n", "<leader>dl", builtin.diagnostics)
vim.keymap.set("n", "grt", builtin.lsp_type_definitions)
vim.keymap.set("n", "gd", builtin.lsp_definitions)
vim.keymap.set("n", "gri", builtin.lsp_implementations)
vim.keymap.set("n", "grr", builtin.lsp_references)
telescope.load_extension("fzf")
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", function()
telescope.extensions.notify.notify({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
telescope.load_extension("undo")
vim.keymap.set("n", "<leader>fu", function()
telescope.extensions.undo.undo({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
+4 -19
View File
@@ -1,20 +1,5 @@
local function undo_tree_tab() vim.cmd.packadd("nvim.undotree")
vim.cmd.tabnew()
vim.cmd.bprevious()
vim.cmd.UndotreeToggle()
vim.cmd.UndotreeFocus()
end
---@type LazyPluginSpec vim.keymap.set("n", "<leader>uu", function()
return { require("undotree").open({ command = "leftabove40vnew" })
"mbbill/undotree", end)
keys = {
{ "<leader>uu", undo_tree_tab, mode = "n" },
},
init = function(_)
vim.g.undotree_WindowLayout = 2
vim.g.undotree_DiffCommand = "diff -u"
vim.g.undotree_SplitWidth = 50
vim.g.undotree_DiffpanelHeight = 20
end,
}
+1
View File
@@ -0,0 +1 @@
vim.keymap.set("n", "<leader>gl", vim.cmd.Flog)
+46
View File
@@ -0,0 +1,46 @@
local function open_git_status()
local previous_win = vim.api.nvim_get_current_win()
vim.cmd("leftabove vertical G")
vim.api.nvim_win_set_width(0, 50)
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
vim.api.nvim_set_current_win(previous_win)
end
local function get_git_status_win()
local current_tabpage = vim.api.nvim_get_current_tabpage()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
local buf = vim.api.nvim_win_get_buf(win)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if
buftype == "nowrite"
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
then
return win
end
end
end
local function toggle_git_status()
local win = get_git_status_win()
if win then
vim.api.nvim_win_close(win, false)
return
end
open_git_status()
end
vim.keymap.set("n", "<leader>gd", vim.cmd.Gvdiffsplit)
vim.keymap.set("n", "<leader>gD", function() vim.cmd.Gvdiffsplit("HEAD") end)
vim.keymap.set("n", "<leader>gh", vim.cmd.Ghdiffsplit)
vim.keymap.set("n", "<leader>gH", function() vim.cmd.Ghdiffsplit("HEAD") end)
vim.keymap.set("n", "<leader>gc", function() vim.cmd.G("commit") end)
vim.keymap.set("n", "<leader>ga", function() vim.cmd.G("commit --amend") end)
vim.keymap.set("n", "<leader>gp", function() vim.cmd.G("push") end)
vim.keymap.set("n", "<leader>gg", toggle_git_status)
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
vim.fn["fugitive#ReloadStatus"]()
end,
})
-78
View File
@@ -4,84 +4,6 @@ local Util = {}
Util.os_name = vim.uv.os_uname().sysname Util.os_name = vim.uv.os_uname().sysname
--- Check that an executable is available
--- @param exe string Array to look for
--- @return boolean
function Util.is_executable(exe)
return vim.fn.executable(exe) == 1
end
--- Check that at least one executable is available
--- @param exes table Array of exes
--- @return boolean
function Util.any_installed(exes)
for _, e in ipairs(exes) do
if Util.is_executable(e) then
return true
end
end
return false
end
--- Asserts that an executable is available
--- Raises error if missing.
--- @param exe string Array to look for
function Util.assert_installed(exe)
assert(Util.is_executable(exe), "Missing executable '" .. exe .. "'.")
end
--- Asserts that at least one executable is available
--- Raises error if missing.
--- @param exes table Array of exes
function Util.assert_any_installed(exes)
assert(
Util.any_installed(exes),
"At least one of the following is required:\n"
.. table.concat(exes, ", ")
)
end
--- Asserts that a python module is installed
---@param mod string The python module to check
function Util.python3_module_is_installed(mod)
if not Util.is_executable("python3") then
return false
end
local resp = vim.system({ "python3", "-c", "import " .. mod }):wait()
return resp.code == 0
end
--- Asserts that a python module is installed
---@param mod string The python module to check
function Util.assert_python3_module_installed(mod)
if not Util.python3_module_is_installed(mod) then
error("Python3 module " .. mod .. " not installed")
end
end
--- Attempts to load a module and logs errors on failure.
---@param module string The module to attempt to load.
---@return any module The loaded module if successful, otherwise nil.
function Util.try_require(module)
local has_module, resp = pcall(require, module)
if has_module then
return resp
end
log.error("Failed to load module %s:\n%s", module, resp)
end
--- Checks if it is possible to require a module
---@param module string
---@return boolean
function Util.has_module(module)
local has_module, _ = pcall(require, module)
return has_module
end
---@alias OutputStream ---@alias OutputStream
---| '"stdout"' ---| '"stdout"'
---| '"stderr"' ---| '"stderr"'
+97
View File
@@ -0,0 +1,97 @@
{
"plugins": {
"Comment.nvim": {
"rev": "e30b7f2008e52442154b66f7c519bfd2f1e32acb",
"src": "https://github.com/numToStr/Comment.nvim"
},
"blink.cmp": {
"rev": "78336bc89ee5365633bcf754d93df01678b5c08f",
"src": "https://github.com/saghen/blink.cmp",
"version": "1.0.0 - 2.0.0"
},
"fidget.nvim": {
"rev": "889e2e96edef4e144965571d46f7a77bcc4d0ddf",
"src": "https://github.com/j-hui/fidget.nvim"
},
"gitsigns.nvim": {
"rev": "0d797daee85366bc242580e352a4f62d67557b84",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"grug-far.nvim": {
"rev": "37d0eafc6a2dcf8641aa19fc2a8db5e391b7f16b",
"src": "https://github.com/MagicDuck/grug-far.nvim"
},
"mason-auto-install.nvim": {
"rev": "fd76cea6bbac98726c0c763deea3c449adf50daf",
"src": "https://github.com/owallb/mason-auto-install.nvim"
},
"mason.nvim": {
"rev": "b03fb0f20bc1d43daf558cda981a2be22e73ac42",
"src": "https://github.com/mason-org/mason.nvim"
},
"nvim-dap": {
"rev": "45a69eba683a2c448dd9ecfc4de89511f0646b5f",
"src": "https://github.com/mfussenegger/nvim-dap"
},
"nvim-dap-repl-highlights": {
"rev": "f31deba47fe3ee6ff8d2f13d9dbd06b2d1ae06b5",
"src": "https://github.com/LiadOz/nvim-dap-repl-highlights"
},
"nvim-dap-view": {
"rev": "e57ac4051aa56293e89991ab93bc148de35321ca",
"src": "https://github.com/igorlfs/nvim-dap-view"
},
"nvim-lspconfig": {
"rev": "bedca8b426b2fee0ccac596d167d71bbe971253f",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-notify": {
"rev": "8701bece920b38ea289b457f902e2ad184131a5d",
"src": "https://github.com/rcarriga/nvim-notify"
},
"nvim-tree.lua": {
"rev": "509962f21ab7289d8dcd28568af539be39a8c01e",
"src": "https://github.com/nvim-tree/nvim-tree.lua"
},
"nvim-treesitter": {
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"oil.nvim": {
"rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e",
"src": "https://github.com/stevearc/oil.nvim"
},
"onedark.nvim": {
"rev": "213c23ae45a04797572242568d5d51937181792d",
"src": "https://github.com/navarasu/onedark.nvim"
},
"outline.nvim": {
"rev": "c293eb56db880a0539bf9d85b4a27816960b863e",
"src": "https://github.com/hedyhli/outline.nvim"
},
"plenary.nvim": {
"rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
"src": "https://github.com/nvim-lua/plenary.nvim"
},
"telescope-fzf-native.nvim": {
"rev": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c",
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
"telescope-undo.nvim": {
"rev": "928d0c2dc9606e01e2cc547196f48d2eaecf58e5",
"src": "https://github.com/debugloop/telescope-undo.nvim"
},
"telescope.nvim": {
"rev": "7ef4d6dccb78ee71e552bbd866176762ad328afa",
"src": "https://github.com/nvim-telescope/telescope.nvim"
},
"vim-flog": {
"rev": "665b16ac8915f746bc43c9572b4581a5e9047216",
"src": "https://github.com/rbong/vim-flog"
},
"vim-fugitive": {
"rev": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0",
"src": "https://github.com/tpope/vim-fugitive"
}
}
}
-3
View File
@@ -1,3 +0,0 @@
((text) @injection.content
(#set! injection.language "html")
(#set! injection.combined))