TechWithGeek · 2022-08-11 14:02
Hi there,
Currently, I'm updating my emacs config and trying to install a language server to python language.
I did the following:
https://preview.redd.it/nuz6c2dta3h91.png?width=1920&format=png&auto=webp&s=53008de73f8266b2c124e7c251a301e5e89d1cfc
The connection to lsp is going fine but stupid errors always occur, check it:
​
https://preview.redd.it/431p0phzb3h91.png?width=1920&format=png&auto=webp&s=705ff7f71612f5f6ee5e9b3536539580e4b3a708
​
https://preview.redd.it/44ybwsk2c3h91.png?width=1920&format=png&auto=webp&s=a590b3270e3d0d5826612b3263ba020582e4d8a3
As you can see, now I have a error and it isn't displayed! Some one can help me with lsp config to use python??
​
Thanks by attention!
[deleted] · 2022-08-11 19:49
[deleted]
Only-Adhesiveness889 · 2022-08-11 21:06
Whal lsp server are you using? Did you install one? Habe you checked M-x lsp-doctor?
TunaCowboy · 2022-08-11 22:07
I don't know what linter you're using, but this snippet should get you started with `pylint`, `autopep8`, `flycheck`, and `company`:
(defun your-python-mode-hook()
"Python."
(flycheck-add-next-checker 'lsp 'python-pylint)
(py-autopep8-enable-on-save))
(add-hook 'python-mode-hook 'lsp)
(add-hook 'python-mode-hook 'your-python-mode-hook)
(add-hook 'python-mode-hook
(lambda () (setq-local company-backends
'((company-capf
company-dabbrev-code
company-yasnippet)))))
That's not my actual config, but should be enough to get you started.
monad_in_disguise · 2022-08-12 02:48
well, the error appears valid, since you are breaking the linting rule [E748](https://www.flake8rules.com/rules/E741.html)
the last error... dunno, it may not throw one yet since some linting may not apply till the code will parse to some degree... otherwise you would get constant errors while just typing.
that said, I echo what the others say, ensure you have the proper LSP server setup and configure your project properly as most python LSP servers have some degree of opinionated linting or format enforcement via flake8 or black or whatnot
TechWithGeek · 2022-08-12 22:07
hmm thaks you very much for your attention!
I understand these warnings are not bugs, but are good practice warnings.
Can you recommend some lsp to python?
TechWithGeek · 2022-08-12 22:14
Great! Thanks for your time.
I'm using flymake. Actually I would like to have a simple lsp to c/c++ and python languages. After that, I will set up the 'lsp-mode' package.
TechWithGeek · 2022-08-12 22:16
I'm using lsp-mode... and the result of lsp-doctor is:
monad_in_disguise · 2022-08-13 12:12
ive had good results with [pyright](https://emacs-lsp.github.io/lsp-pyright/) as well as [pylsp](https://emacs-lsp.github.io/lsp-mode/page/lsp-pylsp/).
TechWithGeek · 2022-08-14 17:31
thanks a lot!
monad_in_disguise · 2022-08-14 18:50
welcome :)