before change to base lazy

This commit is contained in:
Martin-Melody 2024-10-28 22:16:06 +00:00
parent c51b67a644
commit 3022b2eb12
6 changed files with 185 additions and 131 deletions

View file

@ -2,116 +2,65 @@ return {
{
'mfussenegger/nvim-dap',
dependencies = {
'leoluz/nvim-dap-go',
'rcarriga/nvim-dap-ui',
'theHamsta/nvim-dap-virtual-text',
'nvim-neotest/nvim-nio',
'williamboman/mason.nvim',
'williamboman/mason.nvim', -- for installing netcoredbg
},
config = function()
local dap = require 'dap'
local ui = require 'dapui'
local dapui = require 'dapui'
require('dapui').setup()
require('dap-go').setup()
require('nvim-dap-virtual-text').setup {}
-- Setup DAP UI
dapui.setup()
require('nvim-dap-virtual-text').setup()
-- Configuration for .NET Core (ASP.NET Core) using net8.0
-- CoreCLR Adapter Configuration for .NET
dap.adapters.coreclr = {
type = 'executable',
command = '/usr/local/bin/netcoredbg/netcoredbg', -- Update with the correct path to netcoredbg
command = '/usr/local/bin/netcoredbg/netcoredbg',
args = { '--interpreter=vscode' },
}
-- DAP Configuration for .NET Core
dap.configurations.cs = {
{
type = 'coreclr',
name = 'Launch ASP.NET Core',
name = 'Launch .NET Core Web API',
request = 'launch',
preLaunchTask = function()
-- Run the project before launching the debugger
local build_cmd = 'dotnet publish --configuration Debug --runtime linux-x64 --self-contained'
print('Running: ' .. build_cmd)
vim.fn.system(build_cmd)
end,
program = function()
local cwd = vim.fn.getcwd()
local dll = vim.fn.glob(cwd .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 0, 1)
if #dll == 0 then
print 'No DLL found in bin/Debug/net8.0/linux-x64'
return ''
end
print('Using program: ' .. dll[1])
return dll[1]
return vim.fn.input('Path to dll: ', vim.fn.getcwd() .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 'file')
end,
cwd = '${workspaceFolder}',
stopAtEntry = false,
console = 'integratedTerminal',
},
{
type = 'coreclr',
name = 'Attach ASP.NET Core',
name = 'Attach to .NET Core',
request = 'attach',
processId = require('dap.utils').pick_process,
cwd = '${workspaceFolder}',
},
}
-- Configuration for Ionic Angular (JavaScript/TypeScript) using Firefox
dap.adapters.chrome = {
type = 'executable',
command = 'node',
args = { os.getenv 'HOME' .. '/.vscode/extensions/vscode-chrome-debug/out/src/chromeDebug.js' },
}
dap.configurations.javascript = {
{
type = 'chrome',
name = 'Attach to Chrome (Ionic App)',
request = 'attach',
program = '${file}',
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = 'inspector',
port = 9222, -- Port where Chrome is listening
url = 'https://localhost:8100/login', -- URL of your running Ionic app
webRoot = '${workspaceFolder}',
timeout = 20000, -- Optional: Increase if you experience timeouts
address = '0.0.0.0',
},
}
dap.configurations.typescript = dap.configurations.javascript
vim.keymap.set('n', '<space>tb', dap.toggle_breakpoint)
vim.keymap.set('n', '<space>gb', dap.run_to_cursor)
vim.keymap.set('n', '<space>?', function()
require('dapui').eval(nil, { enter = true })
-- Key mappings for debugging
vim.keymap.set('n', '<F5>', dap.continue)
vim.keymap.set('n', '<F10>', dap.step_over)
vim.keymap.set('n', '<F11>', dap.step_into)
vim.keymap.set('n', '<F12>', dap.step_out)
vim.keymap.set('n', '<Leader>b', dap.toggle_breakpoint)
vim.keymap.set('n', '<Leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end)
vim.keymap.set('n', '<F1>', dap.continue)
vim.keymap.set('n', '<F2>', dap.step_into)
vim.keymap.set('n', '<F3>', dap.step_over)
vim.keymap.set('n', '<F4>', dap.step_out)
vim.keymap.set('n', '<F5>', dap.step_back)
vim.keymap.set('n', '<F12>', dap.restart)
-- Key mapping to toggle the DAP UI
vim.keymap.set('n', '<Leader>dui', function()
ui.toggle()
end)
dap.listeners.before.attach.dapui_config = function()
ui.open()
-- Automatically open/close DAP UI on start/end
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
ui.open()
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
end
dap.listeners.before.event_terminated.dapui_config = function()
ui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
ui.close()
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
end
end,
},

View file

@ -0,0 +1,45 @@
return {
'nvimdev/lspsaga.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
'nvim-treesitter/nvim-treesitter',
},
config = function()
-- Setup lspsaga with your custom settings
require('lspsaga').setup {
use_saga_diagnostic_sign = true,
error_sign = 'E',
warn_sign = 'W',
hint_sign = 'H',
infor_sign = 'I',
code_action_icon = '💡',
finder_action_keys = {
open = 'o',
vsplit = 's',
split = 'i',
quit = 'q',
scroll_down = '<C-f>',
scroll_up = '<C-b>',
},
code_action_keys = {
quit = 'q',
exec = '<CR>',
},
rename_action_quit = '<C-c>',
definition_preview_icon = '🔍',
border_style = 'round',
rename_prompt_prefix = '',
}
-- Add custom key mappings for lspsaga
local opts = { noremap = true, silent = true }
-- Key mappings for lspsaga actions
vim.api.nvim_set_keymap('n', '<leader>ca', ':Lspsaga code_action<CR>', opts) -- Code action
vim.api.nvim_set_keymap('n', '<leader>rn', ':Lspsaga rename<CR>', opts) -- Rename
vim.api.nvim_set_keymap('n', 'gh', ':Lspsaga hover_doc<CR>', opts) -- Hover doc
vim.api.nvim_set_keymap('n', 'gd', ':Lspsaga lsp_finder<CR>', opts) -- LSP finder
vim.api.nvim_set_keymap('n', '[e', ':Lspsaga diagnostic_jump_prev<CR>', opts) -- Previous diagnostic
vim.api.nvim_set_keymap('n', ']e', ':Lspsaga diagnostic_jump_next<CR>', opts) -- Next diagnostic
end,
}

32
lua/custom/snips.lua Normal file
View file

@ -0,0 +1,32 @@
local ls = require 'luasnip'
local s = ls.snippet
local t = ls.text_node
local f = ls.function_node
-- Function to generate the namespace based on the file path
local function generate_namespace()
local file_path = vim.fn.expand '%:p:h' -- Get the file path of the current buffer
-- Adjust 'src' or 'project_root' based on your directory structure
local namespace = file_path:gsub('.*src[\\/]', ''):gsub('[\\/]', '.') -- Replace slashes with dots
return 'namespace ' .. namespace
end
-- Function to get the file name (without extension) as the class name
local function get_class_name()
return vim.fn.expand '%:t:r' -- Get the file name without the extension
end
-- Snippet for C# class generation
ls.add_snippets('cs', {
s('myclass', { -- Updated the trigger from 'class' to 'myclass'
-- Insert the namespace based on the file path
f(generate_namespace, {}),
t { '', '' }, -- Line break after namespace
-- Generate class name based on file name
t 'public class ',
f(get_class_name, {}),
t { '', '{', '\t' },
ls.insert_node(0), -- Cursor here
t { '', '}' }, -- End of class
}),
})