update dap and set whichkey keys

This commit is contained in:
2023-08-15 11:11:38 -07:00
parent 38d3e0e221
commit 1566186961
8 changed files with 343 additions and 116 deletions

View File

@@ -1,13 +1,12 @@
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap('n', '<space>e',
'<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>',
opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>',
opts)
vim.api.nvim_set_keymap('n', '<space>q',
'<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- local opts = { noremap = true, silent = true }
-- vim.api.nvim_set_keymap('n', '<space>e',
-- '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
-- vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>',
-- opts)
-- vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>',
-- opts)
-- vim.api.nvim_set_keymap('n', '<space>q',
-- '<cmd>lua vim.diagnostic.setloclist()<CR>', 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)

View File

@@ -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
-- }
-- }

View File

@@ -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)

View File

@@ -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 <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
-- ["<C-/?>"] = "which_key"
}
},
file_ignore_patterns = { "^node_modules/", "^env/", "^__pycache__/" }
},
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "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')

135
plugin-confs/whichkey.lua Normal file → Executable file
View File

@@ -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 = "<leader>" })