diff --git a/init.vim b/init.vim index a372cda..f0122ea 100644 --- a/init.vim +++ b/init.vim @@ -40,6 +40,7 @@ source ~/.config/nvim/plugin-confs/nvim-colorizer.lua source ~/.config/nvim/plugin-confs/nvim-dap-python.lua source ~/.config/nvim/plugin-confs/nvim-dap-bash.lua source ~/.config/nvim/plugin-confs/nvim-dap-ui.lua +source ~/.config/nvim/plugin-confs/nvim-dap-virtual-text.lua " source ~/.config/nvim/plugin-confs/copilot.lua " source ~/.config/nvim/plugin-confs/lsp-signature.lua " source ~/.config/nvim/plugin-confs/nvim-docs-view.lua diff --git a/keybindings.vim b/keybindings.vim index 7602e52..61cfe75 100644 --- a/keybindings.vim +++ b/keybindings.vim @@ -1,8 +1,7 @@ -nmap zz + nmap zz nmap n nzzzv nmap N Nzzzv -nmap x !chmod +x % xnoremap p "_dP @@ -49,8 +48,6 @@ nnoremap Q !!$SHELL nnoremap rn :lua vim.lsp.buf.rename() -nnoremap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 -nnoremap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 nnoremap bb :Telescope buffers nnoremap bk :bdelete @@ -59,7 +56,9 @@ nnoremap bp :bprev nnoremap ca :lua vim.lsp.buf.code_action() nnoremap cd :Telescope diagnostics -nnoremap cDt :lua require("dapui").toggle() +nnoremap cDn :lua vim.diagnostic.goto_next() +nnoremap cDp :lua vim.diagnostic.goto_prev() +nnoremap cl :lua vim.diagnostic.setloclist() nnoremap cp :vert Copilot panel nnoremap Ci :lua require('chatgpt').edit_with_instructions() nnoremap Cd :ChatGPTRun docstring @@ -76,11 +75,37 @@ xnoremap Cs :ChatGPTRun summarize xnoremap Cf :ChatGPTRun fix_bugs xnoremap Ce :ChatGPTRun explain +nnoremap db :lua require("dap").toggle_breakpoint() +nnoremap dc :lua require("dap").continue() +nnoremap di :lua require("dap").step_into() +nnoremap do :lua require("dap").step_over() +nnoremap dO :lua require("dap").step_out() +nnoremap dr :lua require("dap").repl.open() +nnoremap dl :lua require("dap").run_last() +nnoremap dh :lua require("dap.ui.widgets").hover() +nnoremap dp :lua require("dap.ui.widgets").preview() +nnoremap df :lua require('dap.ui.widgets').centered_float(require('dap.ui.widgets').frames) +nnoremap ds :lua require('dap.ui.widgets').centered_float(require('dap.ui.widgets').scopes) +nnoremap dut :lua require("dapui").toggle() +nnoremap duo :lua require("dapui").open() +nnoremap duc :lua require("dapui").close() +nnoremap dPm :lua require("dap-python").test_method() +nnoremap dPc :lua require("dap-python").test_class() +nnoremap dPs :lua require("dap-python").debug_selection() + +vnoremap dh :lua require("dap.ui.widgets").hover() +vnoremap dp :lua require("dap.ui.widgets").preview() +vnoremap dpe :lua require("dapui").eval() + +nnoremap :lua require('dap').step_over() +nnoremap :lua require('dap').step_into() +nnoremap :lua require('dap').step_out() + nnoremap fb :Telescope file_browser nnoremap ff :Telescope find_files nnoremap fg :Telescope live_grep nnoremap fh :Telescope oldfiles -nnoremap fd :e ~/.config/nvim/init.vim +" nnoremap fd :e ~/.config/nvim/init.vim nnoremap gb :Gitsigns blame_line nnoremap gc :Telescope git_commits @@ -93,7 +118,12 @@ nnoremap gpd lua require('goto-preview').goto_preview_definition() nnoremap gpi lua require('goto-preview').goto_preview_implementation() nnoremap hc :Telescope commands -nnoremap hv :Telescope help_tags +nnoremap hdc :Telescope dap commands +nnoremap hdC :Telescope dap configurations +nnoremap hdb :Telescope dap list_breakpoints +nnoremap hdv :Telescope dap variables +nnoremap hdf :Telescope dap frames +nnoremap hv :Telescope vim_options nnoremap hk :Telescope keymaps nnoremap hs :Telescope spell_suggest @@ -104,6 +134,7 @@ nnoremap j :AnyJump nnoremap K :lua vim.lsp.buf.hover() nnoremap ld :Telescope lsp_definitions +nnoremap lD :Telescope diagnostics nnoremap la :lua vim.lsp.buf.code_action() nnoremap lci :Telescope lsp_incoming_calls nnoremap lco :Telescope lsp_outgoing_calls @@ -116,10 +147,13 @@ nnoremap lt :Telescope lsp_type_definitions nnoremap lw :Telescope lsp_dynamic_workspace_symbols nnoremap n :NvimTreeToggle +" nnoremap r :NvimTreeRefresh + nnoremap ob :Telescope file_browser nnoremap oc :ChatGPT -nnoremap oB :FloatermNew --title=bpytop --opener=vsplit bpytop +nnoremap oC :e ~/.config/nvim/init.vim +nnoremap oB :FloatermNew --title=btop --opener=vsplit btop nnoremap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker nnoremap of :wa:FloatermToggle floatterm nnoremap oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45 @@ -129,13 +163,10 @@ nnoremap oP :FloatermNew --title=ipython-full --name=ipython-full --open nnoremap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" nnoremap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 -nnoremap r :NvimTreeRefresh - -nnoremap sl :SessionLoad -nnoremap ss :SessionSave nnoremap sc :nohls nnoremap sC :Telescope commands nnoremap sf :Telescope find_files +nnoremap sg :Telescope glyph nnoremap sh :Telescope command_history nnoremap sm :Telescope man_pages nnoremap s/ :Telescope search_history @@ -150,5 +181,7 @@ nnoremap wa :lua vim.lsp.buf.add_workspace_folder() nnoremap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) nnoremap wr :lua vim.lsp.buf.remove_workspace_folder() +nmap x !chmod +x % + nnoremap y "+ vmap y "+ diff --git a/lua/plugins.lua b/lua/plugins.lua index 83aed55..2580eaf 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -109,10 +109,9 @@ require('packer').startup(function(use) } use { 'junegunn/fzf', run = function() vim.fn['fzf#install']() end } - + use 'junegunn/fzf.vim' use 'norcalli/nvim-colorizer.lua' use 'jiangmiao/auto-pairs' - use 'junegunn/fzf.vim' use 'pechorin/any-jump.vim' use 'tpope/vim-commentary' use 'tpope/vim-surround' @@ -128,6 +127,13 @@ require('packer').startup(function(use) use { 'lewis6991/gitsigns.nvim' } use { 'nvim-telescope/telescope.nvim' } use { 'nvim-telescope/telescope-file-browser.nvim' } + use 'nvim-telescope/telescope-dap.nvim' + use { 'ghassan0/telescope-glyph.nvim' } + use { + 'nvim-telescope/telescope-fzf-native.nvim', + run = + 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' + } use { 'ojroques/nvim-lspfuzzy' } @@ -174,7 +180,8 @@ require('packer').startup(function(use) use 'folke/neodev.nvim' use 'mfussenegger/nvim-dap' use { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } } - + use 'mfussenegger/nvim-dap-python' + use 'theHamsta/nvim-dap-virtual-text' use { 'Mofiqul/dracula.nvim' } use({ 'NTBBloodbath/doom-one.nvim', @@ -199,7 +206,7 @@ require('packer').startup(function(use) -- Plugins integration vim.g.doom_one_plugin_neorg = true vim.g.doom_one_plugin_barbar = false - vim.g.doom_one_plugin_telescope = false + vim.g.doom_one_plugin_telescope = true vim.g.doom_one_plugin_neogit = true vim.g.doom_one_plugin_nvim_tree = true vim.g.doom_one_plugin_dashboard = true diff --git a/plugin-confs/lspconfig.lua b/plugin-confs/lspconfig.lua index c2c2b2c..3999f36 100644 --- a/plugin-confs/lspconfig.lua +++ b/plugin-confs/lspconfig.lua @@ -1,13 +1,12 @@ -local opts = { noremap = true, silent = true } -vim.api.nvim_set_keymap('n', 'e', - 'lua vim.diagnostic.open_float()', opts) -vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', - opts) -vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', - opts) -vim.api.nvim_set_keymap('n', 'q', - 'lua vim.diagnostic.setloclist()', opts) - +-- local opts = { noremap = true, silent = true } +-- vim.api.nvim_set_keymap('n', 'e', +-- 'lua vim.diagnostic.open_float()', opts) +-- vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', +-- opts) +-- vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', +-- opts) +-- vim.api.nvim_set_keymap('n', 'q', +-- 'lua vim.diagnostic.setloclist()', opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) diff --git a/plugin-confs/nvim-dap-python.lua b/plugin-confs/nvim-dap-python.lua index 6600a04..9085c73 100644 --- a/plugin-confs/nvim-dap-python.lua +++ b/plugin-confs/nvim-dap-python.lua @@ -1,48 +1,51 @@ -local dap = require('dap') -dap.adapters.python = function(cb, config) - if config.request == 'attach' then - ---@diagnostic disable-next-line: undefined-field - local port = (config.connect or config).port - ---@diagnostic disable-next-line: undefined-field - local host = (config.connect or config).host or '127.0.0.1' - cb({ - type = 'server', - port = assert(port, - '`connect.port` is required for a python `attach` configuration'), - host = host, - options = { source_filetype = 'python' } - }) - else - cb({ - type = 'executable', - command = '/home/sudacode/Projects/Python/debugpy/env/bin/python', - args = { '-m', 'debugpy.adapter' }, - options = { source_filetype = 'python' } - }) - end -end -dap.configurations.python = { - { - -- The first three options are required by nvim-dap - type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python` - request = 'launch', - name = "Launch file", +local dp = require('dap-python') +dp.test_runner = 'pytest' - -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options +-- local dap = require('dap') +-- dap.adapters.python = function(cb, config) +-- if config.request == 'attach' then +-- ---@diagnostic disable-next-line: undefined-field +-- local port = (config.connect or config).port +-- ---@diagnostic disable-next-line: undefined-field +-- local host = (config.connect or config).host or '127.0.0.1' +-- cb({ +-- type = 'server', +-- port = assert(port, +-- '`connect.port` is required for a python `attach` configuration'), +-- host = host, +-- options = { source_filetype = 'python' } +-- }) +-- else +-- cb({ +-- type = 'executable', +-- command = '/home/sudacode/Projects/Python/debugpy/env/bin/python', +-- args = { '-m', 'debugpy.adapter' }, +-- options = { source_filetype = 'python' } +-- }) +-- end +-- end +-- dap.configurations.python = { +-- { +-- -- The first three options are required by nvim-dap +-- type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python` +-- request = 'launch', +-- name = "Launch file", - program = "${file}", -- This configuration will launch the current file if used. - pythonPath = function() - -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. - -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. - -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. '/env/bin/python') == 1 then - return cwd .. '/env/bin/python' - elseif vim.fn.executable(cwd .. '/.env/bin/python') == 1 then - return cwd .. '/.env/bin/python' - else - return '/usr/bin/python' - end - end - } -} +-- -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + +-- program = "${file}", -- This configuration will launch the current file if used. +-- pythonPath = function() +-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. +-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. +-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. +-- local cwd = vim.fn.getcwd() +-- if vim.fn.executable(cwd .. '/env/bin/python') == 1 then +-- return cwd .. '/env/bin/python' +-- elseif vim.fn.executable(cwd .. '/.env/bin/python') == 1 then +-- return cwd .. '/.env/bin/python' +-- else +-- return '/usr/bin/python' +-- end +-- end +-- } +-- } diff --git a/plugin-confs/nvim-dap-virtual-text.lua b/plugin-confs/nvim-dap-virtual-text.lua new file mode 100644 index 0000000..20b3015 --- /dev/null +++ b/plugin-confs/nvim-dap-virtual-text.lua @@ -0,0 +1,34 @@ +local opts = { + enabled = true, -- enable this plugin (the default) + enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + show_stop_reason = true, -- show stop reason when stopped for exceptions + commented = false, -- prefix virtual text with comment string + only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + all_references = false, -- show virtual text on all all references of the variable (not only definitions) + clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping) + --- A callback that determines how a variable is displayed or whether it should be omitted + --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable + --- @param buf number + --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame + --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`) + --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text + --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed + display_callback = function(variable, buf, stackframe, node, options) + if options.virt_text_pos == 'inline' then + return ' = ' .. variable.value + else + return variable.name .. ' = ' .. variable.value + end + end, + -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line + virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol', + + -- experimental features: + all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. + virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) + virt_text_win_col = 80 -- position the virtual text at a fixed window column (starting from the first text column) , + -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` +} +require("nvim-dap-virtual-text").setup(opts) diff --git a/plugin-confs/telescope.lua b/plugin-confs/telescope.lua index 89ff7ee..cce00a2 100644 --- a/plugin-confs/telescope.lua +++ b/plugin-confs/telescope.lua @@ -1,44 +1,65 @@ -require('telescope').setup{ - defaults = { - -- Default configuration for telescope goes here: - -- config_key = value, - layout_strategy = 'flex', - width = 0.9, - wrap_results = true, - preview = { - border = true, - borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, - title = true, - dynamic_preview_title = true, - treesitter = true, +local ts = require('telescope') +ts.setup({ + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + layout_strategy = 'flex', + width = 0.9, + wrap_results = true, + preview = { + border = true, + borderchars = { + '─', '│', '─', '│', '╭', '╮', '╯', '╰' + }, + title = true, + dynamic_preview_title = true, + treesitter = true + }, + mappings = { + i = { + -- map actions.which_key to (default: ) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + -- [""] = "which_key" + } + }, + file_ignore_patterns = { "^node_modules/", "^env/", "^__pycache__/" } }, - mappings = { - i = { - -- map actions.which_key to (default: ) - -- actions.which_key shows the mappings for your picker, - -- e.g. git_{create, delete, ...}_branch for the git_branches picker - [""] = "which_key" - } + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + find_files = { + -- theme = "dropdown" + } }, - file_ignore_patterns = { "node_modules", "env", "__pycache__" } - }, - pickers = { - -- Default configuration for builtin pickers goes here: - -- picker_name = { - -- picker_config_key = value, - -- ... - -- } - -- Now the picker_config_key will be applied every time you call this - -- builtin picker - find_files = { - -- theme = "dropdown" + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case" -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + glyph = { + action = function(glyph) + -- argument glyph is a table. + -- {name="", value="", category="", description=""} + + -- vim.fn.setreg("*", glyph.value) + -- print([[Press p or "*p to paste this glyph]] .. glyph.value) + + -- insert glyph when picked + vim.api.nvim_put({ glyph.value }, 'c', false, true) + end + } } - }, - extensions = { - -- Your extension configuration goes here: - -- extension_name = { - -- extension_config_key = value, - -- } - -- please take a look at the readme of the extension you want to configure - } -} + +}) +ts.load_extension('dap') +ts.load_extension('fzf') +ts.load_extension('glyph') diff --git a/plugin-confs/whichkey.lua b/plugin-confs/whichkey.lua old mode 100644 new mode 100755 index 8abe422..6fe1084 --- a/plugin-confs/whichkey.lua +++ b/plugin-confs/whichkey.lua @@ -69,11 +69,25 @@ wk.setup { } wk.register({ + a = { name = "AnyJump", b = "Back", l = "Last Result" }, + b = { + name = "Buffers", + b = "Show Buffers", + d = "Delete Buffer", + n = "Next Buffer", + p = "Previous Buffer" + }, c = { - name = "code", + name = "Code", a = "Code Action", d = "Diagnostics", - p = "Copilot Panel" + D = { + name = "Diagnostic List", + n = "Next Diagnostic", + p = "Previous Diagnostic" + }, + p = "Copilot Panel", + l = "Set Loclist" }, C = { name = "ChatGPT", @@ -84,5 +98,120 @@ wk.register({ s = "Summarize", f = "Fix Bugs", e = "Explain Code" - } + }, + d = { + name = "Debug", + b = "Toggle Breakpoint", + c = "Continue", + i = "Step Into", + o = "Step Over", + O = "Step Out", + r = "REPL Open", + l = "Run Last", + h = "Hover", + p = "Preview", + f = "Frames", + s = "Scopes", + u = { name = "Dap UI", t = "Toggle", o = "Open", c = "Close" }, + P = { + name = "Dap-python", + m = "Test Method", + c = "Test Class", + s = "Debug Selection" + } + }, + f = { + name = "Find File", + b = "File Browser", + f = "Find in Current Directory", + g = "Live Grep", + h = "File History" + }, + g = { + name = "Git", + b = "Blame", + c = "Commit", + f = "Files", + g = "Lazygit", + P = "Close goto-preview window", + R = "Telescope References", + p = { + "Peek", + c = "Close Preview", + d = "Preview Definition", + i = "Preview Implementation" + } + }, + h = { + name = "Help", + c = "Commands", + d = { + name = "Dap", + c = "Commands", + C = "Configurations", + b = "Breakpoints", + v = "Variables", + f = "Frames" + }, + v = "Vim Options", + k = "Keymaps", + s = "Spell Suggest" + }, + i = { name = "Insert", s = { name = "Snippet", p = "Python File" } }, + j = "Any Jump", + K = "Show Docs", + l = { + name = "LSP", + d = "Definitions", + D = "Diagnostics", + a = "Code Actions", + c = { name = "Calls", i = "Incoming", o = "Outgoing" }, + h = "Signature Help", + i = "Implementations", + r = "References", + R = "Rename", + s = "Document Symbols", + t = "Type Definitions", + w = "Workspace Symbols" + }, + n = "NvimTree", + o = { + name = "Open", + b = "File Browser", + B = "Btop", + c = "ChatGPT", + C = "Nvim Config", + d = "Lazydocker", + f = "Floating Terminal", + h = "Horizontal Terminal", + p = "Ipython", + P = "Ipython (fullscreen)", + r = "Ranger", + t = "Vertical Terminal" + }, + s = { + name = "Search", + c = "Clear Highlights", + C = "Commands", + f = "Files", + g = "Glyph", + h = "Command History", + m = "Man Pages" + }, + t = { + name = "Toggle", + c = "Colorscheme", + f = "Floating Terminal", + p = "Ipython", + P = "Ipython (fullscreen)", + t = "Split Terminal" + }, + w = { + name = "Workspace", + a = "Add Folder", + l = "List Folders", + r = "Remove Folder" + }, + x = "Set Executable Bit", + y = "System Yank" }, { prefix = "" })