feat: switch from lazy to vim.pack
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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",
|
||||||
}
|
"https://github.com/owallb/mason-auto-install.nvim",
|
||||||
|
"https://github.com/mfussenegger/nvim-dap",
|
||||||
require("lazy").setup("plugins", opts)
|
"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",
|
||||||
|
})
|
||||||
|
|||||||
@@ -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" }
|
|
||||||
}
|
|
||||||
@@ -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)
|
|
||||||
@@ -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
@@ -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
|
||||||
+2
-10
@@ -1,11 +1,4 @@
|
|||||||
---@type LazyPluginSpec
|
require("blink.cmp").setup({
|
||||||
return {
|
|
||||||
"saghen/blink.cmp",
|
|
||||||
-- use a release tag to download pre-built binaries
|
|
||||||
version = "1.*",
|
|
||||||
---@module 'blink.cmp'
|
|
||||||
---@type blink.cmp.Config
|
|
||||||
opts = {
|
|
||||||
completion = {
|
completion = {
|
||||||
documentation = {
|
documentation = {
|
||||||
auto_show = true,
|
auto_show = true,
|
||||||
@@ -92,5 +85,4 @@ return {
|
|||||||
["<C-n>"] = { "snippet_forward", "fallback" },
|
["<C-n>"] = { "snippet_forward", "fallback" },
|
||||||
["<C-p>"] = { "snippet_backward", "fallback" },
|
["<C-p>"] = { "snippet_backward", "fallback" },
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
-- https://github.com/numToStr/Comment.nvim
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
require("Comment").setup({
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"numToStr/Comment.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
opts = {
|
|
||||||
--ignore empty lines
|
--ignore empty lines
|
||||||
ignore = "^$",
|
ignore = "^$",
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -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,
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
-- https://github.com/lewis6991/gitsigns.nvim
|
require("gitsigns").setup({
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"lewis6991/gitsigns.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
opts = {
|
|
||||||
preview_config = {
|
preview_config = {
|
||||||
border = "single",
|
border = "single",
|
||||||
},
|
},
|
||||||
@@ -61,5 +55,4 @@ return {
|
|||||||
end,
|
end,
|
||||||
attach_to_untracked = true,
|
attach_to_untracked = true,
|
||||||
sign_priority = 100,
|
sign_priority = 100,
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
---@type LazyPluginSpec
|
require("grug-far").setup()
|
||||||
return {
|
|
||||||
"MagicDuck/grug-far.nvim",
|
|
||||||
config = true,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
config = require("lsp").setup,
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,4 @@
|
|||||||
---@type LazyPluginSpec
|
require("mason-auto-install").setup({
|
||||||
return {
|
|
||||||
"owallb/mason-auto-install.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
},
|
|
||||||
---@type MasonAutoInstall.Config
|
|
||||||
opts = {
|
|
||||||
packages = {
|
packages = {
|
||||||
{
|
{
|
||||||
"bash-language-server",
|
"bash-language-server",
|
||||||
@@ -56,5 +49,4 @@ return {
|
|||||||
"tsgo",
|
"tsgo",
|
||||||
"zls",
|
"zls",
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1 @@
|
|||||||
-- https://github.com/williamboman/mason.nvim
|
require("mason").setup()
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"williamboman/mason.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
config = true,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,
|
|
||||||
}
|
|
||||||
@@ -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",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
local dap_view = require("dap-view")
|
||||||
|
dap_view.setup()
|
||||||
|
vim.keymap.set("n", "<Leader>du", dap_view.toggle)
|
||||||
+13
-78
@@ -1,80 +1,4 @@
|
|||||||
-- https://github.com/mfussenegger/nvim-dap
|
|
||||||
local hover = require("dap.hover")
|
|
||||||
local log = require("log")
|
local log = require("log")
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"mfussenegger/nvim-dap",
|
|
||||||
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")
|
local dap = require("dap")
|
||||||
|
|
||||||
vim.api.nvim_set_hl(0, "DebugPC", {
|
vim.api.nvim_set_hl(0, "DebugPC", {
|
||||||
@@ -213,5 +137,16 @@ return {
|
|||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
|
||||||
}
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
require("lsp").setup()
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
vim.notify = require("notify")
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
vim.notify.setup({
|
||||||
|
render = "default",
|
||||||
|
stages = "static",
|
||||||
|
})
|
||||||
@@ -34,32 +34,10 @@ 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
|
---@class nvim_tree.api.decorator.UserDecorator
|
||||||
local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
|
local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
|
||||||
|
|
||||||
@@ -270,5 +248,3 @@ return {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,39 +22,31 @@ local languages = {
|
|||||||
"markdown",
|
"markdown",
|
||||||
"go",
|
"go",
|
||||||
"svelte",
|
"svelte",
|
||||||
{ "scss", extra_ft = { "css" } },
|
"scss",
|
||||||
"tsx",
|
"tsx",
|
||||||
"typescript",
|
"typescript",
|
||||||
"yaml",
|
"yaml",
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
lazy = false,
|
|
||||||
build = function()
|
|
||||||
local ts = require("nvim-treesitter")
|
local ts = require("nvim-treesitter")
|
||||||
ts.install(languages):await(ts.update)
|
ts.setup({
|
||||||
end,
|
install_dir = string.format("%s/nvim-treesitter", vim.fn.stdpath("data"))
|
||||||
dependencies = {
|
})
|
||||||
{
|
ts.install(languages):await(function(err)
|
||||||
"LiadOz/nvim-dap-repl-highlights",
|
if err then
|
||||||
config = true,
|
log.error("Error: %s", err)
|
||||||
},
|
return
|
||||||
},
|
end
|
||||||
config = function()
|
|
||||||
local ts = require("nvim-treesitter")
|
---@diagnostic disable-next-line: redefined-local
|
||||||
ts.install(languages):await(function()
|
ts.update():await(function(err)
|
||||||
|
if err then
|
||||||
|
log.error("Error: %s", err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local filetypes = {}
|
local filetypes = {}
|
||||||
for i, value in ipairs(languages) do
|
for _, lang in ipairs(languages) do
|
||||||
local lang = value
|
|
||||||
if type(value) == "table" then
|
|
||||||
lang = value[1]
|
|
||||||
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
|
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
|
||||||
if not vim.list_contains(filetypes, ft) then
|
if not vim.list_contains(filetypes, ft) then
|
||||||
table.insert(filetypes, ft)
|
table.insert(filetypes, ft)
|
||||||
@@ -71,6 +62,6 @@ return {
|
|||||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-16
@@ -1,17 +1,4 @@
|
|||||||
---@type LazyPluginSpec
|
require("oil").setup({
|
||||||
return {
|
|
||||||
"stevearc/oil.nvim",
|
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"<leader>fe",
|
|
||||||
function()
|
|
||||||
vim.cmd.Oil("--float")
|
|
||||||
end,
|
|
||||||
mode = "n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
---@type oil.SetupOpts
|
|
||||||
opts = {
|
|
||||||
default_file_explorer = true,
|
default_file_explorer = true,
|
||||||
columns = {
|
columns = {
|
||||||
-- "icon",
|
-- "icon",
|
||||||
@@ -41,5 +28,6 @@ return {
|
|||||||
win_options = {
|
win_options = {
|
||||||
colorcolumn = "",
|
colorcolumn = "",
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
vim.keymap.set("n", "<leader>fe", function() vim.cmd.Oil("--float") end)
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"navarasu/onedark.nvim",
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
require("onedark").setup({ style = "darker" })
|
require("onedark").setup({ style = "darker" })
|
||||||
|
|
||||||
local c = require("onedark.colors")
|
local c = require("onedark.colors")
|
||||||
@@ -29,5 +24,3 @@ return {
|
|||||||
}
|
}
|
||||||
require("onedark").set_options("highlights", highlights)
|
require("onedark").set_options("highlights", highlights)
|
||||||
require("onedark").load()
|
require("onedark").load()
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-11
@@ -1,16 +1,9 @@
|
|||||||
---@type LazyPluginSpec
|
require("outline").setup({
|
||||||
return {
|
|
||||||
"hedyhli/outline.nvim",
|
|
||||||
lazy = true,
|
|
||||||
cmd = { "Outline", "OutlineOpen" },
|
|
||||||
keys = { -- Example mapping to toggle outline
|
|
||||||
{ "<leader>o", "<cmd>Outline<CR>", desc = "Toggle outline" },
|
|
||||||
},
|
|
||||||
opts = {
|
|
||||||
outline_window = {
|
outline_window = {
|
||||||
relative_width = false,
|
relative_width = false,
|
||||||
split_command = "aboveleft 40vsp",
|
split_command = "aboveleft 40vsp",
|
||||||
focus_on_open = false,
|
focus_on_open = false,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>")
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
-- https://github.com/nvim-telescope/telescope.nvim
|
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
|
||||||
return {
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
"debugloop/telescope-undo.nvim",
|
|
||||||
"rcarriga/nvim-notify",
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope-fzf-native.nvim",
|
|
||||||
build = "make",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local telescope = require("telescope")
|
local telescope = require("telescope")
|
||||||
local builtin = require("telescope.builtin")
|
local builtin = require("telescope.builtin")
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
@@ -119,6 +103,7 @@ return {
|
|||||||
previewer = false,
|
previewer = false,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fr", function()
|
vim.keymap.set("n", "<leader>fr", function()
|
||||||
builtin.oldfiles({
|
builtin.oldfiles({
|
||||||
only_cwd = true,
|
only_cwd = true,
|
||||||
@@ -126,6 +111,7 @@ return {
|
|||||||
previewer = false,
|
previewer = false,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fg", function()
|
vim.keymap.set("n", "<leader>fg", function()
|
||||||
builtin.live_grep({
|
builtin.live_grep({
|
||||||
additional_args = function(_)
|
additional_args = function(_)
|
||||||
@@ -139,6 +125,7 @@ return {
|
|||||||
previewer = true,
|
previewer = true,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fG", function()
|
vim.keymap.set("n", "<leader>fG", function()
|
||||||
builtin.live_grep({
|
builtin.live_grep({
|
||||||
additional_args = function(_)
|
additional_args = function(_)
|
||||||
@@ -153,9 +140,11 @@ return {
|
|||||||
previewer = true,
|
previewer = true,
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fb", function()
|
vim.keymap.set("n", "<leader>fb", function()
|
||||||
builtin.buffers({ previewer = false, sort_mru = true })
|
builtin.buffers({ previewer = false, sort_mru = true })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fd", function()
|
vim.keymap.set("n", "<leader>fd", function()
|
||||||
builtin.diagnostics({
|
builtin.diagnostics({
|
||||||
bufnr = 0,
|
bufnr = 0,
|
||||||
@@ -190,5 +179,3 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
vim.keymap.set("n", "<leader>gl", vim.cmd.Flog)
|
||||||
@@ -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,
|
||||||
|
})
|
||||||
@@ -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"'
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
((text) @injection.content
|
|
||||||
(#set! injection.language "html")
|
|
||||||
(#set! injection.combined))
|
|
||||||
Reference in New Issue
Block a user