Skip to content

Commit a9c16f2

Browse files
authored
feat(neovim): improve python tools support (#47)
Melhora no ferramenta para desenvolvimento em Python. Foi usado o [seguinte repositório](https://gist.github.com/paulopatto/73a8dfe0054d11c7622375f1b095d611) como testes de funcionalidades ### Changes ✨ - [chore(python): Ensure ruff LSP on default packages](067eb3c) - 067eb3c - [feat(neovim): Python DAP - Add support to python dap (via nvim-dap-python and debugpy).](295241d) - 295241d - [feat(neovim): Config static analysis and lint of Python code](a65dd01) - a65dd01 - Defines pyright as static code analysis - Defines ruff as linter - Organizae prettier ### References 📚 - https://youtu.be/IobijoroGE0?si=nvq16kpJG0K0x6wa - https://youtu.be/tfC1i32eW3A?si=1x3EUsr3kjA13umV - https://youtu.be/4BnVeOUeZxc?si=kMEmA72Xk-Kgkk9n
1 parent 308a093 commit a9c16f2

File tree

5 files changed

+258
-181
lines changed

5 files changed

+258
-181
lines changed

default-python-packages

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
black
2-
flake8
31
ipython
42
pipenv
53
pynvim
6-
pyright
74
pytest
85
requests
6+
ruff
7+
ruff-lsp
98
virtualenv
9+

nvim/lua/plugins/DAP.lua

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ return {
77
-- Key maps
88
-- See :help dap.txt, :help dap-mapping and :help dap-api.
99
-- debug toogle (breakpoint)
10-
vim.keymap.set("n", '<Leader>dt', dap.toggle_breakpoint, {})
10+
vim.keymap.set("n", "<Leader>dt", dap.toggle_breakpoint, {})
1111
-- debug continue: Launching debug sessions and resuming execution via
12-
vim.keymap.set("n", '<Leader>dc', dap.continue, {})
12+
vim.keymap.set("n", "<Leader>dc", dap.continue, {})
1313
-- debug step (over): Stepping through code over the line
14-
vim.keymap.set("n", '<Leader>ds', dap.step_over, {})
15-
-- debug (step) into: Stepping through code into the function
16-
vim.keymap.set("n", '<Leader>di', dap.step_into, {})
14+
vim.keymap.set("n", "<Leader>ds", dap.step_over, {})
15+
-- debug (step) into: Stepping through code into the function
16+
vim.keymap.set("n", "<Leader>di", dap.step_into, {})
1717
-- debug repl: Inspecting the state via the built-in REPL
18-
vim.keymap.set("n", '<Leader>dr', dap.repl.open, {})
19-
end
18+
vim.keymap.set("n", "<Leader>dr", dap.repl.open, {})
19+
end,
20+
},
21+
{
22+
"mfussenegger/nvim-dap-python",
23+
ft = "python",
24+
dependecies = {
25+
"mfussenegger/nvim-dap",
26+
"rcarriga/nvim-dap-ui",
27+
},
28+
config = function(_, opts)
29+
--[[ local path = "~/.local/share/nvim/mason/packages/debugpy/venv/bin/python"
30+
require("dap-python").setup(path) ]]
31+
local dap = require("dap-python")
32+
33+
-- calls dap python run file
34+
vim.keymap.set("n", "<leader>dpr", dap.test_method, {})
35+
end,
2036
},
2137
{
2238
"rcarriga/nvim-dap-ui",
@@ -40,36 +56,60 @@ return {
4056
dap.listeners.before.event_exited.dapui_config = function()
4157
dapui.close()
4258
end
43-
end
59+
end,
4460
},
4561
{
4662
"theHamsta/nvim-dap-virtual-text",
47-
config = function ()
63+
config = function()
4864
local dap_virtual_text = require("nvim-dap-virtual-text")
4965

5066
dap_virtual_text.setup({
51-
enabled = true, -- enable this plugin (the default)
52-
enabled_commands = true, -- create commands
53-
-- * DapVirtualTextEnable
54-
-- * DapVirtualTextDisable
55-
-- * DapVirtualTextToggle
56-
highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
57-
highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables
58-
show_stop_reason = true, -- show stop reason when stopped for exceptions
59-
commented = false, -- prefix virtual text with comment string
60-
only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
61-
all_references = false, -- show virtual text on all all references of the variable (not only definitions)
62-
clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping)
63-
virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol', -- position of virtual text, see `:h nvim_buf_set_extmark()`
67+
enabled = true, -- enable this plugin (the default)
68+
enabled_commands = true, -- create commands
69+
-- * DapVirtualTextEnable
70+
-- * DapVirtualTextDisable
71+
-- * DapVirtualTextToggle
72+
highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
73+
highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables
74+
show_stop_reason = true, -- show stop reason when stopped for exceptions
75+
commented = false, -- prefix virtual text with comment string
76+
only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
77+
all_references = false, -- show virtual text on all all references of the variable (not only definitions)
78+
clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping)
79+
virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol", -- position of virtual text, see `:h nvim_buf_set_extmark()`
6480
})
65-
end
81+
end,
6682
},
6783
{
6884
"jay-babu/mason-nvim-dap.nvim",
69-
config = function ()
85+
opts = {
86+
-- This line is essential to making automatic installation work
87+
-- :exploding-brain
88+
-- https://www.johntobin.ie/blog/debugging_in_neovim_with_nvim-dap/
89+
handlers = {},
90+
automatic_installation = {
91+
exclude = {
92+
"python",
93+
},
94+
ensure_installed = {
95+
"python",
96+
"debugpy",
97+
},
98+
},
99+
},
100+
dependencies = {
101+
"mfussenegger/nvim-dap",
102+
"williamboman/mason.nvim",
103+
},
104+
config = function()
70105
require("mason-nvim-dap").setup({
71106
automatic_installation = true,
107+
ensure_installed = {
108+
"python",
109+
"debugpy",
110+
},
72111
})
73-
end
112+
end,
74113
},
75114
}
115+

0 commit comments

Comments
 (0)