To get code suggestions (intellisense) on your custom Frappe apps (including ERPNext) in Visual Studio Code, follow the steps below:
Open your app in a VSCode workspace
Create a new file called settings.json
in a folder .vscode
Add the following to this file:
{
"python.analysis.extraPaths": [
"${workspaceFolder}/../frappe"
],
}
What this is doing is telling VSCode to resolve paths from the frappe folder in the apps directory. You will now get code completion for all standard frappe methods in your own custom app.
Example:
Code suggestions:
12 Likes
Simply awesome. You have nailed it on code completion and type checking. It was pleasure to meet you.
1 Like
ankush
September 26, 2022, 4:41pm
3
I’ve been using pyright for year+ now. Works flawlessly
Some suggestions:
Enable auto search path instead of hardcoding it.
Enable use of library code for types.
Disable type checking (too much dynamic code to use this reliably)
nvim_lsp.pyright.setup {
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = on_attach,
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
typeCheckingMode = "off",
diagnosticMode = "openFilesOnly",
}
}
}
}
5 Likes
I had the same problem with pyright and adapted this for Emacs.
(after! lsp-pyright
(setq lsp-pyright-auto-search-paths t
lsp-pyright-use-library-code-for-types t
lsp-pyright-typechecking-mode "off"
lsp-pyright-diagnostic-mode "openFilesOnly"))