Skip to content

Python Extra

lang.python adds the usual Python editing stack without changing project policy. Your pyproject.toml, ruff.toml, or tool-specific config files remain the source of truth for formatting and lint rules.

For a more opinionated power-user stack with BasedPyright, Ruff formatting, virtualenv selection, and debugpy tooling, use lang.python-pro instead.

-- ~/.config/blak/lua/blak/user.lua
return {
extras = {
enabled = {
"lang.python",
},
},
}

Or enable it from Neovim:

:BlakExtras enable lang.python
Surface Contribution
Treesitter python
Mason black, isort, ruff
LSP pyright, ruff
Formatting isort, then black, for python
Linting ruff for python

Use lsp.servers.pyright and lsp.servers.ruff for server settings:

return {
extras = {
enabled = { "lang.python" },
},
lsp = {
servers = {
pyright = {
settings = {
python = {
analysis = {
typeCheckingMode = "basic",
},
},
},
},
ruff = {
init_options = {
settings = {
lineLength = 100,
},
},
},
},
},
}

The default order is imports first, then code formatting:

return {
extras = {
enabled = { "lang.python" },
},
format = {
formatters_by_ft = {
python = { "isort", "black" },
},
},
}

To let Ruff lint but stop format-on-save for Python, define an empty formatter list for Python:

return {
extras = {
enabled = { "lang.python" },
},
format = {
formatters_by_ft = {
python = {},
},
},
}

The extra wires ruff through nvim-lint. Set an empty list if you want only the Ruff LSP diagnostics:

return {
extras = {
enabled = { "lang.python" },
},
lint = {
linters_by_ft = {
python = {},
},
},
}
:BlakToolsInstall
:BlakTreesitterInstall
:BlakDoctor

Open a Python file and check :LspInfo for pyright and ruff.