This commit is contained in:
alice-vu-163 2025-05-06 16:29:55 +07:00
parent d350db2449
commit ee1be1a29a
6 changed files with 258 additions and 11 deletions

View file

@ -0,0 +1,43 @@
-- must be after `require("dap-python").setup(debugpy_path)`
local dap = require 'dap'
local dap_python = require 'dap-python'
-- ─── General DAP mappings ────────────────────────────────────────────────────
vim.keymap.set('n', '<F5>', dap.continue, { desc = '▶ Continue' })
vim.keymap.set('n', '<F10>', dap.step_over, { desc = '⤼ Step Over' })
vim.keymap.set('n', '<F11>', dap.step_into, { desc = '⤽ Step Into' })
vim.keymap.set('n', '<F12>', dap.step_out, { desc = '⤾ Step Out' })
vim.keymap.set('n', '<leader>db', dap.toggle_breakpoint, { desc = ' Toggle Breakpoint' })
vim.keymap.set('n', '<leader>dB', function() -- conditional
dap.set_breakpoint(nil, nil, vim.fn.input 'Breakpoint condition: ')
end, { desc = ' Set Conditional Breakpoint' })
vim.keymap.set('n', '<leader>dr', dap.repl.open, { desc = ' Open DAP REPL' })
vim.keymap.set('n', '<leader>dl', dap.run_last, { desc = ' Run Last Session' })
-- Move current line down with J
vim.keymap.set('n', 'J', ':m .+1<CR>==', { noremap = true, silent = true })
-- Move current line up with K
vim.keymap.set('n', 'K', ':m .-2<CR>==', { noremap = true, silent = true })
-- Map <leader>T to toggle terminal
vim.keymap.set('n', 'T', function()
local Terminal = require('toggleterm.terminal').Terminal
local float_term = Terminal:new {
direction = 'float',
hidden = true, -- ensures it doesn't persist visually
}
float_term:toggle()
end, { desc = 'Toggle Floating Terminal' })
vim.keymap.set('n', '<leader>bd', function()
-- Close all open toggleterm terminals
require('toggleterm').toggle_all()
-- Then close the current buffer
vim.cmd 'bdelete!'
end, { desc = 'Close buffer and toggleterm' })
return {}

View file

@ -2,4 +2,132 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
return {
{
'folke/tokyonight.nvim',
lazy = false,
priority = 1000,
config = function()
require('tokyonight').setup {
transparent = true,
}
vim.cmd 'colorscheme tokyonight'
end,
},
{
'akinsho/toggleterm.nvim',
tag = '*',
config = function()
require('toggleterm').setup()
end,
},
{
'mfussenegger/nvim-dap',
dependencies = {
'rcarriga/nvim-dap-ui',
'mfussenegger/nvim-dap-python',
},
config = function()
local dap = require 'dap'
local dap_python = require 'dap-python'
local dapui = require 'dapui'
local debugpy_path = vim.fn.stdpath 'data' .. '/mason/packages/debugpy/venv/bin/python'
dap_python.setup(debugpy_path)
dap.configurations.python = dap.configurations.python or {}
-- Ta-yoong project debug config
table.insert(dap.configurations.python, {
name = 'Odoo Tayoong',
type = 'python',
request = 'launch',
program = '/Users/quandoan/Desktop/odoo-18.0/odoo-bin',
args = {
'-c',
'/Users/quandoan/Desktop/odoo-18.0/debian/odoo-tayoong.conf',
'-u',
'a1_einvoice_to_gov',
'--xmlrpc-port',
'8066',
},
pythonPath = function()
return '/usr/local/bin/python3.12'
end,
cwd = vim.fn.getcwd(),
env = { PYTHONUNBUFFERED = '1' },
console = 'integratedTerminal',
})
-- odoo 13 debug
table.insert(dap.configurations.python, {
name = 'Odoo 13',
type = 'python',
request = 'launch',
program = '/Users/quandoan/Desktop/odoo-13.0/odoo-bin',
args = {
'-c',
'/Users/quandoan/Desktop/odoo-13.0/debian/odoo.conf',
'-u',
'a1_einvoice_to_gov',
'--xmlrpc-port',
'8066',
},
pythonPath = function()
return '/usr/local/bin/python3.7'
end,
cwd = vim.fn.getcwd(),
env = { PYTHONUNBUFFERED = '1' },
console = 'integratedTerminal',
})
-- UI signs
vim.fn.sign_define('DapBreakpoint', { text = 'B', texthl = 'DapBreakpoint' })
vim.fn.sign_define('DapBreakpointCondition', { text = 'C', texthl = 'DapBreakpointCondition' })
vim.fn.sign_define('DapStopped', { text = '>', texthl = 'DapStopped', linehl = 'CursorLine' })
vim.cmd [[
highlight DapBreakpoint guifg=#FFA500 guibg=#1F1F28
highlight DapBreakpointCondition guifg=#FFA500 guibg=#1F1F28
highlight DapStopped guifg=#FFA500 guibg=#1F1F28
]]
dapui.setup {
layouts = {
{
elements = {
{ id = 'repl', size = 0.5 },
{ id = 'console', size = 0.5 },
},
size = 0.15,
position = 'left',
},
{
elements = {
{ id = 'scopes', size = 1.0 },
},
size = 0.85,
position = 'bottom',
},
},
}
end,
},
{
-- Ensure toggleterm is loaded
'akinsho/toggleterm.nvim',
keys = {
{
'<leader>lg',
function()
local Terminal = require('toggleterm.terminal').Terminal
local lazygit = Terminal:new {
cmd = 'lazygit',
direction = 'float',
hidden = true,
}
lazygit:toggle()
end,
desc = 'Lazygit (float)',
},
},
},
}

View file

@ -0,0 +1,3 @@
-- Then load your custom setup scripts
require 'custom.setups.lsp'
require 'custom.setups.term'

12
lua/custom/setups/lsp.lua Normal file
View file

@ -0,0 +1,12 @@
require('lspconfig').pyright.setup {
settings = {
python = {
analysis = {
typeCheckingMode = 'off', -- disables type checking
diagnosticMode = 'openFilesOnly', -- optional: only analyze open files
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
}

View file

@ -0,0 +1,10 @@
require('toggleterm').setup {
direction = 'float',
float_opts = {
border = 'curved',
width = 100,
height = 30,
winblend = 0, -- optional: transparency
-- Omit row/col so it's automatically centered
},
}