DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
http://docs.basedpyright.com/
Other
594 stars 12 forks source link

support `textDocument/foldingRange` #308

Open igorlfs opened 2 months ago

igorlfs commented 2 months ago

LSP Spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_foldingRange

Other servers that implement this capability are rust-analyzer and tsserver.

DetachHead commented 2 months ago

are these folding ranges? if so, vscode seems to add these on its own without pylance/pyright installed:

image

just to make sure we're on the same page, are you using a different editor and want this feature added to the language server?

igorlfs commented 2 months ago

Yep, those are the folds!

I assume VS Code has a built-in implementation for some languages, or something like that.

I'm using neovim, which also provides a "default" implementation, but having as it language server capability would be nice. Some servers allow folding imports / comments, for instance.

DetachHead commented 2 months ago

alright, i just removed "pylance feature parity" because as far as i can tell the functionality doesn't come from pylance but vscode itself

igorlfs commented 2 months ago

I do think the capability comes from pylance, see this issue

KotlinIsland commented 2 months ago

Can we automatically fold the import blocks, PyCharm does this and it's very appreciated: I don't like seeing 1000 lines of generated code at the top of every file

KotlinIsland commented 2 months ago

I do think the capability comes from pylance, see this issue

Folding support was added in 2022.1.1

https://github.com/microsoft/pylance-release/issues/372#issuecomment-1023726101

KotlinIsland commented 2 months ago

currently (in bpr) folding is based on indentation:

def foo():
    print(
)
    print(2)

Try this out, you will observe that it is broken.