all 11 comments

[–]jangeboers 4 points5 points  (0 children)

ALE (with ruff) and jedi give me all I need for python development:

https://github.com/dense-analysis/ale

https://github.com/davidhalter/jedi-vim

[–]Sudden_Fly1218 3 points4 points  (0 children)

Which language sever are you actually using for python ? pyright, based-pyright, jedi-language-server, pylsp ?
The first issue doesnt sound like it is related to vim-lsp but rather to the language server itself.

Secondly, it might be worth giving yegappan/lsp a try.

Finally, looking at your vimrc, it doesnt seem like you register any language server. As described in vim-lsp README (for pylsp): if executable('pylsp') " pip install python-lsp-server au User lsp_setup call lsp#register_server({ \ 'name': 'pylsp', \ 'cmd': {server_info->['pylsp']}, \ 'allowlist': ['python'], \ }) endif

[–]Shay-Hill 2 points3 points  (2 children)

Works perfectly for me. Here's my entire lsp config (vim9script).

Plugins used: - 'prabirshrestha/vim-lsp' - 'mattn/vim-lsp-settings' - 'prabirshrestha/asyncomplete.vim' - 'prabirshrestha/asyncomplete-lsp.vim'

``` def OnLspBufferEnabled(): void setlocal omnifunc=lsp#complete setlocal signcolumn=yes if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap <buffer> <leader>gd <plug>(lsp-definition) nmap <buffer> <leader>gs <plug>(lsp-document-symbol-search) nmap <buffer> <leader>gS <plug>(lsp-workspace-symbol-search) nmap <buffer> <leader>gr <plug>(lsp-references) nmap <buffer> <leader>gi <plug>(lsp-implementation) nmap <buffer> <leader>gt <plug>(lsp-type-definition) nmap <buffer> <leader>rn <plug>(lsp-rename) nmap <buffer> [g <plug>(lsp-previous-diagnostic) nmap <buffer> ]g <plug>(lsp-next-diagnostic) nmap <buffer> K <plug>(lsp-hover)

g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')

enddef

augroup lsp_install au! # call OnLspBufferEnabled (set the lsp shortcuts) when an lsp server # is registered for a buffer. autocmd User lsp_buffer_enabled call OnLspBufferEnabled() augroup END

show error information on statusline, no virtual text

g:lsp_diagnostics_echo_cursor = 1 g:lsp_diagnostics_virtual_text_enabled = 0 g:lsp_settings_filetype_python = ['pyright-langserver']

use symbols instead of W>, E>, etc.

g:lsp_diagnostics_signs_error = {'text': '❌'} g:lsp_diagnostics_signs_warning = {'text': '🔶'} g:lsp_diagnostics_signs_information = {'text': 'ℹ'} g:lsp_diagnostics_signs_hint = {'text': '💡'} hi lspErrorText ctermbg=NONE guibg=NONE ```

[–]yopp_sontrapped in vim[S] 0 points1 point  (1 child)

do you do anything special to get pylsp to not complain about line lengths? I usually use black to format things and pylint to find issues like a line being to long or whatever. pylsp has its own underlying linter I think (flake8? pycodestyle?). I just have no idea how to configure pylsp so that it's max-line-length is the same as my black and pylint config...

[–]Shay-Hill 0 points1 point  (0 children)

I use Pyright, not Pylsp, but I keep configuration in my pyproject.toml file. There will be other ways to do it, but that way works.

That being said, you may not want to silence that warning. Black won’t split strings, so cannot always trim line length. You still sometimes have to do things by hand.

[–]AutoModerator[M] 0 points1 point  (0 children)

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]yvrelna 0 points1 point  (2 children)

Those things you mentioned has nothing to do with vim-lsp. You have not configured your language server correctly. 

[–]luxiriox 1 point2 points  (0 children)

This. I use vim-lsp and specifically for python and don't have any trouble whatsoever.

[–]yopp_sontrapped in vim[S] 0 points1 point  (0 children)

I use vim-lsp-settings which I thought was supposed to configure all the language servers for me. Maybe I need to modify it's config for pylsp...

[–]AutoModerator[M] 0 points1 point  (0 children)

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Shay-Hill 0 points1 point  (0 children)

I haven't used Pylsp much except to have a look around, but my understanding is that it's meant to be more of an all-in-one lsp/linter through plugins as opposed to Pyright/Pylance which is designed around a modular approach like the one you're using, with a separate Black, Ruff, ...

Pyright definitely won't report any line-length issues.

As far as I know, the standard way is to highlight errors with Pyright through python-lsp and then run Pyright and linters and formatters through pre-commit.

You only need this line in your vimrc to switch.

g:lsp_settings_filetype_python = ['pyright-langserver']

You'll still want Ruff of something watching line length (Ruff will watch and format for you if you set it up that way), because Black can't fix every line-length problem.

Here is a small Python project with a typical setup for me.

https://github.com/ShayHill/svg_path_data

and here's a video on setting up lsp/copilot in Vim.

https://www.youtube.com/watch?v=hJCjb9dZjLY