From f89dbf8e7f418dd03f0a19cd62984d4780ae9e3d Mon Sep 17 00:00:00 2001 From: aliaksandrkotau Date: Sat, 23 Dec 2023 12:43:15 +0100 Subject: [PATCH] tmux; dap; dapui; debugging --- dummy_src/learn_nvim.txt | 31 +++++++++ dummy_src/p.py | 19 ++++++ init.lua | 54 ++++++++++++--- lazy-lock.json | 1 + lua/custom/plugins/dap.lua | 9 +++ lua/custom/plugins/dapui.lua | 89 +++++++++++++++++++++++++ lua/custom/plugins/vimtmuxnavigator.lua | 3 + 7 files changed, 198 insertions(+), 8 deletions(-) create mode 100644 dummy_src/learn_nvim.txt create mode 100644 dummy_src/p.py create mode 100644 lua/custom/plugins/dap.lua create mode 100644 lua/custom/plugins/dapui.lua create mode 100644 lua/custom/plugins/vimtmuxnavigator.lua diff --git a/dummy_src/learn_nvim.txt b/dummy_src/learn_nvim.txt new file mode 100644 index 00000000..e088e81b --- /dev/null +++ b/dummy_src/learn_nvim.txt @@ -0,0 +1,31 @@ +# Vim Motions Practice + +hjkl: Move left, down, up, right. Try it now! +w: Move to next word. Move to "word" in this line. +b: Move to previous word. Move to "Move" in this line. +e: Move to end of word. Move to "line" in this line. +0: Move to beginning of line. Do it now! +$: Move to end of line. Do it now! +G: Move to end of file. Do it now! +gg: Move to beginning of file. Do it now! +f{char}: Move to next occurrence of {char}. Move to "c" in this line. +F{char}: Move to previous occurrence of {char}. Move to "M" in this line. +t{char}: Move to before next occurrence of {char}. Move to before "c" in this line. +T{char}: Move to after previous occurrence of {char}. Move to after "M" in this line. +;: Repeat last f, F, t, or T motion. Do it now! +,: Repeat last f, F, t, or T motion in opposite direction. Do it now! +H: Move to top of screen. Do it now! +M: Move to middle of screen. Do it now! +L: Move to bottom of screen. Do it now! +z{char}: Scroll the screen and position the current line. zt: top, zz: middle, zb: bottom. Try them now! +{num}G: Move to line {num}. Move to line 10 now! +:{num}: Move to line {num}. Move to line 20 now! +%: Move to matching parenthesis, bracket, or brace. Move to the opening brace in this line { +^: Move to first non-blank character of the line. Move to the first letter in this line. +g_: Move to last non-blank character of the line. Move to the last letter in this line. +/ {pattern}: Search forward for {pattern}. Search for "line" in this file. +? {pattern}: Search backward for {pattern}. Search for "word" in this file. +n: Repeat last search in same direction. Do it now! +N: Repeat last search in opposite direction. Do it now! +* : Search forward for the word under the cursor. Move to "screen" and search for it. +# : Search backward for the word under the cursor. Move to "file" and search for it. diff --git a/dummy_src/p.py b/dummy_src/p.py new file mode 100644 index 00000000..21ac9ada --- /dev/null +++ b/dummy_src/p.py @@ -0,0 +1,19 @@ +import logging + +def f(x: int) -> str: + a = 100 + logging.debug(a) + b = [200] * 10 + logging.info(a, b) + c = {x: x*x for x in b} + logging.warning(c) + d = f'Values {x=} {a=} {b=} {c=}' + logging.error(d) + logging.exception('FATAL!!!!!!!###!@#') + return d + + +if __name__ == '__main__': + logging.debug('start') + print(f(100500)) + logging.debug('end') diff --git a/init.lua b/init.lua index 414127c5..feef51d1 100644 --- a/init.lua +++ b/init.lua @@ -163,8 +163,7 @@ require('lazy').setup({ }, { - -- Choices: - ----'navarasu/onedark.nvim', + -- Neovim Color Theme _G.THEME_REPO, priority = 1000, config = function() @@ -173,6 +172,7 @@ require('lazy').setup({ }, { + -- TODO: move to plugins -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` @@ -266,7 +266,7 @@ require('lazy').setup({ -- NOTE: You can change these options as you wish! -- Set highlight on search -vim.o.hlsearch = true +vim.o.hlsearch = false -- Make line numbers default vim.wo.number = true @@ -278,7 +278,7 @@ vim.wo.list = true vim.wo.listchars = "tab:»·,trail:·,extends:>,precedes:<,nbsp:." vim.wo.colorcolumn = '120' vim.wo.wrap = false -vim.opt.cmdheight = 3 +vim.opt.cmdheight = 2 vim.opt.ignorecase = true vim.opt.showtabline = 2 @@ -304,8 +304,8 @@ vim.o.smartcase = true vim.wo.signcolumn = 'yes' -- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 200 +vim.o.updatetime = 150 +vim.o.timeoutlen = 100 -- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' @@ -686,6 +686,19 @@ vim.cmd [[ -- \ [ 'In &Project', 'echo "undefined"' ], -- \ ]) --]] +vim.cmd [[ + call quickui#menu#install( + \ '&Debugger', + \ [ + \ ['Start &Debug', ':lua require("dap").continue()'], + \ ['DAP UI: &Toggle', ':lua require("dapui").toggle()'], + \ ['--',''], + \ ['DAP UI: &Setup', ':lua require("dapui").setup()'], + \ ['DAP UI: &Open', ':lua require("dapui").open()'], + \ ['DAP UI: &Close', ':lua require("dapui").close()'], + \ ] + \ ) +]] vim.cmd [[ call quickui#menu#install('&Window', [ \ ['Open &Neotree', ':Neotree'], @@ -719,8 +732,33 @@ vim.cmd [[ \ ], 10000) ]] - - vim.api.nvim_set_keymap('n', 'm', ':call quickui#menu#open()', { noremap = true }) + + +vim.keymap.set('n', '', function() require('dap').continue() end) +vim.keymap.set('n', '', function() require('dap').step_over() end) +vim.keymap.set('n', '', function() require('dap').step_into() end) +vim.keymap.set('n', '', function() require('dap').step_out() end) +vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end) +vim.keymap.set('n', 'B', function() require('dap').set_breakpoint() end) +vim.keymap.set('n', 'lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) +vim.keymap.set('n', 'dr', function() require('dap').repl.open() end) +vim.keymap.set('n', 'dl', function() require('dap').run_last() end) +vim.keymap.set({'n', 'v'}, 'dh', function() + require('dap.ui.widgets').hover() +end) +vim.keymap.set({'n', 'v'}, 'dp', function() + require('dap.ui.widgets').preview() +end) +vim.keymap.set('n', 'df', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.frames) +end) +vim.keymap.set('n', 'ds', function() + local widgets = require('dap.ui.widgets') + widgets.centered_float(widgets.scopes) +end) + + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json index c8879425..52e9be29 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -33,5 +33,6 @@ "vim-quickui": { "branch": "master", "commit": "4c6ff1250f5d0d62a8b2f373d2dcb667e1fdc5ee" }, "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/lua/custom/plugins/dap.lua b/lua/custom/plugins/dap.lua new file mode 100644 index 00000000..9cfaee2e --- /dev/null +++ b/lua/custom/plugins/dap.lua @@ -0,0 +1,9 @@ +return { + 'mfussenegger/nvim-dap-python', + dependencies = { + 'mfussenegger/nvim-dap', + }, + config = function () + require('dap-python').setup('~/.venvs_python/debugpy/bin/python') + end +} diff --git a/lua/custom/plugins/dapui.lua b/lua/custom/plugins/dapui.lua new file mode 100644 index 00000000..86c5cf2c --- /dev/null +++ b/lua/custom/plugins/dapui.lua @@ -0,0 +1,89 @@ +return { + 'rcarriga/nvim-dap-ui', + dependencies = { + 'mfussenegger/nvim-dap', + }, + config = function() + require("dapui").setup({ + controls = { + element = "repl", + enabled = true, + icons = { + disconnect = "", + pause = "", + play = "", + run_last = "", + step_back = "", + step_into = "", + step_out = "", + step_over = "", + terminate = "" + } + }, + element_mappings = {}, + expand_lines = true, + floating = { + border = "single", + mappings = { + close = { "q", "" } + } + }, + force_buffers = true, + icons = { + collapsed = "", + current_frame = "", + expanded = "" + }, + layouts = { + { + elements = { + { + id = "console", + size = 0.5 + }, + }, + position = "bottom", + size = 10 + }, + { + elements = { + { + id = "repl", + size = 0.2 + }, + { + id = "scopes", + size = 0.2 + }, + { + id = "breakpoints", + size = 0.2 + }, + { + id = "stacks", + size = 0.2 + }, + { + id = "watches", + size = 0.2 + }, + }, + position = "right", + size = 40 + }, + }, + mappings = { + edit = "e", + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + repl = "r", + toggle = "t" + }, + render = { + indent = 1, + max_value_lines = 100 + } + }) + end +} diff --git a/lua/custom/plugins/vimtmuxnavigator.lua b/lua/custom/plugins/vimtmuxnavigator.lua new file mode 100644 index 00000000..cae77de0 --- /dev/null +++ b/lua/custom/plugins/vimtmuxnavigator.lua @@ -0,0 +1,3 @@ +return { + 'christoomey/vim-tmux-navigator' +}