From dfc2ef548f87334ef0dd11148d3583ebe08578cd Mon Sep 17 00:00:00 2001 From: flin16 Date: Mon, 26 May 2025 21:01:40 -0500 Subject: [PATCH] add auto change line --- lazy-lock.json | 14 ++-- lazyvim.json | 1 + lua/config/keymaps.lua | 143 +++++++++++++++------------------------- lua/config/options.lua | 1 + lua/plugins/example.lua | 49 +++++++++++++- 5 files changed, 111 insertions(+), 97 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 47e7b3a..6c597d5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,10 @@ { "CopilotChat.nvim": { "branch": "main", "commit": "16d897fd43d07e3b54478ccdb2f8a16e4df4f45a" }, "LazyVim": { "branch": "main", "commit": "25abbf546d564dc484cf903804661ba12de45507" }, - "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "catppuccin": { "branch": "main", "commit": "be1e5e6308bb9d016bf5c1565e0f1d5e46400d7a" }, + "catppuccin": { "branch": "main", "commit": "56a9dfd1e05868cf3189369aad87242941396563" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, - "copilot.lua": { "branch": "master", "commit": "a620a5a97b73faba009a8160bab2885316e1451c" }, "copilot.vim": { "branch": "release", "commit": "d1e8429bef7f7709586886b0a23a46fbecc685c4" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, @@ -17,6 +15,7 @@ "lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, "mini.ai": { "branch": "main", "commit": "b91997d220086e92edc1fec5ce82094dcc234291" }, "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, @@ -26,14 +25,16 @@ "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, + "nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" }, "nvim-dap": { "branch": "master", "commit": "b0f983507e3702f073bfe1516846e58b56d4e42f" }, "nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "b47cbb249351873e3a571751c3fb66ed6369852f" }, - "nvim-lspconfig": { "branch": "master", "commit": "3ea99227e316c5028f57a4d86a1a7fd01dd876d0" }, + "nvim-lspconfig": { "branch": "master", "commit": "d45702594afc661a9dfa95e96acf18c56006d4d9" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-context": { "branch": "master", "commit": "404502e607c3b309e405be9112c438c721153372" }, + "nvim-treesitter-context": { "branch": "master", "commit": "153a076598076bf5664ab868fb01d3418ecffce9" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "0f051e9813a36481f48ca1f833897210dbcfffde" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" }, @@ -43,6 +44,7 @@ "render-markdown.nvim": { "branch": "main", "commit": "df64d5d5432e13026a79384ec4e2bab185fd4eb5" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "texlab": { "branch": "master", "commit": "86d5a3c9ad0c20855fe8441834d36d8e3f92e6d7" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, diff --git a/lazyvim.json b/lazyvim.json index 9bda2ca..8fdfb06 100644 --- a/lazyvim.json +++ b/lazyvim.json @@ -2,6 +2,7 @@ "extras": [ "lazyvim.plugins.extras.coding.mini-surround", "lazyvim.plugins.extras.coding.yanky", + "lazyvim.plugins.extras.dap.core", "lazyvim.plugins.extras.editor.refactoring", "lazyvim.plugins.extras.lang.markdown", "lazyvim.plugins.extras.lang.python", diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 03fb796..677f1bf 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -16,22 +16,38 @@ end vim.keymap.set("v", "x", '"_x', { noremap = true, desc = "Delete selection with Backspace" }) map_all_mode("", function() require("dap").continue() -end, { desc = "DAP: Continue" }) +end, { desc = "Dap: Continue" }) map_all_mode("", function() require("dap").run_last() -end, { desc = "DAP: Use last config" }) +end, { desc = "Dap: Use last config" }) map_all_mode("", function() require("dap").step_over() -end, { desc = "DAP: Step Over" }) +end, { desc = "Dap: Step Over" }) map_all_mode("", function() require("dap").step_into() -end, { desc = "DAP: Step Into" }) +end, { desc = "Dap: Step Into" }) map_all_mode("", function() require("dap").step_out() -end, { desc = "DAP: Step Out" }) +end, { desc = "Dap: Step Out" }) vim.keymap.set("n", "\\b", function() require("dap").toggle_breakpoint() -end, { desc = "DAP: Toggle Breakpoint" }) +end, { desc = "Dap: Toggle Breakpoint" }) +vim.keymap.set("n", "\\dr", function() + require("dap").repl.open() +end, { desc = "Dap: Open REPL" }) +vim.keymap.set({ "n", "v" }, "\\dh", function() + require("dap.ui.widgets").hover() +end, { desc = "Print variable (Hover Mode)" }) +vim.keymap.set({ "n", "v" }, "\\dp", function() + require("dap.ui.widgets").preview() +end, { desc = "Print variable (Preview Mode)" }) +-- TODO: remove this +-- vim.keymap.set("n", "\\dt", function() +-- require("dapui").toggle() +-- end, { desc = "Toggle debug GUI" }) +-- vim.keymap.set({ "n", "v" }, "\\de", function() +-- require("dapui").eval() +-- end, { desc = "Eval variable" }) -- Now configure shortcuts for MacOS -- if vim.g.neovide then @@ -52,90 +68,37 @@ vim.keymap.set("v", "", '"+y', { desc = "Copy to clipboard in visual mode" vim.keymap.set("v", "", '"+d', { desc = "Cut to clipboard" }) map_nv("", "ggG", { desc = "Select all" }) -- end -local function get_environments_from_lsp_symbols(symbols) - local blocks = {} - local lsp_symbol_kind = vim.lsp.protocol.SymbolKind -- Access the SymbolKind enum - local function traverse(nodes) - for _, symbol in ipairs(nodes) do - -- We check for 'Struct' which texlab uses for most \begin{}...\end{} blocks. - -- You could add other kinds here if your LSP server uses them. - if symbol.kind == lsp_symbol_kind.Struct then - table.insert(blocks, { - -- lnum is 0-indexed from LSP, so we add 1 for vim - lnum = symbol.range.start.line + 1, - -- 'text' is the name of the environment (e.g., "figure", "itemize") - text = "\\begin{" .. symbol.name .. "}", - }) - end - -- Recursively search in child symbols - if symbol.children and #symbol.children > 0 then - traverse(symbol.children) - end - end - end - - traverse(symbols) - return blocks -end -- Set the keymap fg to trigger the picker -vim.keymap.set("n", "fg", function() - local Snacks = require("snacks") - return Snacks.picker({ - finder = "lsp_symbols", -- Use the LSP symbols as the source - layout = { - layout = { - box = "horizontal", - width = 0.5, - height = 0.5, - { - box = "vertical", - border = "rounded", - title = "Find directory", - { win = "input", height = 1, border = "bottom" }, - { win = "list", border = "none" }, - }, - }, - }, - format = 'lsp_symbol', - confirm = function(picker, item) - picker:close() - Snacks.picker.pick("files", { - dirs = { item.file }, - }) - end, - filter = { - tex = true, - } - }) -end -, { desc = "Find LaTeX environments using LSP" }) -- Updated description -local function get_symbols() - -- 1. 检查texlab是否已附加到当前缓冲区 - local clients = vim.lsp.get_clients({ bufnr = 0 }) - local texlab_found = false - local bufnr = vim.api.nvim_get_current_buf() - for _, client in ipairs(clients) do - if client.name == "texlab" then - texlab_found = true - client.request("textDocument/documentSymbol", { - textDocument = vim.lsp.util.make_text_document_params(bufnr), - }, function(err, result, ctx, config) - if err then - print("Error:", vim.inspect(err)) - return - end - print("texlab symbols:", vim.inspect(result)) - end, bufnr) - break - end - end - - if not texlab_found then - vim.notify("Texlab LSP 未附加到当前缓冲区。", vim.log.levels.WARN) - return - end - - vim.notify("正在向 texlab 请求文档结构...", vim.log.levels.INFO) -end +-- vim.keymap.set("n", "fg", function() +-- local Snacks = require("snacks") +-- return Snacks.picker({ +-- finder = "lsp_symbols", -- Use the LSP symbols as the source +-- layout = { +-- layout = { +-- box = "horizontal", +-- width = 0.5, +-- height = 0.5, +-- { +-- box = "vertical", +-- border = "rounded", +-- title = "Find directory", +-- { win = "input", height = 1, border = "bottom" }, +-- { win = "list", border = "none" }, +-- }, +-- }, +-- }, +-- format = 'lsp_symbol', +-- confirm = function(picker, item) +-- picker:close() +-- Snacks.picker.pick("files", { +-- dirs = { item.file }, +-- }) +-- end, +-- filter = { +-- tex = true, +-- } +-- }) +-- end +-- , { desc = "Find LaTeX environments using LSP" }) -- Updated description diff --git a/lua/config/options.lua b/lua/config/options.lua index e26569f..cc90da1 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -3,6 +3,7 @@ -- Add any additional options here vim.o.clipboard = "" vim.o.guifont = "Monaco:h16" +vim.cmd('set wrap') local dap = require("dap") dap.adapters.python = { diff --git a/lua/plugins/example.lua b/lua/plugins/example.lua index a96108b..25604a2 100644 --- a/lua/plugins/example.lua +++ b/lua/plugins/example.lua @@ -20,6 +20,17 @@ return { vim.cmd.colorscheme("molokai") end, }, + { + "folke/which-key.nvim", + --TODO: Try to use this without warning + -- opts = function(_, opts) + -- -- 添加 '\' 开头的提示组 + -- opts.defaults["\\"] = { + -- name = "\\", -- 或你喜欢的名字,比如 '+custom' + -- d = { name = "+debug" }, -- 这样会提示 \d 有 "debug" 的子命令 + -- } + -- end, + }, { "lervag/vimtex", lazy = false, -- we don't want to lazy load VimTeX @@ -138,7 +149,43 @@ return { }, { "latex-lsp/texlab", - } + }, + { + "rcarriga/nvim-dap-ui", + dependencies = { "nvim-neotest/nvim-nio" }, + keys = { + { + "du", + function() + require("dapui").toggle {} + end, + desc = "Dap UI", + }, + { + "de", + function() + require("dapui").eval() + end, + desc = "Eval", + mode = { "n", "v" }, + }, + }, + opts = {}, + config = function(_, opts) + local dap = require "dap" + local dapui = require "dapui" + dapui.setup(opts) + dap.listeners.after.event_initialized["dapui_config"] = function() + dap.repl.open() + end + -- dap.listeners.before.event_terminated["dapui_config"] = function() + -- dapui.close {} + -- end + -- dap.listeners.before.event_exited["dapui_config"] = function() + -- dapui.close {} + -- end + end, + }, } -- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim --