diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 42e2bef..83f5c55 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -18,23 +18,67 @@ dap.adapters.coreclr = { args = {"--interpreter=vscode"} } -dap.configurations.cs = { +vim.g.dotnet_build_project = function() + local default_path = vim.fn.getcwd() .. "/" + if vim.g["dotnet_last_proj_path"] ~= nil then + default_path = vim.g["dotnet_last_proj_path"] + end + local cmd = "dotnet build -c Debug > /dev/null" + print("") + print("Cmd to execute: " .. cmd) + local f = os.execute(cmd) + if f == 0 then + print("\nBuild: ✔️ ") + else + print("\nBuild: ❌ (code: " .. f .. ")") + end +end + +vim.g.dotnet_get_dll_path = function() + local cwd = vim.fn.getcwd() + local solution = vim.fn.glob(cwd .. "/*.csproj") + local projectName = vim.fn.fnamemodify(solution, ":t:r") + local dll = cwd .. "/bin/Debug/net6.0/" .. projectName .. ".dll" + return dll +end + +local config = { { type = "coreclr", name = "launch - netcoredbg", request = "launch", program = function() - local cwd = vim.fn.getcwd() - local solution = vim.fn.glob(cwd .. "/*.csproj") - local projectName = vim.fn.fnamemodify(solution, ":t:r") - local proj = cwd .. "/bin/Debug/net6.0/" .. projectName .. ".dll" - print(proj) - return proj - -- return vim.fn.input("Path to dll", vim.fn.getcwd() .. "/bin/Debug/", "file") + if vim.fn.confirm("Should I recompile first?", "&yes\n&no", 2) == 1 then + vim.g.dotnet_build_project() + end + return vim.g.dotnet_get_dll_path() end } } +dap.configurations.cs = config + -- keybindings -vim.api.nvim_set_keymap("n", "db", ":lua require'dap'.toggle_breakpoint()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap("n", "dc", ":lua require'dap'.continue()", {noremap = true, silent = true}) +local api = vim.api +local keymap_restore = {} +dap.listeners.after["event_initialized"]["me"] = function() + for _, buf in pairs(api.nvim_list_bufs()) do + local keymaps = api.nvim_buf_get_keymap(buf, "n") + for _, keymap in pairs(keymaps) do + if keymap.lhs == "K" then + table.insert(keymap_restore, keymap) + api.nvim_buf_del_keymap(buf, "n", "K") + end + end + end + api.nvim_set_keymap("n", "K", 'lua require("dap.ui.widgets").hover()', {silent = true}) +end + +dap.listeners.after["event_terminated"]["me"] = function() + for _, keymap in pairs(keymap_restore) do + api.nvim_buf_set_keymap(keymap.buffer, keymap.mode, keymap.lhs, keymap.rhs, {silent = keymap.silent == 1}) + end + keymap_restore = {} +end +api.nvim_set_keymap("n", "B", ":lua require'dap'.toggle_breakpoint()", {noremap = true, silent = true}) +api.nvim_set_keymap("n", "", ":lua require'dap'.continue()", {noremap = true, silent = true}) diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index 4003e41..ba3c923 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -95,51 +95,35 @@ require("neo-tree").setup( mappings = { [""] = { "toggle_node", - nowait = false -- disable `nowait` if you have existing combos starting with this char that you want to use + nowait = false }, - -- ["<2-LeftMouse>"] = "open", - -- [""] = "open", [""] = "revert_preview", ["P"] = {"toggle_preview", config = {use_float = true}}, - -- ["s"] = "open_split", - -- ["v"] = "open_vsplit", ["s"] = "split_with_window_picker", ["v"] = "vsplit_with_window_picker", ["t"] = "open_tabnew", - -- [""] = "open_drop", - -- ["t"] = "open_tab_drop", [""] = "open_with_window_picker", ["<2-LeftMouse>"] = "open_with_window_picker", - --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing ["C"] = "close_node", ["z"] = "close_all_nodes", - --["Z"] = "expand_all_nodes", ["a"] = { "add", - -- some commands may take optional config options, see `:h neo-tree-mappings` for details config = { - show_path = "absolute" -- "none", "relative", "absolute" + show_path = "absolute" } }, - ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". ["d"] = "delete", ["r"] = "rename", ["y"] = "copy_to_clipboard", ["x"] = "cut_to_clipboard", ["p"] = "paste_from_clipboard", - ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": - -- ["c"] = { - -- "copy", - -- config = { - -- show_path = "none" -- "none", "relative", "absolute" - -- } - --} + ["c"] = "copy", ["m"] = { "move", config = { show_path = "absoulte" } - }, -- takes text input for destination, also accepts the optional config.show_path option like "add". + }, ["q"] = "close_window", ["R"] = "refresh", ["?"] = "show_help",