pyright
tags :
LSP #
Configurations #
pyrightconfig.json documentation and sample:
ref: https://github.com/microsoft/pyright/blob/master/docs/configuration.md
Configuration that I used and that worked
t in the root of the project(git)
"venv": "ksaflyer_env",
"extraPaths": [
"/home/jaavedkhan/cdrive/code/personal_projects/apps/repo_ksaflyer/ksaflyer"
],
"exclude": [
"**/node_modules",
"**/__pycache__",
"**/static"
]
emacs config
(use-package lsp-pyright
:ensure t
:after lsp-mode
:custom
(lsp-pyright-auto-import-completions nil)
(lsp-pyright-typechecking-mode "off")
:config
(fk/async-process
"npm outdated -g | grep pyright | wc -l" nil
(lambda (process output)
(pcase output
("0\n" (message "Pyright is up to date."))
("1\n" (message "A pyright update is available.")))))
;; for setting python version of pyright lsp
(setq lsp-pyright-python-executable-cmd "python3")
(setq lsp-pyright-venv-path "/home/jaavedkhan/.virtualenvs")
)
Issues faced #
Error while uisng pyright IN office PC with npm #
pyright server was restaring with error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'worker_threads'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
Got at clue from here: https://github.com/fannheyward/coc-pyright/issues/73 and while installing the pyright package using emacs, I was getting this warning
npm WARN EBADENGINE Unsupported engine package: 'pyright@1.1.134',
npm WARN EBADENGINE required: node: '>=12.0.0' ,
npm WARN EBADENGINE current: node: 'v10.24.0', npm: '7.11.1'
Solution: #
Issue was nodejs (node==10.24.0) was installed already with apt. I uninstalled this, but still emacs was looking for node in /usr/bin/env(? not sure about the path but it was bin path of debian) . Restarting the PC made sure that the emacs recognizes the node version that I installed with nvm.