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

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.opt`
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
@ -275,7 +275,39 @@ require('lazy').setup({
},
},
},
{
'rcarriga/nvim-dap-ui',
requires = { 'mfussenegger/nvim-dap' },
config = function()
local dap, dapui = require 'dap', require 'dapui'
-- set up with all the default layouts:
dapui.setup()
-- auto-open when session starts, auto-close when it ends:
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
end
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
end
-- optional: a handy toggle keymap
vim.keymap.set('n', '<leader>du', dapui.toggle, { desc = ' Toggle DAP UI' })
end,
},
{
'mfussenegger/nvim-dap-python',
dependencies = { 'mfussenegger/nvim-dap' },
config = function()
-- point to the Python that can `import debugpy`
local debugpy_path = vim.fn.stdpath 'data' .. '/mason/packages/debugpy/venv/bin/python'
require('dap-python').setup(debugpy_path)
end,
},
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
--
-- This is often very useful to both group configuration, as well as handle
@ -665,7 +697,22 @@ require('lazy').setup({
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
pyright = {
settings = {
python = {
analysis = {
typeCheckingMode = 'off', -- ✅ disable type errors
diagnosticMode = 'openFilesOnly', -- ✅ optional: only open buffers, not full project
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
},
lemminx = {},
-- ✅ JavaScript/TypeScript LSP (recommended)
ts_ls = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
@ -708,6 +755,8 @@ require('lazy').setup({
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'prettierd', -- JS/TS formatter
'xmlformatter', -- for formatting XML if needed
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -965,18 +1014,20 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.neo-tree',
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
{ import = 'custom.keymaps' },
{ import = 'custom.setups' },
--
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope!

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