enc: add default config python

This commit is contained in:
asep.komarudin 2024-06-22 13:00:28 +07:00
parent 178c969312
commit 35c170c09a
6 changed files with 53 additions and 54 deletions

View file

@ -2,7 +2,7 @@
-- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt"
local rfile = {
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
python = "python3 -u",
python = "python -u",
typescript = "ts-node $dir/$fileName",
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",

View file

@ -1,5 +1,5 @@
local M = {}
if pcode.nvim_dap_python then
if pcode.active_python_config then
M = {
{
"mfussenegger/nvim-dap",
@ -51,6 +51,45 @@ if pcode.nvim_dap_python then
{ "<leader>dU", "<cmd>lua require'dapui'.toggle({reset = true})<cr>", desc = "Toggle UI" },
},
},
-- https://github.com/nvim-neotest/neotest-python
-- https://docs.pytest.org/en/7.1.x/getting-started.html
{
"nvim-neotest/neotest",
dependencies = {
"mfussenegger/nvim-dap-python",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/nvim-nio",
"nvim-neotest/neotest-python",
},
config = function()
local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/")
pcall(function()
require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
end)
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
args = { "--log-level", "DEBUG" },
runner = "pytest",
python = "python",
}),
},
})
end,
-- stylua: ignore
keys = {
{ "<leader>T","",desc="  Test"},
{ "<leader>Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
{ "<leader>Tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
{ "<leader>TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
{ "<leader>Tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
{ "<Leader>Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
{ "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
},
},
}
end
return M

View file

@ -1,42 +0,0 @@
local M = {}
if pcode.pytest then
M = {
"nvim-neotest/neotest",
dependencies = {
"mfussenegger/nvim-dap-python",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/nvim-nio",
"nvim-neotest/neotest-python",
},
config = function()
local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/")
pcall(function()
require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
end)
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
args = { "--log-level", "DEBUG" },
runner = "pytest",
python = "python",
}),
},
})
end,
-- stylua: ignore
keys = {
{ "<leader>T","",desc="  Test"},
{ "<leader>Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
{ "<leader>Tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
{ "<leader>TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
{ "<leader>Tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
{ "<Leader>Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
{ "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
},
}
end
return M

View file

@ -64,4 +64,11 @@ if pcode.active_golang_config then
table.insert(pcode.null_ls_ensure_installed, "ast_grep")
table.insert(pcode.null_ls_ensure_installed, "gofumpt")
end
-- run if python config true
if pcode.active_python_config then
table.insert(pcode.treesitter_ensure_installed, "python")
table.insert(pcode.mason_ensure_installed, "pyright")
table.insert(pcode.null_ls_ensure_installed, "flake8")
table.insert(pcode.null_ls_ensure_installed, "black")
end
return {}