Getting Started¶
Installation¶
From PyPI¶
From Source¶
Editor Configuration¶
Neovim¶
Using lazy.nvim:
{
"neovim/nvim-lspconfig",
opts = {
servers = {
nasa_lsp = {
cmd = { "uvx", "nasa_lsp" },
filetypes = { "python" },
root_dir = function(fname)
return require("lspconfig.util").find_git_ancestor(fname)
end,
settings = {},
},
},
},
}
Or with manual configuration:
require("lspconfig").nasa_lsp.setup({
cmd = { "uvx", "nasa_lsp" },
filetypes = { "python" },
root_dir = require("lspconfig.util").find_git_ancestor,
})
VS Code¶
Create or edit .vscode/settings.json:
{
"python.linting.enabled": true,
"python.languageServer": "None",
"nasa-lsp.enabled": true,
"nasa-lsp.path": ["uvx", "nasa_lsp"]
}
Usage¶
The LSP runs automatically on Python files and provides inline diagnostics as you type. Violations appear as warnings with diagnostic codes:
NASA01-A: Use of forbidden dynamic APINASA01-B: Direct recursive function callNASA02: Unbounded while True loopNASA04: Function exceeds 60-line limitNASA05: Insufficient assertions in function
Example Violations¶
This code violates NASA02 with an unbounded loop and NASA05 with no assertions.
Fixed version: