espace

is it someone who success to implement tern-phaser with vim ?

Recommended Posts

yes thanks i follow each steps (this is good write) and it work, expect one feature that i believe it was possible :

When i'm typing

game.add.sprite("C-j"

i hope that :

game.add.sprite(game, x, y, key, frame)

but it do nothing ...is it possible on your computer ?

Share this post


Link to post
Share on other sites

if you are coding all the javascript/ phaser inside main html file and want phaser auto-completion then,

in vim,

:set ft=javascript      (to switch back   :set ft=html)

**this will allow you to list the .js plugin in current working file

//for handling further bug on phaser auto-completion with vim//

http://redchilligame.com/how_to_use_phaser_with_vim

Share this post


Link to post
Share on other sites

i set ft= javascript

problem is still present, when i autocomplete this

game.add.sprite

i have no this:

game.add.sprite(game, x, y, key, frame)

and when i run :ternDef on sprite i have this error:

Failed to start server:                                                                                                                                                                                                                                                                   
/home/espace/game/phaser.js:21763                                                                                                                                                                                                                                    
    PIXI: PIXI || {},                                                                                                                                                                                                                                                                     
          ^                                                                                                                                                                                                                                                                               
ReferenceError: PIXI is not defined                                                                                                                                                                                                                                                       
    at Object.<anonymous> (/home/espace/game/phaser.js:21763:11)                                                                                                                                                                                                     
    at Object.<anonymous> (/home/espace/game/phaser.js:105605:4)                                                                                                                                                                                                     
    at Module._compile (module.js:409:26)                                                                                                                                                                                                                                                 
    at Object.Module._extensions..js (module.js:416:10)                                                                                                                                                                                                                                   
    at Module.load (module.js:343:32)                                                                                                                                                                                                                                                     
    at Function.Module._load (module.js:300:12)                                                                                                                                                                                                                                           
    at Module.require (module.js:353:17)                                                                                                                                                                                                                                                  
    at require (internal/module.js:12:17)                                                                                                                                                                                                                                                 
    at loadPlugins (/home/espace/.vim/plugged/tern_for_vim/node_modules/tern/bin/tern:136:15)                                                                                                                                                                                               
    at startServer (/home/espace/.vim/plugged/tern_for_vim/node_modules/tern/bin/tern:174:17) 

an idea ?

Share this post


Link to post
Share on other sites

if you followed all the steps correctly for setting vim with phaser in http://redchilligame.com/how_to_use_phaser_with_vim

then, there shouldn't be any problem.(if the steps are correct).

if the phaser auto completion plugin is installed in correct dir. then , its not necessary to type :TernDef (vim will auto display TernDef panel at bottom/top ).

according to error you have posted::

at loadPlugins (/home/espace/.vim/plugged/tern_for_vim/node_modules/tern/bin/tern:136:15)

the phaser auto completion directory folder is mismatched when calling:: set it to  ../tern_for_vim/node_modules/tern/plugin/..

if set correctly you will see :: (ref: pic below)

vim_phaser_sprite.png

Share this post


Link to post
Share on other sites

hi,

i have create a new user and reinstall all vim with tern and now an another error. it seems that the server won't launch.

Failed to start server:                                                                                                                     
/home/user/game/phaser.js:16034                                                                                              
                canvas: document.createElement('canvas')                                                                                    
                        ^                                                                                                                   
ReferenceError: document is not defined  

have you an idea ?

Share this post


Link to post
Share on other sites

I think ,

you might have missed some steps for configuration phaser with vim  in http://redchilligame.com/how_to_use_phaser_with_vim

- according to the error you have posted::

/home/user/game/phaser.js:16034

tern is pointing to wrong api plugin

check this steps::

1] if linux::  install tern inside tern_for_vim folder using sudo npm install tern

     if windows::  if you use "neocomplete" instead of "youcompleteme"  check if vim is compiled with +lua

2] you have correctly downloaded and copied phaser.js auto-completion api to the ..tern/plugin/ folder (*** note::  the  official phaser.js  != to phaser.js auto-complete api , they are two different entities :: one is framework another is auto-completer)

*** download and copy the phaser.js auto-complete api (**not the official phaser.js ) from [point no.4]  of the link provided in http://redchilligame.com/how_to_use_phaser_with_vim

--this will solve most of the problem.

3] there is ".tern-project" - root of dir.

-- and tell me if that works (vim + phaser rocks) " happy coding"

 

Share this post


Link to post
Share on other sites

hi,

thanks to keep time to solve this.

i read and re-read your explanation and all you have described is done. I describe this :

sudo apt-get install vim 
//node => ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo apt-get install -y build-essential

install neocomplete

install tern_for_vim

cd .vim/plugged/tern_for_vim 
sudo npm install tern
cd node_modules/tern/plugin/

copy phaser.js from http://redchilligame.com/tutorials/vim_phaser/js/phaser.js 

inside this directory : vim/plugged/tern_for_vim /node_modules/tern/plugin

cd && cd mygame && vim .tern-project

copy paste this inside and save

{
"ecmaVersion": 6,
"libs": ["browser"],
"loadEagerly": [],

"plugins": {
"phaser" : {},
"doc_comment": true
}
}

in vim

:set ft=javascript

when i run :TerndeffPreview this error :

Failed to start server:                                                                                                                                                                                                                                                                                                     
/home/bertrand/mygame/phaser.js:21763                                                                                                                                                                                                                                                                          
    PIXI: PIXI || {},                                                                                                                                                                                                                                                                                                       
          ^                                                                                                                                                                                                                                                                                                                 
ReferenceError: PIXI is not defined                                                                                                                                                                                                                                                                                         
    at Object.<anonymous> (/home/bertrand/mygame/phaser.js:21763:11)                                                                                                                                                                                                                                           
    at Object.<anonymous> (/home/bertrand/mygame/phaser.js:105605:4)                                                                                                                                                                                                                                           
    at Module._compile (module.js:409:26)                                                                                                                                                                                                                                                                                   
    at Object.Module._extensions..js (module.js:416:10)                                                                                                                                                                                                                                                                     
    at Module.load (module.js:343:32)                                                                                                                                                                                                                                                                                       
    at Function.Module._load (module.js:300:12)                                                                                                                                                                                                                                                                             
    at Module.require (module.js:353:17)                                                                                                                                                                                                                                                                                    
    at require (internal/module.js:12:17)                                                                                                                                                                                                                                                                                   
    at loadPlugins (/home/bertrand/.vim/plugged/tern_for_vim/node_modules/tern/bin/tern:136:15)                                                                                                                                                                                                                             
    at startServer (/home/bertrand/.vim/plugged/tern_for_vim/node_modules/tern/bin/tern:174:17) 

 

Share this post


Link to post
Share on other sites

(vim + phaser rocks)

so as per your steps,

all the installation steps are correct in reference to http://redchilligame.com/how_to_use_phaser_with_vim .
its the problem with the tern_for_vim configuration
since you are using vim-plug "plugin manager" (there's no error/problem with the vundle vim "plugin manager").
do any of the following steps::
reference::
https://github.com/ternjs/tern_for_vim/blob/master/autoload/tern.vim

1] goto you tern_for_vim folder  ..autoload/tern.vim line 15
since Ubuntu; change node --> "nodejs"
 let g:tern#command = ["node", expand('<sfile>:h') . '/../node_modules/tern/bin/tern', '--no-port-file']
to
 let g:tern#command = ["nodejs", expand('<sfile>:h') . '/../node_modules/tern/bin/tern', '--no-port-file']

OR (if the above steps doesn't work then,)

let g:tern#command = ['tern']

OR (if the above steps doesn't work then,)
let g:tern#command = [ '${pkgs.nodePackages.tern}/bin/tern' ]

2]vim-plug configuration::
in vimrc::
call plug#begin('~/.vim/plugged')

change  ~  to $HOME  ("its equivalent actually but, give it a try")

3] check if python is installed/or not

4] use vundle vim "plugin manager"
if it still doesn't work in vundle,
in vimrc::
change  ~  to  $HOME
set rtp+=~/.vim/bundle/Vundle.vim
and add this,
call vundle#begin('$HOME/.vim/bundle/')

-->hope this helps 

Share this post


Link to post
Share on other sites

hi,

i have follow each steps and always the same error. just for this :

let g:tern#command = ['tern'] i have another error who say no module find ....

did you success to implement this feature  on ubuntu ? i would try on windows to check but i don't have the time now.

i have also try with tern-phaser but it seems that the project is not update... https://github.com/angelozerr/tern-phaser

 

Share this post


Link to post
Share on other sites

i saw also this :

https://github.com/photonstorm/phaser/issues/2998

but i don't know really how to implement this.

Where must i put this (index.html, phaser.js, phaser.js autocomplete ???):

window.PIXI = require('phaser/build/custom/pixi')
window.p2 = require('phaser/build/custom/p2')
window.Phaser = require('phaser/build/custom/phaser-split')

 

Share this post


Link to post
Share on other sites

Just to be sure,

I have tested in all platform as described in http://redchilligame.com/how_to_use_phaser_with_vim
 and it works very well (100/100 %).
recheck::
-> python(2,3) ?
-> in home dir::
   place..
   ->.vimrc/_vimrc(win)
   ->.vim
      ->bundle
         ->tern_for_vim
           ->node_modules .../plugin/

--> give it a try with vundle plugin manager
--> re-check your vimrc file(path/calling..) and folder location once.
--> install all the requirement plugins for associative plugins see doc.

--> if all is set it will work (100/100 %)

keep trying (VIM + PHASER ROCKS!!)

Test result with tern plug both in gvim/vim::
phaser with vim in ubuntu [linux]::

phaser with vim in fedora [linux]::

phaser with vim in windows 10::

ubuntu_phasr_vim.png

fedora_vim_phaser.png

windows_vim_phaser.png

Share this post


Link to post
Share on other sites

yes !

finally i success with you big thanks :)

i have followed these steps:

install nodejs 8 and not 9

:set ft=javascript

:set omnifunc

disable neocomplete and press ctrl+x and ctrl+o after and tadam the same screen than you.

big big thanks !!!!!!!

Share this post


Link to post
Share on other sites

you can do everything in vim ("Old is Gold").

but if you want to use  nvim then,

for nvim (neovim) ;

put the phaser auto-completion api to ...tern/plugin/..

or main .npm  folder for global as described in http://redchilligame.com/how_to_use_phaser_with_vim

follow this links::

for using vimrc for nvim

https://github.com/neovim/neovim/wiki/FAQ

https://groups.google.com/forum/#!topic/neovim/Nuki1lAnZ04

for ternjs ::

https://github.com/carlitux/deoplete-ternjs

https://github.com/roxma/nvim-cm-tern

Share this post


Link to post
Share on other sites

damned i follow each step that you recommended and that don't works with nvim ! sorry to borry  you with this...but maybe if we find the correct solution you could put this tuto in your blog...

first i install neovim from source (ubuntu 16.04)

sudo apt-get install neovim

after write the init.vim in ~/.config/nvim/init.vim with vim-plug

default config with the plugins recommended =>

-deoplete.nvim

-deoplete-ternjs (required by deoplete.nvim)

-nvim-cm-tern

-tern_for_vim

my init.vim

set encoding=utf8
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set number
set clipboard=unnamedplus
set incsearch
set cursorline
set ignorecase
set wildignorecase
set autoindent
"" true color
set background=dark
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors

" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')

" keybinding
" Declare the list of plugins.
Plug 'Shougo/deoplete.nvim'
Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' }
Plug 'roxma/nvim-cm-tern',  {'do': 'npm install'}
Plug 'ternjs/tern_for_vim',  {'do': 'npm install'}

" List ends here. Plugins become visible to Vim after this call.
call plug#end()

after put the settings recommended by deoplete in the bottom of my init.vim :

https://github.com/carlitux/deoplete-ternjs#vim-configuration-example

" Whether to include the types of the completions in the result data. Default: 0
let g:deoplete#sources#ternjs#types = 1

" Whether to include the distance (in scopes for variables, in prototypes for 
" properties) between the completions and the origin position in the result 
" data. Default: 0
let g:deoplete#sources#ternjs#depths = 1

" Whether to include documentation strings (if found) in the result data.
" Default: 0
let g:deoplete#sources#ternjs#docs = 1

" When on, only completions that match the current word at the given point will
" be returned. Turn this off to get all results, so that you can filter on the 
" client side. Default: 1
/////previous nvim
////////////////////////////////////////////////

let g:deoplete#sources#ternjs#filter = 0

" Whether to use a case-insensitive compare between the current word and 
" potential completions. Default 0
let g:deoplete#sources#ternjs#case_insensitive = 1

" When completing a property and no completions are found, Tern will use some 
" heuristics to try and return some properties anyway. Set this to 0 to 
" turn that off. Default: 1
let g:deoplete#sources#ternjs#guess = 0

" Determines whether the result set will be sorted. Default: 1
let g:deoplete#sources#ternjs#sort = 0

" When disabled, only the text before the given position is considered part of 
" the word. When enabled (the default), the whole variable name that the cursor
" is on will be included. Default: 1
let g:deoplete#sources#ternjs#expand_word_forward = 0

" Whether to ignore the properties of Object.prototype unless they have been 
" spelled out by at least two characters. Default: 1
let g:deoplete#sources#ternjs#omit_object_prototype = 0

" Whether to include JavaScript keywords when completing something that is not 
" a property. Default: 0
let g:deoplete#sources#ternjs#include_keywords = 1

" If completions should be returned when inside a literal. Default: 1
let g:deoplete#sources#ternjs#in_literal = 0

"Add extra filetypes
let g:deoplete#sources#ternjs#filetypes = [
                \ 'jsx',
                \ 'javascript.jsx',
                \ 'vue',
                \ '...'
                \ ]

" Use tern_for_vim.
let g:tern#command = ["tern"]
let g:tern#arguments = ["--persistent"]

run

:PlugInstall

run npm

cd && sudo npm install -g tern
cd ~/.vim/plugged/nvim-cm-term && sudo npm install
cd ..
cd tern_for_vim && sudo npm install

copy the phaser auto completion in ~/.vim/plugged/tern_for_vim/nodes.....

make a .tern-project at the root directory of my game

{
"ecmaVersion": 6,
"libs": ["browser"],
"loadEagerly": [],

"plugins": {
"phaser" : {},
"doc_comment": true
}
}

and when i run :TernDeff on for example sprite same errot than my previous post :

Failed to start server:
/home/nvim/bubblexxx.github.io/phaser.js:21763
    PIXI: PIXI || {},
          ^
ReferenceError: PIXI is not defined
    at Object.<anonymous> (/home/nvim/bubblexxx.github.io/phaser.js:21763:11)
    at Object.<anonymous> (/home/nvim/bubblexxx.github.io/phaser.js:105605:4)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at loadPlugins (/usr/lib/node_modules/tern/bin/tern:136:15)

if you could resolve this you be my angel !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.