diff options
| -rw-r--r-- | config/nvim/ftdetect/conf.vim | 2 | ||||
| -rw-r--r-- | config/nvim/lazy-lock.json | 2 | ||||
| -rw-r--r-- | config/nvim/lua/plugins.lua | 1 | ||||
| -rw-r--r-- | config/nvim/lua/plugins/dap.lua | 129 | ||||
| -rw-r--r-- | config/nvim/lua/plugins/minimap.lua | 47 | ||||
| -rw-r--r-- | config/nvim/syntax/conf.vim | 59 |
6 files changed, 219 insertions, 21 deletions
diff --git a/config/nvim/ftdetect/conf.vim b/config/nvim/ftdetect/conf.vim new file mode 100644 index 0000000..cf940f0 --- /dev/null +++ b/config/nvim/ftdetect/conf.vim @@ -0,0 +1,2 @@ +" conf filetype detection +autocmd BufRead,BufNewFile *.conf setfiletype conf diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index 257a01f..78856fd 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -18,11 +18,11 @@ "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, "multicursor.nvim": { "branch": "1.0", "commit": "630dd29dd696bc977cb81d7dd2fa6bb280f60fc4" }, "neogit": { "branch": "master", "commit": "2a47e1df95605b232fbdd5d369ab1bfaaf40fce4" }, + "neominimap.nvim": { "branch": "main", "commit": "6a9d8b0d2f2c0d9d7853b377fa225990cb24837a" }, "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, "nvim-dap": { "branch": "master", "commit": "db321947bb289a2d4d76a32e76e4d2bd6103d7df" }, "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-drawer": { "branch": "main", "commit": "d80832901fc69c56b39f657dd807cbb00098e36f" }, "nvim-lspconfig": { "branch": "master", "commit": "44acfe887d4056f704ccc4f17513ed41c9e2b2e6" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-tree.lua": { "branch": "master", "commit": "e11ce83ed9a00f065bf676ae4e6c261c766989ba" }, 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 = { { "<leader>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 + { "<leader>nm", "<cmd>Neominimap Toggle<cr>", desc = "Toggle global minimap" }, + { "<leader>no", "<cmd>Neominimap Enable<cr>", desc = "Enable global minimap" }, + { "<leader>nc", "<cmd>Neominimap Disable<cr>", desc = "Disable global minimap" }, + { "<leader>nr", "<cmd>Neominimap Refresh<cr>", desc = "Refresh global minimap" }, + + -- Window-Specific Minimap Controls + { "<leader>nwt", "<cmd>Neominimap WinToggle<cr>", desc = "Toggle minimap for current window" }, + { "<leader>nwr", "<cmd>Neominimap WinRefresh<cr>", desc = "Refresh minimap for current window" }, + { "<leader>nwo", "<cmd>Neominimap WinEnable<cr>", desc = "Enable minimap for current window" }, + { "<leader>nwc", "<cmd>Neominimap WinDisable<cr>", desc = "Disable minimap for current window" }, + + -- Tab-Specific Minimap Controls + { "<leader>ntt", "<cmd>Neominimap TabToggle<cr>", desc = "Toggle minimap for current tab" }, + { "<leader>ntr", "<cmd>Neominimap TabRefresh<cr>", desc = "Refresh minimap for current tab" }, + { "<leader>nto", "<cmd>Neominimap TabEnable<cr>", desc = "Enable minimap for current tab" }, + { "<leader>ntc", "<cmd>Neominimap TabDisable<cr>", desc = "Disable minimap for current tab" }, + + -- Buffer-Specific Minimap Controls + { "<leader>nbt", "<cmd>Neominimap BufToggle<cr>", desc = "Toggle minimap for current buffer" }, + { "<leader>nbr", "<cmd>Neominimap BufRefresh<cr>", desc = "Refresh minimap for current buffer" }, + { "<leader>nbo", "<cmd>Neominimap BufEnable<cr>", desc = "Enable minimap for current buffer" }, + { "<leader>nbc", "<cmd>Neominimap BufDisable<cr>", desc = "Disable minimap for current buffer" }, + + ---Focus Controls + { "<leader>nf", "<cmd>Neominimap Focus<cr>", desc = "Focus on minimap" }, + { "<leader>nu", "<cmd>Neominimap Unfocus<cr>", desc = "Unfocus minimap" }, + { "<leader>ns", "<cmd>Neominimap ToggleFocus<cr>", 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, +} diff --git a/config/nvim/syntax/conf.vim b/config/nvim/syntax/conf.vim new file mode 100644 index 0000000..9efb07b --- /dev/null +++ b/config/nvim/syntax/conf.vim @@ -0,0 +1,59 @@ +" Vim syntax file for conf configuration language +" Language: conf +" Maintainer: NeonXP <i@neonxp.ru> +" Latest Revision: 2025-02-23 + +if exists("b:current_syntax") + finish +endif + +syn keyword confBoolean true false +syn keyword confTodo contained TODO FIXME XXX NOTE + +" Comments +syn match confComment "#.*$" contains=confTodo + +" Variables (environment variables starting with $) +syn match confVariable '\$\h\w*' + +" Strings +syn region confString start='"' end='"' skip='\\"' +syn region confString start="'" end="'" skip="\\'" +syn region confMultilineString start='`' end='`' skip='\\`' + +" Numbers +syn match confNumber '\d\+' +syn match confNumber '-\d\+' +syn match confFloat '\d\+\.\d\+' +syn match confFloat '-\d\+\.\d\+' + +" Operators +syn match confOperator "=\ze\s*" +syn match confSemiColon ";" + +" Brackets +syn match confBraces "[{}\[\]]" + +" Directives (words followed by arguments and/or block) +syn match confDirective '^\s*\h\w*\ze\s*[{;]' contained +syn match confDirective '^\s*\h\w*\ze\s*\S' contained + +" Keys (word followed by =) +syn match confKey '^\s*\h\w*\ze\s*=' + +" Define syntax groups +hi def link confComment Comment +hi def link confTodo Todo +hi def link confVariable Identifier +hi def link confString String +hi def link confMultilineString String +hi def link confNumber Number +hi def link confFloat Float +hi def link confBoolean Boolean +hi def link confOperator Operator +hi def link confSemiColon Special +hi def link confBraces Special +hi def link confKey Identifier +hi def link confDirective Function + +let b:current_syntax = "conf" |
