-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathconfig.lua
More file actions
173 lines (155 loc) · 4.38 KB
/
Copy pathconfig.lua
File metadata and controls
173 lines (155 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
-- Disable moving lines with Alt+j / Alt+k in normal and visual modes
lvim.keys.normal_mode["<A-j>"] = false
lvim.keys.normal_mode["<A-k>"] = false
lvim.keys.visual_mode["<A-j>"] = false
lvim.keys.visual_mode["<A-k>"] = false
-- Plugin configuration
lvim.plugins = {
"ChristianChiarulli/swenv.nvim",
"stevearc/dressing.nvim",
"rafi/awesome-vim-colorschemes",
"shaunsingh/moonlight.nvim",
{
"folke/zen-mode.nvim",
opts = {
window = {
backdrop = 0.8,
width = 84,
height = 40,
options = {
number = false,
}
},
}
},
{
"folke/twilight.nvim",
opts = {
dimming = {
alpha = 0.125, -- less is more
color = { "Normal", "#ffffff" },
term_bg = "#000000", -- if guibg=NONE, this will be used to calculate text color
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10,
treesitter = true,
}
},
-- Disable indent guides (optional)
{
"lukas-reineke/indent-blankline.nvim",
enabled = true,
},
{ "tpope/vim-projectionist" },
-- Debug Adapter for Python
{
"mfussenegger/nvim-dap-python",
config = function()
local mason_path = vim.fn.stdpath("data") .. "/mason/packages/debugpy/venv/bin/python"
local ok, dap_python = pcall(require, "dap-python")
if ok then
dap_python.setup(mason_path)
else
vim.notify("nvim-dap-python not found", vim.log.levels.WARN)
end
end,
},
-- Neotest core + Python + Vitest adapters
{
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-neotest/neotest-python",
"marilari88/neotest-vitest",
"nvim-neotest/nvim-nio",
},
config = function()
local ok, neotest = pcall(require, "neotest")
if not ok then
vim.notify("Failed to load neotest: " .. neotest, vim.log.levels.ERROR)
return
end
local adapters = {}
local ok_py, python = pcall(require, "neotest-python")
if ok_py then
table.insert(adapters, python({
dap = {
justMyCode = false,
console = "integratedTerminal",
},
args = { "--log-level", "DEBUG", "--quiet" },
runner = "pytest",
}))
end
local ok_vitest, vitest = pcall(require, "neotest-vitest")
if ok_vitest then
table.insert(adapters, vitest({}))
end
neotest.setup({ adapters = adapters })
end,
},
}
-- Enable DAP
lvim.builtin.dap.active = true
-- Neotest key mappings
lvim.builtin.which_key.mappings["dm"] = {
"<cmd>lua require('neotest').run.run()<cr>", "Test Method"
}
lvim.builtin.which_key.mappings["dM"] = {
"<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", "Test Method DAP"
}
lvim.builtin.which_key.mappings["df"] = {
"<cmd>lua require('neotest').run.run(vim.fn.expand('%'))<cr>", "Test File"
}
lvim.builtin.which_key.mappings["dF"] = {
"<cmd>lua require('neotest').run.run({vim.fn.expand('%'), strategy = 'dap'})<cr>", "Test File DAP"
}
lvim.builtin.which_key.mappings["dS"] = {
"<cmd>lua require('neotest').summary.toggle()<cr>", "Test Summary"
}
lvim.builtin.which_key.mappings["dQ"] = {
"<cmd>lua require('dapui').close()<CR>", "Close DAP UI"
}
-- Python virtualenv chooser
lvim.builtin.which_key.mappings["C"] = {
name = "Python",
c = { "<cmd>lua require('swenv.api').pick_venv()<cr>", "Choose Env" },
}
vim.cmd([[
augroup AutoTest
autocmd!
autocmd BufWritePost *.py lua require("neotest").run.run()
augroup END
]])
require("neotest").setup({
output = {
enabled = true,
open_on_run = "short", -- or "always"
}
})
vim.g.projectionist_heuristics = {
["*.py"] = {
["*.py"] = {
alternate = "test_{}.py",
type = "source",
},
["test_*.py"] = {
alternate = "{}.py",
type = "test",
},
},
}
-- leader tt to switch between tests and impl
vim.keymap.set("n", "<leader>da", ":A<CR>", { desc = "Toggle Test/Impl" })
lvim.builtin.which_key.mappings["T"] = {
name = "Tabs",
n = { ":tabnew<cr>", "New Tab" },
c = { ":tabclose<cr>", "Close Tab" },
o = { ":tabonly<cr>", "Only This Tab" },
l = { ":tabnext<cr>", "Next Tab" },
h = { ":tabprevious<cr>", "Previous Tab" },
}
vim.opt.wrap = true
vim.opt.linebreak = true