From 02a32cd80527bcfbe8befcc4a87861e05462c070 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Mar 2023 21:18:47 +0200 Subject: Add plugin dap --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index ec29d65..8941a05 100644 --- a/init.lua +++ b/init.lua @@ -60,6 +60,7 @@ local modules = { "plugins.nvim-tree", "plugins.quickfix", "plugins.cmp", + "plugins.dap", "plugins.luasnip", "plugins.colorizer", "plugins.prettier", -- cgit v1.2.3 From 3999f9e6639eba12708689b6bb58353da198210a Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Mar 2023 21:19:25 +0200 Subject: Add plugin dap mappings --- lua/user/keys.lua | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 689ff13..77edfa8 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -331,6 +331,45 @@ map("n", "q", function() end end, { desc = "Toggle quickfix window" }) +-- Dap (debugging) +local dap_ok, dap = pcall(require, "dap") +local dap_ui_ok, ui = pcall(require, "dapui") + +if not (dap_ok and dap_ui_ok) then + require("notify")("nvim-dap or dap-ui not installed!", "warning") -- nvim-notify is a separate plugin, I recommend it too! + return +end + +vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) + +-- Start debugging session +vim.keymap.set("n", "ds", function() + dap.continue() + ui.toggle({}) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly +end) + +-- Set breakpoints, get variable values, step into/out of functions, etc. +map("n", "dl", require("dap.ui.widgets").hover) +map("n", "dc", dap.continue) +map("n", "db", dap.toggle_breakpoint) +map("n", "dn", dap.step_over) +map("n", "di", dap.step_into) +map("n", "do", dap.step_out) +map("n", "dC", function() + dap.clear_breakpoints() + require("notify")("Breakpoints cleared", "warn") +end) + +-- Close debugger and clear breakpoints +map("n", "de", function() + dap.clear_breakpoints() + ui.toggle({}) + dap.terminate() + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) + require("notify")("Debugger session ended", "warn") +end) + -- Dashboard map("n", "db", "Dashboard") -- cgit v1.2.3 From 54530be3e279b609f4dd023c25a4dd5f0d480869 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Mar 2023 21:20:00 +0200 Subject: Add plugin dap config --- lua/plugins/dap.lua | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 lua/plugins/dap.lua diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..4ba4c46 --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,177 @@ +--local status, dap = pcall(require,"dap") +--if (not status) then return end +--local status2, dapui = pcall(require,"dapui") +--if (not status2) then return end +--local status3, daptext = pcall(require,"nvim-dap-virtual-text") +--if (not status3) then return end +-- +--dapui.setup() +--daptext.setup({}) +-- +--vim.fn.sign_define('DapBreakpoint', {text='🔴'}) +--vim.fn.sign_define('DapStopped', {text='🟢'}) +-- +--dap.listeners.after.event_initialized["dapui_config"] = function () +-- dapui.open() +--end +--dap.listeners.before.event_terminated["dapui_config"] = function () +-- dapui.close() +--end +--dap.listeners.before.event_exited["dapui_config"] = function () +-- dapui.close() +--end +-- +---- --- Adapters --- -- +-- +---- CPP Setup +--dap.adapters.cppdbg = { +-- id = 'cppdbg', +-- type = 'executable', +-- command = os.getenv("USERPROFILE") .. '\\dap_adapters\\cpptools\\extension\\debugAdapters\\bin\\OpenDebugAD7.exe', +-- options = { +-- detached = false +-- } +--} +-- +--dap.adapters.codelldb = { +-- type = 'server', +-- port = "${port}", +-- executable = { +-- -- CHANGE THIS to your path! +-- command = os.getenv("USERPROFILE") .. "\\dap_adapters\\codelldb\\extension\\adapter\\codelldb", +-- args = {"--port", "${port}"}, +-- +-- -- On windows you may have to uncomment this: +-- detached = false, +-- } +--} +-- +---- --- configurations --- -- +-- +---- CPP Setup +--dap.configurations.cpp = { +-- { +-- name = "DBG Debug", +-- type = "cppdbg", +-- request = "launch", +-- program = function() +-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +-- end, +-- cwd = '${workspaceFolder}', +-- stopAtEntry = true +-- }, +-- { +-- name = "LLDB Debug", +-- type = "codelldb", +-- request = "launch", +-- program = function() +-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +-- end, +-- cwd = '${workspaceFolder}', +-- stopOnEntry = false +-- } +--} +-- +--dap.configurations.c = dap.configurations.cpp +--dap DAP setup commands. +-- +-- +--Trevor Gray +--Covert this to lua (local dap (require :dap)) +--(local dapui (require :dapui)) +--(dapui.setup) +-- +--(vim.api.nvim_set_hl 0 :DapBreakpoint {:ctermbg 0 :fg "#993939" :bg "#31353f"}) +-- +--(vim.api.nvim_set_hl 0 :DapBreakpointLine {:bg "#251215"}) +-- +--(vim.api.nvim_set_hl 0 :DapLogPoint {:ctermbg 0 :fg "#61afef" :bg "#31353f"}) +-- +--(vim.api.nvim_set_hl 0 :DapLogPointLine {:bg "#252849"}) +-- +--(vim.api.nvim_set_hl 0 :DapStopped {:ctermbg 0 :fg "#98c379" :bg "#31353f"}) +--(vim.api.nvim_set_hl 0 :DapStoppedLine {:bg "#15171B"}) +-- +--(vim.fn.sign_define :DapBreakpoint +-- {:text "" +-- :texthl :DapBreakpoint +-- :linehl :DapBreakpointLine +-- :numhl :DapBreakpoint}) +-- +--(vim.fn.sign_define :DapBreakpointCondition +-- {:text "ﳁ" +-- :texthl :DapBreakpoint +-- :linehl :DapBreakpointLine +-- :numhl :DapBreakpoint}) +-- +--(vim.fn.sign_define :DapBreakpointRejected +-- {:text "" +-- :texthl :DapBreakpoint +-- :linehl :DapBreakpointLine +-- :numhl :DapBreakpoint}) +-- +--(vim.fn.sign_define :DapLogPoint +-- {:text "" +-- :texthl :DapLogPoint +-- :linehl :DapLogPointLine +-- :numhl :DapLogPoint}) +-- +--(vim.fn.sign_define :DapStopped +-- {:text "" +-- :texthl :DapStopped +-- :linehl :DapStoppedLine +-- :numhl :DapStopped}) +-- +--(tset dap.listeners.after.event_initialized :dapui_config dapui.open) +-- +--(tset dap.listeners.before.event_terminated :dapui_config dapui.close) +-- +--(tset dap.listeners.before.event_exited :dapui_config dapui.close) +-- +--(set dap.adapters.lldb {:type :executable +-- :attach {:pidProperty :pid :pidSelect :ask} +-- :command :lldb-vscode +-- :env {:LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY :YES} +-- :name :lldb}) +-- +local dap = require("dap") +local dapui = require("dapui") +dapui.setup() + +vim.api.nvim_set_hl(0, "DapBreakpoint", {ctermbg = 0, fg = "#993939", bg = "#31353f"}) +vim.api.nvim_set_hl(0, "DapBreakpointLine", {bg = "#251215"}) +vim.api.nvim_set_hl(0, "DapLogPoint", {ctermbg = 0, fg = "#61afef", bg = "#31353f"}) +vim.api.nvim_set_hl(0, "DapLogPointLine", {bg = "#252849"}) +vim.api.nvim_set_hl(0, "DapStopped", {ctermbg = 0, fg = "#98c379", bg = "#31353f"}) +vim.api.nvim_set_hl(0, "DapStoppedLine", {bg = "#15171B"}) + +vim.fn.sign_define("DapBreakpoint", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +vim.fn.sign_define("DapBreakpointCondition", {text = "ﳁ", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +vim.fn.sign_define("DapBreakpointRejected", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +vim.fn.sign_define("DapLogPoint", {text = "", texthl = "DapLogPoint", linehl = "DapLogPointLine", numhl = "DapLogPoint"}) +vim.fn.sign_define("DapStopped", {text = "", texthl = "DapStopped", linehl = "DapStoppedLine", numhl = "DapStopped"}) + +dap.listeners.after.event_initialized["dapui_config"] = function() +dapui.open() +end + +dap.listeners.before.event_terminated["dapui_config"] = function() +dapui.close() +end + +dap.listeners.before.event_exited["dapui_config"] = function() +dapui.close() +end + +dap.adapters.lldb = ({ + type = "executable", + attach = { + pidProperty = "pid", + pidSelect = "ask", + }, + command = "lldb-vscode", + env = { + LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES", + }, + name = "lldb" +}).configurations.rust == dap.configurations.cpp -- cgit v1.2.3 From 20945124174b1bac17caf5042410d99046e75966 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Mar 2023 21:41:41 +0200 Subject: Fixed wrong config --- lua/plugins/dap.lua | 140 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 106 insertions(+), 34 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 4ba4c46..2fb4333 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -134,44 +134,116 @@ -- :env {:LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY :YES} -- :name :lldb}) -- -local dap = require("dap") -local dapui = require("dapui") -dapui.setup() - -vim.api.nvim_set_hl(0, "DapBreakpoint", {ctermbg = 0, fg = "#993939", bg = "#31353f"}) -vim.api.nvim_set_hl(0, "DapBreakpointLine", {bg = "#251215"}) -vim.api.nvim_set_hl(0, "DapLogPoint", {ctermbg = 0, fg = "#61afef", bg = "#31353f"}) -vim.api.nvim_set_hl(0, "DapLogPointLine", {bg = "#252849"}) -vim.api.nvim_set_hl(0, "DapStopped", {ctermbg = 0, fg = "#98c379", bg = "#31353f"}) -vim.api.nvim_set_hl(0, "DapStoppedLine", {bg = "#15171B"}) - -vim.fn.sign_define("DapBreakpoint", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) -vim.fn.sign_define("DapBreakpointCondition", {text = "ﳁ", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) -vim.fn.sign_define("DapBreakpointRejected", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) -vim.fn.sign_define("DapLogPoint", {text = "", texthl = "DapLogPoint", linehl = "DapLogPointLine", numhl = "DapLogPoint"}) -vim.fn.sign_define("DapStopped", {text = "", texthl = "DapStopped", linehl = "DapStoppedLine", numhl = "DapStopped"}) - -dap.listeners.after.event_initialized["dapui_config"] = function() -dapui.open() +--local dap = require("dap") +--local dapui = require("dapui") +--dapui.setup() +-- +--vim.api.nvim_set_hl(0, "DapBreakpoint", {ctermbg = 0, fg = "#993939", bg = "#31353f"}) +--vim.api.nvim_set_hl(0, "DapBreakpointLine", {bg = "#251215"}) +--vim.api.nvim_set_hl(0, "DapLogPoint", {ctermbg = 0, fg = "#61afef", bg = "#31353f"}) +--vim.api.nvim_set_hl(0, "DapLogPointLine", {bg = "#252849"}) +--vim.api.nvim_set_hl(0, "DapStopped", {ctermbg = 0, fg = "#98c379", bg = "#31353f"}) +--vim.api.nvim_set_hl(0, "DapStoppedLine", {bg = "#15171B"}) +-- +--vim.fn.sign_define("DapBreakpoint", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +--vim.fn.sign_define("DapBreakpointCondition", {text = "ﳁ", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +--vim.fn.sign_define("DapBreakpointRejected", {text = "", texthl = "DapBreakpoint", linehl = "DapBreakpointLine", numhl = "DapBreakpoint"}) +--vim.fn.sign_define("DapLogPoint", {text = "", texthl = "DapLogPoint", linehl = "DapLogPointLine", numhl = "DapLogPoint"}) +--vim.fn.sign_define("DapStopped", {text = "", texthl = "DapStopped", linehl = "DapStoppedLine", numhl = "DapStopped"}) +-- +--dap.listeners.after.event_initialized["dapui_config"] = function() +--dapui.open() +--end +-- +--dap.listeners.before.event_terminated["dapui_config"] = function() +--dapui.close() +--end +-- +--dap.listeners.before.event_exited["dapui_config"] = function() +--dapui.close() +--end +-- +--dap.adapters.lldb = ({ +-- type = "executable", +-- attach = { +-- pidProperty = "pid", +-- pidSelect = "ask", +-- }, +-- command = "lldb-vscode", +-- env = { +-- LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES", +-- }, +-- name = "lldb" +--}).configurations.rust == dap.configurations.cpp +local dap_ok, dap = pcall(require, "dap") +if not (dap_ok) then + print("nvim-dap not installed!") + return end -dap.listeners.before.event_terminated["dapui_config"] = function() -dapui.close() -end +require('dap').set_log_level('INFO') -- Helps when configuring DAP, see logs with :DapShowLog -dap.listeners.before.event_exited["dapui_config"] = function() -dapui.close() +dap.configurations = { + go = { + { + type = "go", -- Which adapter to use + name = "Debug", -- Human readable name + request = "launch", -- Whether to "launch" or "attach" to program + program = "${file}", -- The buffer you are focused on when running nvim-dap + }, + } +} +dap.adapters.go = { + type = "server", + port = "${port}", + executable = { + command = vim.fn.stdpath("data") .. '/mason/bin/dlv', + args = { "dap", "-l", "127.0.0.1:${port}" }, + }, +} +local dap_ui_ok, ui = pcall(require, "dapui") +if not (dap_ok and dap_ui_ok) then + require("notify")("dap-ui not installed!", "warning") + return end -dap.adapters.lldb = ({ - type = "executable", - attach = { - pidProperty = "pid", - pidSelect = "ask", +ui.setup({ + icons = { expanded = "▾", collapsed = "▸" }, + mappings = { + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + expand_lines = vim.fn.has("nvim-0.7"), + layouts = { + { + elements = { + "scopes", + }, + size = 0.3, + position = "right" + }, + { + elements = { + "repl", + "breakpoints" + }, + size = 0.3, + position = "bottom", + }, + }, + floating = { + max_height = nil, + max_width = nil, + border = "single", + mappings = { + close = { "q", "" }, + }, }, - command = "lldb-vscode", - env = { - LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES", + windows = { indent = 1 }, + render = { + max_type_length = nil, }, - name = "lldb" -}).configurations.rust == dap.configurations.cpp +}) -- cgit v1.2.3 From 34c00419478f6f4cf08f2ab09d041f8e2eec4384 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Mar 2023 11:06:51 +0200 Subject: Add ToggleDiff function --- autoload/utils.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoload/utils.vim b/autoload/utils.vim index 1f10423..b4356ba 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -99,4 +99,20 @@ function! OpenLastClosed() endfunction +"------------------------------------------------- + +" Toggle Diff +let g:diff_is_open = 0 + +function! utils#ToggleDiff() + if g:diff_is_open + windo diffoff + let g:diff_is_open = 0 + else + windo diffthis + let g:diff_is_open = 1 + endif +endfunction + + "------------------------------------------------- -- cgit v1.2.3 From 23a2932e5a0ec8cbee9ff09206a309de1972b4aa Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Mar 2023 11:09:43 +0200 Subject: Changed vim.keymap.set to map --- lua/user/keys.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 77edfa8..cd63dfc 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -336,14 +336,14 @@ local dap_ok, dap = pcall(require, "dap") local dap_ui_ok, ui = pcall(require, "dapui") if not (dap_ok and dap_ui_ok) then - require("notify")("nvim-dap or dap-ui not installed!", "warning") -- nvim-notify is a separate plugin, I recommend it too! + require("notify")("nvim-dap or dap-ui not installed!", "warning") return end vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) -- Start debugging session -vim.keymap.set("n", "ds", function() +map("n", "ds", function() dap.continue() ui.toggle({}) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly -- cgit v1.2.3 From 0de3d43eb78b5c54e78aa86cafe4e93ae806ad7f Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Mar 2023 15:47:33 +0200 Subject: Removed "dinhhuy258/git.nvim" because of conflicting keybindings --- lua/user/pack.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 0bcb006..249796b 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -111,7 +111,7 @@ return packer.startup(function(use) -- Git use("tpope/vim-fugitive") -- - use("dinhhuy258/git.nvim") -- For git blame & browse + --use("dinhhuy258/git.nvim") -- For git blame & browse use("kdheepak/lazygit.nvim") -- Terminal UI for git commands use("lewis6991/gitsigns.nvim") -- Git decorations -- cgit v1.2.3 From 5a781bf79564a086367dec77385ca658c6b72b3d Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Mar 2023 15:47:53 +0200 Subject: Add function M.find_projects() --- lua/plugins/telescope.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 95a5dd6..605cdc3 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -312,6 +312,20 @@ function M.find_scripts() } end +function M.find_projects() + require("telescope.builtin").find_files { + hidden = true, + no_ignore = true, + prompt_title = " Find Projects", + path_display = { "smart" }, + search_dirs = { + "~/src", + }, + layout_strategy = "horizontal", + layout_config = { preview_width = 0.65, width = 0.75 }, + } +end + function M.grep_notes() local opts = {} opts.hidden = false -- cgit v1.2.3 From 1578ead916cb0ff26a47d18dbcb80bb576f65c01 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Mar 2023 15:48:30 +0200 Subject: Add keybinding for telescope.find_projects() --- lua/user/keys.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index cd63dfc..fe9e3af 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -287,9 +287,10 @@ map("n", "fk", "lua require('telescope.builtin').keymaps()") map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find notes +map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts +map("n", "fw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find media files +map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find notifications -- FZF map("n", "fz", "lua require('fzf-lua').files()") -- cgit v1.2.3 From 7bf0bc4fab41f035c544e5e8c705804bdbf51094 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Mar 2023 15:51:56 +0200 Subject: Removed plugins.git --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 8941a05..85fde42 100644 --- a/init.lua +++ b/init.lua @@ -64,7 +64,7 @@ local modules = { "plugins.luasnip", "plugins.colorizer", "plugins.prettier", - "plugins.git", + --"plugins.git", "plugins.gitsigns", "plugins.neoscroll", "plugins.null-ls", -- cgit v1.2.3