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
.
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 arequirements.txt
file.nvim file.py
. Related to your hint I find this. It seems I have to created a proper python project?requirements.txt
file next to yourfile.py
does it solve your problem?