Git Product home page Git Product logo

Comments (18)

marcdeop avatar marcdeop commented on May 25, 2024 3

I know the issue is closed but I took the liberty of adding documentation here

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

This assumes you have already run these steps composer install and composer run-script parse-stub.

au User lsp_setup call lsp#register_server({
    \ 'name': 'php',
    \ 'cmd': {server_info->['php', expand('~/.vim/bundle/php-language-server/bin/php-language-server.php')]},
    \ 'whitelist': ['php'],
    \ })

expand() will make sure the path is absolute path. I'm not sure if php can handled ~/ paths.

if executable('php') is not needed but you can add it if you want.

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

Also you shouldn't be doing this actually Plugin 'felixfbecker/php-language-server' since it is not a vim plugin. But in this case it works.

from vim-lsp.

davidsierradz avatar davidsierradz commented on May 25, 2024

It does not seems to work, this is my settings in .vimrc

let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/vim-lsp.log')
au User lsp_setup call lsp#register_server({
    \ 'name': 'php',
    \ 'cmd': {server_info->['php', expand('/home/neuromante/.vim/bundle/php-language-server/bin/php-language-server.php')]},
    \ 'whitelist': ['php'],
    \ })
autocmd FileType php setlocal omnifunc=lsp#complete

when I open a php file, the log shows:

Sun 27 Aug 2017 01:41:13 PM -05:["lsp#register_server","server registered","php"]

Sun 27 Aug 2017 01:41:13 PM -05:["s:on_text_document_did_open()",1]

Sun 27 Aug 2017 01:41:37 PM -05:["s:on_text_document_did_close()",1]

Sun 27 Aug 2017 01:41:37 PM -05:["s:on_text_document_did_open()",2]

Sun 27 Aug 2017 01:41:37 PM -05:[{"response":{"data":{"__data__":"vim-lsp","lsp_id":1,"server_name":"php"},"message":"started lsp server successfully"}}]

Sun 27 Aug 2017 01:41:37 PM -05:["--->",1,"php",{"method":"initialize","params":{"rootUri":"file:///home/neuromante","capabilities":{},"rootPath":"file:///home/neuromante"}}]
Sun 27 Aug 2017 01:41:39 PM -05:["<---",1,"php",{"response":{"id":1,"jsonrpc":"2.0","error":{"data":null,"code":-32603,"message":"ErrorException: file_get_contents(file:\\\\\\home\\neuromante\\Code\\quarx\\composer.json): failed to open stream: No such file or directory in /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php:22\nStack trace:\n#0 [internal function]: {closure}(2, 'file_get_conten...', '/home/neuromant...', 22, Array)\n#1 /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php(22): file_get_contents('file:\\\\\\\\\\\\home\\\\ne...')\n#2 /home/neuromante/.vim/bundle/php-language-server/src/LanguageServer.php(207): LanguageServer\\ContentRetriever\\FileSystemContentRetriever->retrieve('file:///file://...')\n#3 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#4 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/coroutine.php(70): Generator->send(Array)\n#5 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Promise.php(242): Sabre\\Event\\{closure}(Array)\n#6 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\\Event\\Promise->Sabre\\Event\\{closure}()\n#7 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\\Event\\Loop\\Loop->runNextTicks()\n#8 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\\Event\\Loop\\Loop->tick(true)\n#9 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\\Event\\Loop\\Loop->run()\n#10 /home/neuromante/.vim/bundle/php-language-server/bin/php-language-server.php(102): Sabre\\Event\\Loop\\run()\n#11 {main}"}},"request":{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"rootUri":"file:///home/neuromante","capabilities":{},"rootPath":"file:///home/neuromante"}}}]

If I try to invoke omni-completion with <C-x C-o> it writes in the command line Pattern not found

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

Make sure to set ominfunc.

autocmd FileType php setlocal omnifunc=lsp#complete

I added more info in the log. Can you try getting the latest and paste the new logs? I'm interested in :echo getcwd() and the file path you are editing. I have vim plugins that autoset the cwd to the root of my git repo so it usually plays good with other plugins too.

Does your php project include composer.json? Glancing at the exception and source code I see that the lang server depends on it. https://github.com/felixfbecker/php-language-server/blob/42d0c7b714f91d272207380737eb075ee2d46b8a/src/LanguageServer.php#L201.

If it does depend on composer.json you can add root_uri. But this means if the file doesn't exist it will only start the server but send the initialize request to the server. If you do this then it should correctly work without setting the cwd correctly.

au User lsp_setup call lsp#register_server({
    \ 'name': 'php',
    \ 'cmd': {server_info->['php', expand('~/.vim/bundle/php-language-server/bin/php-language-server.php')]},
    \ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'composer.json'))},
    \ 'whitelist': ['php'],
    \ })

Currently it is sending rootUri as to the lang server. "rootUri":"file:///home/neuromante" which to me seems like your home directory instead of the project directory. If you don't specify root_uri when registering the server it will use getcwd().

from vim-lsp.

davidsierradz avatar davidsierradz commented on May 25, 2024

Still no luck, I added the root_uri parameter in the vimrc, set the cwd to the root of the project and also checked the existence of the composer.json file (it exist, is a Laravel project), this is the new log file content:

Sun 27 Aug 2017 02:55:42 PM -05:["lsp#register_server","server registered","php"]
Sun 27 Aug 2017 02:55:42 PM -05:["s:on_text_document_did_open()",1,"startify","/home/neuromante","file:///home/neuromante/Startify"]
Sun 27 Aug 2017 02:55:46 PM -05:["s:on_text_document_did_close()",1]
Sun 27 Aug 2017 02:55:46 PM -05:["s:on_text_document_did_open()",2,"php","/home/neuromante","file:///home/neuromante/Code/Forum/tests/Feature/ParticipateInForumTest.php"]
Sun 27 Aug 2017 02:55:46 PM -05:[{"response":{"data":{"__data__":"vim-lsp","lsp_id":1,"server_name":"php"},"message":"started lsp server successfully"}}]
Sun 27 Aug 2017 02:55:46 PM -05:["--->",1,"php",{"method":"initialize","params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}]
Sun 27 Aug 2017 02:55:46 PM -05:["<---",1,"php",{"response":{"id":1,"jsonrpc":"2.0","error":{"data":null,"code":-32603,"message":"ErrorException: file_get_contents(file:\\\\\\home\\neuromante\\Code\\Forum\\composer.json): failed to open stream: No such file or directory in /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php:22\nStack trace:\n#0 [internal function]: {closure}(2, 'file_get_conten...', '/home/neuromant...', 22, Array)\n#1 /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php(22): file_get_contents('file:\\\\\\\\\\\\home\\\\ne...')\n#2 /home/neuromante/.vim/bundle/php-language-server/src/LanguageServer.php(207): LanguageServer\\ContentRetriever\\FileSystemContentRetriever->retrieve('file:///file://...')\n#3 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#4 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/coroutine.php(70): Generator->send(Array)\n#5 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Promise.php(242): Sabre\\Event\\{closure}(Array)\n#6 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\\Event\\Promise->Sabre\\Event\\{closure}()\n#7 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\\Event\\Loop\\Loop->runNextTicks()\n#8 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\\Event\\Loop\\Loop->tick(true)\n#9 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\\Event\\Loop\\Loop->run()\n#10 /home/neuromante/.vim/bundle/php-language-server/bin/php-language-server.php(102): Sabre\\Event\\Loop\\run()\n#11 {main}"}},"request":{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}}]
Sun 27 Aug 2017 02:56:09 PM -05:["s:on_text_document_did_change()",2]
Sun 27 Aug 2017 02:56:09 PM -05:[{"response":{"data":{"__data__":"vim-lsp","server_name":"php"},"message":"server already started"}}]
Sun 27 Aug 2017 02:56:09 PM -05:["--->",1,"php",{"method":"initialize","params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}]
Sun 27 Aug 2017 02:56:09 PM -05:["<---",1,"php",{"response":{"id":2,"jsonrpc":"2.0","error":{"data":null,"code":-32603,"message":"ErrorException: file_get_contents(file:\\\\\\home\\neuromante\\Code\\Forum\\composer.json): failed to open stream: No such file or directory in /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php:22\nStack trace:\n#0 [internal function]: {closure}(2, 'file_get_conten...', '/home/neuromant...', 22, Array)\n#1 /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php(22): file_get_contents('file:\\\\\\\\\\\\home\\\\ne...')\n#2 /home/neuromante/.vim/bundle/php-language-server/src/LanguageServer.php(207): LanguageServer\\ContentRetriever\\FileSystemContentRetriever->retrieve('file:///file://...')\n#3 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#4 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/coroutine.php(70): Generator->send(Array)\n#5 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Promise.php(242): Sabre\\Event\\{closure}(Array)\n#6 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\\Event\\Promise->Sabre\\Event\\{closure}()\n#7 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\\Event\\Loop\\Loop->runNextTicks()\n#8 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\\Event\\Loop\\Loop->tick(true)\n#9 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\\Event\\Loop\\Loop->run()\n#10 /home/neuromante/.vim/bundle/php-language-server/bin/php-language-server.php(102): Sabre\\Event\\Loop\\run()\n#11 {main}"}},"request":{"method":"initialize","jsonrpc":"2.0","id":2,"params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}}]
Sun 27 Aug 2017 02:56:10 PM -05:["s:on_text_document_did_change()",2]
Sun 27 Aug 2017 02:56:10 PM -05:[{"response":{"data":{"__data__":"vim-lsp","server_name":"php"},"message":"server already started"}}]
Sun 27 Aug 2017 02:56:10 PM -05:["--->",1,"php",{"method":"initialize","params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}]
Sun 27 Aug 2017 02:56:10 PM -05:["<---",1,"php",{"response":{"id":3,"jsonrpc":"2.0","error":{"data":null,"code":-32603,"message":"ErrorException: file_get_contents(file:\\\\\\home\\neuromante\\Code\\Forum\\composer.json): failed to open stream: No such file or directory in /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php:22\nStack trace:\n#0 [internal function]: {closure}(2, 'file_get_conten...', '/home/neuromant...', 22, Array)\n#1 /home/neuromante/.vim/bundle/php-language-server/src/ContentRetriever/FileSystemContentRetriever.php(22): file_get_contents('file:\\\\\\\\\\\\home\\\\ne...')\n#2 /home/neuromante/.vim/bundle/php-language-server/src/LanguageServer.php(207): LanguageServer\\ContentRetriever\\FileSystemContentRetriever->retrieve('file:///file://...')\n#3 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#4 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/coroutine.php(70): Generator->send(Array)\n#5 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Promise.php(242): Sabre\\Event\\{closure}(Array)\n#6 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\\Event\\Promise->Sabre\\Event\\{closure}()\n#7 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\\Event\\Loop\\Loop->runNextTicks()\n#8 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\\Event\\Loop\\Loop->tick(true)\n#9 /home/neuromante/.vim/bundle/php-language-server/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\\Event\\Loop\\Loop->run()\n#10 /home/neuromante/.vim/bundle/php-language-server/bin/php-language-server.php(102): Sabre\\Event\\Loop\\run()\n#11 {main}"}},"request":{"method":"initialize","jsonrpc":"2.0","id":3,"params":{"rootUri":"file:///home/neuromante/Code/Forum","capabilities":{},"rootPath":"file:///home/neuromante/Code/Forum"}}}]
Sun 27 Aug 2017 03:01:40 PM -05:["s:on_text_document_did_close()",2]
Sun 27 Aug 2017 03:01:40 PM -05:["s:on_text_document_did_close()",4]
Sun 27 Aug 2017 03:01:41 PM -05:["s:on_text_document_did_close()",5]
Sun 27 Aug 2017 03:01:45 PM -05:["s:on_text_document_did_close()",6]
Sun 27 Aug 2017 03:01:45 PM -05:["s:on_text_document_did_open()",7,"json","/home/neuromante/Code/Forum","file:///home/neuromante/Code/Forum/composer.json"]
Sun 27 Aug 2017 03:04:58 PM -05:["s:on_text_document_did_open()",8,"help","/home/neuromante/Code/Forum","file:///usr/share/vim/vim80/doc/eval.txt"]
Sun 27 Aug 2017 03:05:12 PM -05:["s:on_text_document_did_close()",8]
Sun 27 Aug 2017 03:05:12 PM -05:["s:on_text_document_did_open()",9,"help","/home/neuromante/Code/Forum","file:///usr/share/vim/vim80/doc/editing.txt"]
Sun 27 Aug 2017 03:05:29 PM -05:["s:on_text_document_did_close()",9]

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

Seems to me more like the Lang server bug. Might be file an issuer there instead?

from vim-lsp.

wysiecki avatar wysiecki commented on May 25, 2024

hi, i'm very inetrrested in this too, any progress ?

thx

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

@wysiecki can you post your log. Currently I'm waiting for @davidsierradz to file a bug on the php lang server.

from vim-lsp.

davidsierradz avatar davidsierradz commented on May 25, 2024

Right now Im super busy with work so no advances in this regard, currently using Neovim with autozimu/LanguageClient-neovim and roxma/LanguageServer-php-neovim and the PHP server is working fine.

from vim-lsp.

tsufeki avatar tsufeki commented on May 25, 2024

Hi, I think the problem comes from incorrectly setting rootPath in initialize method to the same value as rootUri - rootPath is a plain path, not an URI (compare the types in https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize-request). This confuses php-language-server.

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

@tsufeki does php support rootUri since rootPath is deprecated? langserver-go requires rootPath to start with file:// that was why I set it.
Either php language server should support file://.. or vim-lsp should have option to use uri for rootPath.

Might be ping the php lang server first?

from vim-lsp.

tsufeki avatar tsufeki commented on May 25, 2024

@prabirshrestha php server ignores rootUri. However, quick look through go server source code suggests it does not require an URI in rootPath (at least not anymore?) - see for example https://github.com/sourcegraph/go-langserver/blob/master/pkg/lsp/service.go#L27

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

@tsufeki @davidsierradz I pushed root-path branch that doesn't use uri for rootPath. Can you verify if this works for php and go?

If you are using vim-plug you can try Plug 'prabirshrestha/vim-lsp', { 'branch': 'root-path' }. Fix can be found at 0f11222

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

I verified for go lang server and it seems to work so will merge it. Please let me know if it fixes php lang server.

from vim-lsp.

tsufeki avatar tsufeki commented on May 25, 2024

@prabirshrestha php server works ok for me, thanks.

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

@tsufeki thanks for verifying. Would it be possible to add some docs here for php? https://github.com/prabirshrestha/vim-lsp/wiki/Servers

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 25, 2024

@marcdeop thanks for adding the docs!

from vim-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.