From a05fdf786fc4f0fc7195feb77faa59227b9330ef Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Tue, 24 Feb 2026 12:59:04 +0300 Subject: Added minimap nvim, dap configs, conf syntax(WIP) --- config/nvim/lua/plugins.lua | 1 + config/nvim/lua/plugins/dap.lua | 129 ++++++++++++++++++++++++++++++------ config/nvim/lua/plugins/minimap.lua | 47 +++++++++++++ 3 files changed, 157 insertions(+), 20 deletions(-) create mode 100644 config/nvim/lua/plugins/minimap.lua (limited to 'config/nvim/lua') diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index fe3360c..2118756 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -25,6 +25,7 @@ require("lazy").setup({ require("plugins.zk"), require("plugins.wrapping"), require("plugins.folding"), + require("plugins.minimap"), }, { performance = { rtp = { diff --git a/config/nvim/lua/plugins/dap.lua b/config/nvim/lua/plugins/dap.lua index 7340da6..6a17265 100644 --- a/config/nvim/lua/plugins/dap.lua +++ b/config/nvim/lua/plugins/dap.lua @@ -11,26 +11,115 @@ return { args = { "dap", "-l", "127.0.0.1:${port}" }, }, } - -- Стандартные конфигурации для Go - dap.configurations.go = { - { - type = "go", - name = "Debug cur file", - request = "launch", - program = "${file}", - cwd = "${workspaceFolder}", - envFile = "${workspaceFolder}/.env", - buildFlags = "", - outputMode = "remote", - }, - { + + -- Хранение истории аргументов для каждой точки входа + local _args_history = {} + + -- Функция для запроса аргументов у пользователя с историей (возвращает строку для парсинга) + local function get_args(entry_point) + local cache_key = entry_point + local default = _args_history[cache_key] or "" + local prompt = "Arguments for " .. entry_point .. ": " + local input = vim.fn.input(prompt, default) + if input and #input > 0 then + _args_history[cache_key] = input + end + return _args_history[cache_key] + end + + -- Генерация конфигураций для Go на основе точек входа + local function generate_go_configs() + local workspace_folder = vim.fn.getcwd() + + -- Проверка существования .env файла в корне проекта + local env_file = nil + if vim.fn.filereadable(workspace_folder .. "/.env") == 1 then + env_file = "${workspaceFolder}/.env" + end + + local configs = {} + local entry_points = {} + + -- Поиск точки входа: main.go в корне или cmd/*/main.go + if vim.fn.filereadable(workspace_folder .. "/main.go") == 1 then + table.insert(entry_points, { + name = "main", + path = "${workspaceFolder}", + }) + end + + -- Поиск cmd/*/main.go + local cmd_dirs = vim.fn.glob(workspace_folder .. "/cmd/*", 0, 1) + for _, cmd_dir in ipairs(cmd_dirs) do + local main_path = cmd_dir .. "/main.go" + if vim.fn.filereadable(main_path) == 1 then + local entry_name = vim.fn.fnamemodify(cmd_dir, ":t") + table.insert(entry_points, { + name = entry_name, + path = cmd_dir, + }) + end + end + + -- Генерация конфигураций для каждой точки входа + for _, entry in ipairs(entry_points) do + -- Базовая конфигурация без аргументов + table.insert(configs, { + type = "go", + name = "Debug " .. entry.name, + request = "launch", + program = entry.path, + cwd = "${workspaceFolder}", + envFile = env_file, + buildFlags = "", + outputMode = "remote", + }) + + -- Конфигурация с аргументами (функция для запроса при запуске) + table.insert(configs, { + type = "go", + name = "Debug " .. entry.name .. " (args)", + request = "launch", + program = entry.path, + cwd = "${workspaceFolder}", + envFile = env_file, + buildFlags = "", + outputMode = "remote", + args = function() + local args_str = get_args(entry.name) + -- Разбиваем строку аргументов на массив + local args = {} + for arg in args_str:gmatch("%S+") do + table.insert(args, arg) + end + return args + end, + }) + end + + -- Remote attach конфигурация для подключения к уже запущенному delve + table.insert(configs, { type = "go", - name = "Debug test", - request = "launch", - mode = "test", - program = "${file}", - }, - } + name = "Remote attach (127.0.0.1:43000)", + request = "attach", + mode = "remote", + port = "43000", + host = "127.0.0.1", + }) + + return configs + end + + -- Установка конфигураций Go + dap.configurations.go = generate_go_configs() + + -- Автообновление конфигураций при открытии Go файла + vim.api.nvim_create_autocmd("BufReadPost", { + pattern = "*.go", + callback = function() + dap.configurations.go = generate_go_configs() + end, + }) end, keys = { { @@ -175,7 +264,7 @@ return { "leoluz/nvim-dap-go", dependencies = { "mfussenegger/nvim-dap" }, ft = "go", - config = true, + -- Не используем автоconfig - конфигурации управляются в nvim-dap keys = { { "dt", diff --git a/config/nvim/lua/plugins/minimap.lua b/config/nvim/lua/plugins/minimap.lua new file mode 100644 index 0000000..6d9efdc --- /dev/null +++ b/config/nvim/lua/plugins/minimap.lua @@ -0,0 +1,47 @@ +return { + "Isrothy/neominimap.nvim", + version = "v3.x.x", + lazy = false, -- NOTE: NO NEED to Lazy load + -- Optional. You can also set your own keybindings + keys = { + -- Global Minimap Controls + { "nm", "Neominimap Toggle", desc = "Toggle global minimap" }, + { "no", "Neominimap Enable", desc = "Enable global minimap" }, + { "nc", "Neominimap Disable", desc = "Disable global minimap" }, + { "nr", "Neominimap Refresh", desc = "Refresh global minimap" }, + + -- Window-Specific Minimap Controls + { "nwt", "Neominimap WinToggle", desc = "Toggle minimap for current window" }, + { "nwr", "Neominimap WinRefresh", desc = "Refresh minimap for current window" }, + { "nwo", "Neominimap WinEnable", desc = "Enable minimap for current window" }, + { "nwc", "Neominimap WinDisable", desc = "Disable minimap for current window" }, + + -- Tab-Specific Minimap Controls + { "ntt", "Neominimap TabToggle", desc = "Toggle minimap for current tab" }, + { "ntr", "Neominimap TabRefresh", desc = "Refresh minimap for current tab" }, + { "nto", "Neominimap TabEnable", desc = "Enable minimap for current tab" }, + { "ntc", "Neominimap TabDisable", desc = "Disable minimap for current tab" }, + + -- Buffer-Specific Minimap Controls + { "nbt", "Neominimap BufToggle", desc = "Toggle minimap for current buffer" }, + { "nbr", "Neominimap BufRefresh", desc = "Refresh minimap for current buffer" }, + { "nbo", "Neominimap BufEnable", desc = "Enable minimap for current buffer" }, + { "nbc", "Neominimap BufDisable", desc = "Disable minimap for current buffer" }, + + ---Focus Controls + { "nf", "Neominimap Focus", desc = "Focus on minimap" }, + { "nu", "Neominimap Unfocus", desc = "Unfocus minimap" }, + { "ns", "Neominimap ToggleFocus", desc = "Switch focus on minimap" }, + }, + init = function() + -- The following options are recommended when layout == "float" + vim.opt.wrap = false + vim.opt.sidescrolloff = 36 -- Set a large value + + --- Put your configuration here + ---@type Neominimap.UserConfig + vim.g.neominimap = { + auto_enable = true, + } + end, +} -- cgit v1.2.3