python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.95k stars 194 forks source link

Hide/show dunder methods and attributes during autocompletion #95

Open sntgluca opened 3 years ago

sntgluca commented 3 years ago

Hi,

I wonder if it's possible to configure pylsp to hide dunder methods and attributes, or if something like this could be added in the future.

Thanks!

ccordoba12 commented 3 years ago

Hey @sntgluca, thanks for reporting. We don't have an option for that and we don't have plans to add one.

I think it's simpler for editors/IDEs to decide if they want to show/hide those methods.

sntgluca commented 3 years ago

Hi @ccordoba12 ,

thanks for clarifying your point of view. I am still unsure where the request belongs :)

krassowski commented 2 years ago

Hi @ccordoba12 I believe that LSP server is a good place to host this option (coming here from https://github.com/jupyter-lsp/jupyterlab-lsp/issues/685). It is what jedi-language-server does: https://github.com/pappasam/jedi-language-server/issues/168 and it makes more sense to allow users to enable it server-side because we get a performance bump this way (no need to transfer these completion items for methods which would not be displayed).

While things which touch a live interpreter (like Jupyter) and collate completions from both interpreter/kernel and LSP will want to have the filtering client-side too (https://github.com/jupyter-lsp/jupyterlab-lsp/issues/685), it makes sense to me to also have this on the LSP server side.

I propose to re-open this with "contributions welcome" label - this is if anyone wants to implement it and will commits to support such feature we would accept a PR. What do you think?

ccordoba12 commented 2 years ago

Good idea @krassowski! The implementation seems really simple, at least according to what Jedi-language-server is doing, so I'll try to do the same here for our next release.

One question for you is: should we hide dunder methods by default?

krassowski commented 2 years ago

No strong opinion. I think it would be fine to hide them on say obj.<tab> but I would expect to see them if I press tab after an underscode or two (obj._<tab> or obj.__<tab>); I thing we could have this as three options: 'hide', 'show', 'auto' and the one described which checks if there is _ would be 'auto' and enabled by default - what do you think?

ccordoba12 commented 2 years ago

Sounds good to me, thanks for the feedback.