0

How to attach the lsp-client properly? I installed Neovim v0.8.3 and nvim-lspconfig manually:

$ mkdir ~/.config/nvim/pack/plugins/start
$ git clone https://github.com/neovim/nvim-lspconfig.git ~/.config/nvim/pack/plugins/start/nvim-lspconfig

Then I opened ~/.config/nvim/init.vim, run :packadd lsp-config and add the following line to the file:

lua require('lspconfig').pylsp.setup{cmd = {"pylsp", "--tcp", "--port", "2087"}}   

After creating project

~/pythonProjects/helloworld$ python3 -m project_cli -y
~/pythonProjects/helloworld$ pipreqs ./    
~/pythonProjects/helloworld$ find | sed 's|[^/]*/|- |g'
.
- setup.py
- README.rst
- helloworld
- - __init__.py
- - __main__.py
- requirements.txt
- tests
- - __init__.py
- - context.py
- - test_main.py

I start nvim helloworld/__main__.py and run :LspInfo:

Press q or <Esc> to close this window. Press <Tab> to view server doc.                                                                                 
                                                                                                                                                        
Language client log: /home/user/.local/state/nvim/lsp.log                                                                                         
Detected filetype:   python                                                                                                                            

0 client(s) attached to this buffer:                                                                                                                   

Other clients that match the filetype: python                                                                                                          

Config: pyright                                                                                                                                        
 filetypes:         python                                                                                                                             
 root directory:    /home/user/pythonProjects/helloworld                                                                                          
 cmd:               pylsp --tcp --port 2087                                                                                                            
 cmd is executable: true                                                                                                                               
 autostart:         true                                                                                                                               
 custom handlers:                                                                                                                                      
                                                                                                                                                            
 Configured servers list: pylsp

pgrep pylsp returns a process id, that indicates Neovim starts the language server. And there is no /home/user/.local/state/nvim/lsp.log created only a empty /home/user/.local/state/nvim/log.

7
  • 1
    I noticed root directory Not Found. What is the current working directory when the file is opened? Does the current working directory or one of its parent contains a .git folder or a requirements.txt file. Commented Apr 26, 2023 at 3:35
  • 1
    @VivianDeSmedt I noticed too, but don't give much attention, because for me it's unclear that this is part of minimal requirements. there is no specific working directory, it gets the working dir of my shell. I just create a test file in my home dir and opened it with nvim file.py. Related to your hint I find this. It seems I have to created a proper python project?
    – Hölderlin
    Commented Apr 26, 2023 at 14:42
  • 1
    If you add a requirements.txt file next to your file.py does it solve your problem? Commented Apr 26, 2023 at 14:49
  • 1
    @VivianDeSmedt please find my edits above. I created a python project and a requirements.txt inside the project but no client attached.
    – Hölderlin
    Commented Apr 28, 2023 at 12:56
  • 1
    Do you have client for the server like nvim-cmp for completion of null-ls for fomating? Commented Apr 28, 2023 at 13:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.