Since I work on large Python projects, use direnv
to manage my environment, and lsp-mode
, I thought I might be able to help, but reading your long message I can’t find any specific issue except it sounds like your LSP server is misbehaving.
I do not get lagging or memory leaking in Emacs from using it. What process is getting large? Emacs or the LSP server? You don’t give us any clues.
Though I am therefore no use in solving your problems, if I’ve avoided them. I’m using pyright, and ruff. I am using the
lsp-pyright
package, and it looks like I configured ruff with: