Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Auto-completion Setup #2293

Closed
childishPT opened this issue Apr 26, 2022 · 10 comments
Closed

Python Auto-completion Setup #2293

childishPT opened this issue Apr 26, 2022 · 10 comments

Comments

@childishPT
Copy link

Sorry, completely new to this editor, and with the lack of videos on this fairly new text editor, I require some step by step and clear help on how to setup up Python Auto-completion on Mac M1 for Helix text editor. I tried copying from the repo area, but this led to nothing. Also, am I missing a command that I should type to toggle Auto-completion?

Thank you very much, and I look forward to using this text editor and being one of the first few people to get onto this!

@the-mikedavis
Copy link
Member

If you haven't already, you'll need to install the python language server pylsp: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers#pylsp

With that installed, auto-complete and other language server driven features like goto-definition should work without any extra configuration or commands.

@childishPT
Copy link
Author

If you haven't already, you'll need to install the python language server pylsp: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers#pylsp

With that installed, auto-complete and other language server driven features like goto-definition should work without any extra configuration or commands.

Thank you very much, that worked, is there anyway to fix error : W191, indentation contains tab

@the-mikedavis
Copy link
Member

I'm not too familiar with python but I think it comes from this PEP https://peps.python.org/pep-0008/#tabs-or-spaces

Seems like the language server wants you to use spaces for indentation instead of tabs.

@childishPT
Copy link
Author

I'm not too familiar with python but I think it comes from this PEP https://peps.python.org/pep-0008/#tabs-or-spaces

Seems like the language server wants you to use spaces for indentation instead of tabs.

Is there any way I can turn off the error messages, there are so many (E303, W141, my whole code is just underlined) if so how do I do it, because the tutorial given by the website "https://github.com/python-lsp/python-lsp-server" is not very clear, and I was unable to find a file called pycodestyle in my configs.

@the-mikedavis
Copy link
Member

Oh hmm, I'm not sure how configurable pylsp is for turning those of or tuning them. As far as I know, there isn't an option within Helix to disable diagnostics.

@tmke8
Copy link

tmke8 commented Apr 27, 2022

If possible, I would recommend you use pyright instead of pylsp if you don't care about the linters. Pyright is much better in terms of autocompletion and correctness checks, but it doesn't have any style linting or code formatting (which you seem to not want anyway).

If you have node.js installed, you can install pyright globally with

sudo npm install -g pyright@latest

But there is also a wrapper package on pypi: https://pypi.org/project/pyright/ which I believe installs a per-project node.js.

Then set up pyright like this:

 [[language]]
 name = "python"
 scope = "source.python"
 injection-regex = "python"
 file-types = ["py"]
 shebangs = ["python"]
 roots = ["pyproject.toml", "setup.py", "Poetry.lock"]
 comment-token = "#"
 language-server = { command = "pyright-langserver", args = ["--stdio"] }
 auto-format = false
 indent = { tab-width = 4, unit = "    " }
 config = {}

You need to specify config (even if empty) because of this unresolved issue: #1898 . And you also need to build from master – not the recent release – because of that same issue.

@lukepighetti
Copy link

lukepighetti commented Apr 27, 2022

In the world of python it's up to you to select the correct LSP for your needs, helix merely displays the results from your LSP.

This is not true in all languages. Dart, for example, works with Helix without any configuration. Install dart, install helix, it's working. The zero-conf nature in this case is due to Dart coming prepackaged with a configured LSP.

@childishPT
Copy link
Author

childishPT commented Apr 27, 2022

Put the exact same thing inside my languages.toml and I still got the error:
thread 'main' panicked at 'Failed to parse WorkspaceConfiguration params: Error { code: InvalidParams, message: "Invalid params: invalid value: string \"\", expected relative URL without a base.", data: None }', helix-lsp/src/lib.rs:216:22 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Is there something wrong I am doing here?

@childishPT
Copy link
Author

In the world of python it's up to you to select the correct LSP for your needs, helix merely displays the results from your LSP.

This is not true in all languages. Dart, for example, works with Helix without any configuration. Install dart, install helix, it's working. The zero-conf nature in this case is due to Dart coming prepackaged with a configured LSP.

Yes, I would like to learn more as I am yet just a beginner, a newborn coming out of the computers womb, searching merely for just answers that cannot be obtained oh so easily

@paul-scott
Copy link
Contributor

@The-Rivers see #1898 for a possible work-around for your crash.

@kirawi kirawi converted this issue into discussion #4689 Nov 10, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants