Skip to content

Commit ee1be1a

Browse files
committed
quandoan
1 parent d350db2 commit ee1be1a

File tree

6 files changed

+258
-11
lines changed

6 files changed

+258
-11
lines changed

init.lua

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ vim.g.mapleader = ' '
9191
vim.g.maplocalleader = ' '
9292

9393
-- Set to true if you have a Nerd Font installed and selected in the terminal
94-
vim.g.have_nerd_font = false
94+
vim.g.have_nerd_font = true
9595

9696
-- [[ Setting options ]]
9797
-- See `:help vim.opt`
@@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
102102
vim.opt.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
-- vim.opt.relativenumber = true
105+
vim.opt.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108108
vim.opt.mouse = 'a'
@@ -275,7 +275,39 @@ require('lazy').setup({
275275
},
276276
},
277277
},
278+
{
279+
'rcarriga/nvim-dap-ui',
280+
requires = { 'mfussenegger/nvim-dap' },
281+
config = function()
282+
local dap, dapui = require 'dap', require 'dapui'
283+
284+
-- set up with all the default layouts:
285+
dapui.setup()
286+
287+
-- auto-open when session starts, auto-close when it ends:
288+
dap.listeners.after.event_initialized['dapui_config'] = function()
289+
dapui.open()
290+
end
291+
dap.listeners.before.event_terminated['dapui_config'] = function()
292+
dapui.close()
293+
end
294+
dap.listeners.before.event_exited['dapui_config'] = function()
295+
dapui.close()
296+
end
278297

298+
-- optional: a handy toggle keymap
299+
vim.keymap.set('n', '<leader>du', dapui.toggle, { desc = ' Toggle DAP UI' })
300+
end,
301+
},
302+
{
303+
'mfussenegger/nvim-dap-python',
304+
dependencies = { 'mfussenegger/nvim-dap' },
305+
config = function()
306+
-- point to the Python that can `import debugpy`
307+
local debugpy_path = vim.fn.stdpath 'data' .. '/mason/packages/debugpy/venv/bin/python'
308+
require('dap-python').setup(debugpy_path)
309+
end,
310+
},
279311
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
280312
--
281313
-- This is often very useful to both group configuration, as well as handle
@@ -665,7 +697,22 @@ require('lazy').setup({
665697
local servers = {
666698
-- clangd = {},
667699
-- gopls = {},
668-
-- pyright = {},
700+
pyright = {
701+
settings = {
702+
python = {
703+
analysis = {
704+
typeCheckingMode = 'off', -- ✅ disable type errors
705+
diagnosticMode = 'openFilesOnly', -- ✅ optional: only open buffers, not full project
706+
autoSearchPaths = true,
707+
useLibraryCodeForTypes = true,
708+
},
709+
},
710+
},
711+
},
712+
lemminx = {},
713+
714+
-- ✅ JavaScript/TypeScript LSP (recommended)
715+
ts_ls = {},
669716
-- rust_analyzer = {},
670717
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
671718
--
@@ -708,6 +755,8 @@ require('lazy').setup({
708755
local ensure_installed = vim.tbl_keys(servers or {})
709756
vim.list_extend(ensure_installed, {
710757
'stylua', -- Used to format Lua code
758+
'prettierd', -- JS/TS formatter
759+
'xmlformatter', -- for formatting XML if needed
711760
})
712761
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
713762

@@ -965,18 +1014,20 @@ require('lazy').setup({
9651014
-- Here are some example plugins that I've included in the Kickstart repository.
9661015
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
9671016
--
968-
-- require 'kickstart.plugins.debug',
969-
-- require 'kickstart.plugins.indent_line',
970-
-- require 'kickstart.plugins.lint',
971-
-- require 'kickstart.plugins.autopairs',
972-
-- require 'kickstart.plugins.neo-tree',
973-
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
1017+
require 'kickstart.plugins.debug',
1018+
require 'kickstart.plugins.indent_line',
1019+
require 'kickstart.plugins.lint',
1020+
require 'kickstart.plugins.autopairs',
1021+
require 'kickstart.plugins.neo-tree',
1022+
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
9741023

9751024
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
9761025
-- This is the easiest way to modularize your config.
9771026
--
9781027
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
979-
-- { import = 'custom.plugins' },
1028+
{ import = 'custom.plugins' },
1029+
{ import = 'custom.keymaps' },
1030+
{ import = 'custom.setups' },
9801031
--
9811032
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
9821033
-- Or use telescope!

lua/custom/keymaps/init.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- must be after `require("dap-python").setup(debugpy_path)`
2+
local dap = require 'dap'
3+
local dap_python = require 'dap-python'
4+
5+
-- ─── General DAP mappings ────────────────────────────────────────────────────
6+
vim.keymap.set('n', '<F5>', dap.continue, { desc = '▶ Continue' })
7+
vim.keymap.set('n', '<F10>', dap.step_over, { desc = '⤼ Step Over' })
8+
vim.keymap.set('n', '<F11>', dap.step_into, { desc = '⤽ Step Into' })
9+
vim.keymap.set('n', '<F12>', dap.step_out, { desc = '⤾ Step Out' })
10+
11+
vim.keymap.set('n', '<leader>db', dap.toggle_breakpoint, { desc = ' Toggle Breakpoint' })
12+
vim.keymap.set('n', '<leader>dB', function() -- conditional
13+
dap.set_breakpoint(nil, nil, vim.fn.input 'Breakpoint condition: ')
14+
end, { desc = ' Set Conditional Breakpoint' })
15+
16+
vim.keymap.set('n', '<leader>dr', dap.repl.open, { desc = ' Open DAP REPL' })
17+
vim.keymap.set('n', '<leader>dl', dap.run_last, { desc = ' Run Last Session' })
18+
19+
-- Move current line down with J
20+
vim.keymap.set('n', 'J', ':m .+1<CR>==', { noremap = true, silent = true })
21+
22+
-- Move current line up with K
23+
vim.keymap.set('n', 'K', ':m .-2<CR>==', { noremap = true, silent = true })
24+
25+
-- Map <leader>T to toggle terminal
26+
vim.keymap.set('n', 'T', function()
27+
local Terminal = require('toggleterm.terminal').Terminal
28+
local float_term = Terminal:new {
29+
direction = 'float',
30+
hidden = true, -- ensures it doesn't persist visually
31+
}
32+
float_term:toggle()
33+
end, { desc = 'Toggle Floating Terminal' })
34+
35+
vim.keymap.set('n', '<leader>bd', function()
36+
-- Close all open toggleterm terminals
37+
require('toggleterm').toggle_all()
38+
39+
-- Then close the current buffer
40+
vim.cmd 'bdelete!'
41+
end, { desc = 'Close buffer and toggleterm' })
42+
43+
return {}

lua/custom/plugins/init.lua

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,132 @@
22
-- I promise not to create any merge conflicts in this directory :)
33
--
44
-- See the kickstart.nvim README for more information
5-
return {}
5+
return {
6+
{
7+
'folke/tokyonight.nvim',
8+
lazy = false,
9+
priority = 1000,
10+
config = function()
11+
require('tokyonight').setup {
12+
transparent = true,
13+
}
14+
vim.cmd 'colorscheme tokyonight'
15+
end,
16+
},
17+
{
18+
'akinsho/toggleterm.nvim',
19+
tag = '*',
20+
config = function()
21+
require('toggleterm').setup()
22+
end,
23+
},
24+
{
25+
'mfussenegger/nvim-dap',
26+
dependencies = {
27+
'rcarriga/nvim-dap-ui',
28+
'mfussenegger/nvim-dap-python',
29+
},
30+
config = function()
31+
local dap = require 'dap'
32+
local dap_python = require 'dap-python'
33+
local dapui = require 'dapui'
34+
35+
local debugpy_path = vim.fn.stdpath 'data' .. '/mason/packages/debugpy/venv/bin/python'
36+
dap_python.setup(debugpy_path)
37+
38+
dap.configurations.python = dap.configurations.python or {}
39+
-- Ta-yoong project debug config
40+
table.insert(dap.configurations.python, {
41+
name = 'Odoo Tayoong',
42+
type = 'python',
43+
request = 'launch',
44+
program = '/Users/quandoan/Desktop/odoo-18.0/odoo-bin',
45+
args = {
46+
'-c',
47+
'/Users/quandoan/Desktop/odoo-18.0/debian/odoo-tayoong.conf',
48+
'-u',
49+
'a1_einvoice_to_gov',
50+
'--xmlrpc-port',
51+
'8066',
52+
},
53+
pythonPath = function()
54+
return '/usr/local/bin/python3.12'
55+
end,
56+
cwd = vim.fn.getcwd(),
57+
env = { PYTHONUNBUFFERED = '1' },
58+
console = 'integratedTerminal',
59+
})
60+
-- odoo 13 debug
61+
table.insert(dap.configurations.python, {
62+
name = 'Odoo 13',
63+
type = 'python',
64+
request = 'launch',
65+
program = '/Users/quandoan/Desktop/odoo-13.0/odoo-bin',
66+
args = {
67+
'-c',
68+
'/Users/quandoan/Desktop/odoo-13.0/debian/odoo.conf',
69+
'-u',
70+
'a1_einvoice_to_gov',
71+
'--xmlrpc-port',
72+
'8066',
73+
},
74+
pythonPath = function()
75+
return '/usr/local/bin/python3.7'
76+
end,
77+
cwd = vim.fn.getcwd(),
78+
env = { PYTHONUNBUFFERED = '1' },
79+
console = 'integratedTerminal',
80+
})
81+
82+
-- UI signs
83+
vim.fn.sign_define('DapBreakpoint', { text = 'B', texthl = 'DapBreakpoint' })
84+
vim.fn.sign_define('DapBreakpointCondition', { text = 'C', texthl = 'DapBreakpointCondition' })
85+
vim.fn.sign_define('DapStopped', { text = '>', texthl = 'DapStopped', linehl = 'CursorLine' })
86+
87+
vim.cmd [[
88+
highlight DapBreakpoint guifg=#FFA500 guibg=#1F1F28
89+
highlight DapBreakpointCondition guifg=#FFA500 guibg=#1F1F28
90+
highlight DapStopped guifg=#FFA500 guibg=#1F1F28
91+
]]
92+
93+
dapui.setup {
94+
layouts = {
95+
{
96+
elements = {
97+
{ id = 'repl', size = 0.5 },
98+
{ id = 'console', size = 0.5 },
99+
},
100+
size = 0.15,
101+
position = 'left',
102+
},
103+
{
104+
elements = {
105+
{ id = 'scopes', size = 1.0 },
106+
},
107+
size = 0.85,
108+
position = 'bottom',
109+
},
110+
},
111+
}
112+
end,
113+
},
114+
{
115+
-- Ensure toggleterm is loaded
116+
'akinsho/toggleterm.nvim',
117+
keys = {
118+
{
119+
'<leader>lg',
120+
function()
121+
local Terminal = require('toggleterm.terminal').Terminal
122+
local lazygit = Terminal:new {
123+
cmd = 'lazygit',
124+
direction = 'float',
125+
hidden = true,
126+
}
127+
lazygit:toggle()
128+
end,
129+
desc = 'Lazygit (float)',
130+
},
131+
},
132+
},
133+
}

lua/custom/setups/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Then load your custom setup scripts
2+
require 'custom.setups.lsp'
3+
require 'custom.setups.term'

lua/custom/setups/lsp.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require('lspconfig').pyright.setup {
2+
settings = {
3+
python = {
4+
analysis = {
5+
typeCheckingMode = 'off', -- disables type checking
6+
diagnosticMode = 'openFilesOnly', -- optional: only analyze open files
7+
autoSearchPaths = true,
8+
useLibraryCodeForTypes = true,
9+
},
10+
},
11+
},
12+
}

lua/custom/setups/term.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require('toggleterm').setup {
2+
direction = 'float',
3+
float_opts = {
4+
border = 'curved',
5+
width = 100,
6+
height = 30,
7+
winblend = 0, -- optional: transparency
8+
-- Omit row/col so it's automatically centered
9+
},
10+
}

0 commit comments

Comments
 (0)