espace Posted November 28, 2017 Share Posted November 28, 2017 hi, i would use this feature. i follow the installation but that don't work https://github.com/ternjs/tern_for_vim honestly i don't know how to configure this...could you post your vimrc and .tern-project file if never ? and tell me more about that ? Link to comment Share on other sites More sharing options...
espace Posted November 30, 2017 Author Share Posted November 30, 2017 nobody use this ? Link to comment Share on other sites More sharing options...
espace Posted December 5, 2017 Author Share Posted December 5, 2017 really nobody ? Link to comment Share on other sites More sharing options...
DanielKlava Posted December 5, 2017 Share Posted December 5, 2017 Not exactly with Tern, but @speedo did a tutorial for Vim: espace 1 Link to comment Share on other sites More sharing options...
espace Posted December 7, 2017 Author Share Posted December 7, 2017 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 ? Link to comment Share on other sites More sharing options...
speedo Posted December 7, 2017 Share Posted December 7, 2017 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 Link to comment Share on other sites More sharing options...
espace Posted December 8, 2017 Author Share Posted December 8, 2017 No yet time to check this. I see it later and keep informed . Thanks. Link to comment Share on other sites More sharing options...
espace Posted December 9, 2017 Author Share Posted December 9, 2017 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 ? Link to comment Share on other sites More sharing options...
speedo Posted December 9, 2017 Share Posted December 9, 2017 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) Link to comment Share on other sites More sharing options...
espace Posted December 10, 2017 Author Share Posted December 10, 2017 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 ? Link to comment Share on other sites More sharing options...
speedo Posted December 10, 2017 Share Posted December 10, 2017 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" Link to comment Share on other sites More sharing options...
espace Posted December 11, 2017 Author Share Posted December 11, 2017 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) Link to comment Share on other sites More sharing options...
espace Posted December 11, 2017 Author Share Posted December 11, 2017 Maybe try at home if after downloading the phaser.js autocompleter api if you don't have the same problem than me ? (Maybe this file has changed since) Link to comment Share on other sites More sharing options...
speedo Posted December 11, 2017 Share Posted December 11, 2017 (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 Link to comment Share on other sites More sharing options...
espace Posted December 12, 2017 Author Share Posted December 12, 2017 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 Link to comment Share on other sites More sharing options...
espace Posted December 12, 2017 Author Share Posted December 12, 2017 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') Link to comment Share on other sites More sharing options...
speedo Posted December 12, 2017 Share Posted December 12, 2017 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:: espace 1 Link to comment Share on other sites More sharing options...
espace Posted December 12, 2017 Author Share Posted December 12, 2017 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 !!!!!!! speedo 1 Link to comment Share on other sites More sharing options...
espace Posted December 13, 2017 Author Share Posted December 13, 2017 hi yet me another thing have you a good tutorial to enable this feature with nvim in place of vim ? (i prefer nvim for true colors and for the indent speed) Link to comment Share on other sites More sharing options...
speedo Posted December 14, 2017 Share Posted December 14, 2017 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 Link to comment Share on other sites More sharing options...
espace Posted December 15, 2017 Author Share Posted December 15, 2017 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 ! Link to comment Share on other sites More sharing options...
espace Posted December 16, 2017 Author Share Posted December 16, 2017 after searching i'm ready to use only vim. i have found this option : set guitermcolors so i have guicolors in my terminal so it"s ok. however vim autocompletion with tern definition work by me only if i press Ctrl-x,Ctrl-o is i the same by you ? i imagine that the tern definition follow with the completion like atom or sublime. What must i do for that ? Link to comment Share on other sites More sharing options...
speedo Posted December 16, 2017 Share Posted December 16, 2017 I mainly use vim but if u want to use neovim for phaser. to use phaser with neovim (all the steps and plugins are same as vim configuration) for neovim:: install nodejs. (For lookup http://redchilligame.com/how_to_use_phaser_with_vim )install neovim:: To be able to use add-apt-repository you may need to install software-properties-common: sudo apt-get install software-properties-common sudo add-apt-repository ppa:neovim-ppa/stable sudo apt-get update sudo apt-get install neovim Prerequisites for the Python modules: sudo apt-get install python-dev python-pip python3-dev python3-pip To use Vim Python 2/3 plugins with Nvim: - For Python 2 plugins $ sudo pip2 install --upgrade neovim or for the current user: $ pip2 install --user --upgrade neovim - For Python 3 plugins $ sudo pip3 install --upgrade neovim or for the current user: $ pip3 install --user --upgrade neovim put this configuration in init.vim file:: let g:python_host_prog = '/path/to/python' (*** eg:: /usr/bin/python2.7) let g:python3_host_prog = '/path/to/python3' To disable Python 2 support: let g:loaded_python_provider = 1 To disable Python 3 support: let g:loaded_python3_provider = 1 plugin manager :: vim-plug (***currently used for testing) tern plug:: tern_for_vim *** for vim-plug :: Plug 'marijnh/tern_for_vim' To user tern feature in vim/neovim - must be compiled with python. check if neovim is compiled with python(2/3) ? :checkhealth (to see more status or :version(for short def)) eg; configuration location:: home dir:: .config -----nvim -------init.vim .vim -----plugged --------tern_for_vim (for installation follow ) ------------node_modules -------------- ../tern/plugin and for phaser auto-completion follow http://redchilligame.com/how_to_use_phaser_with_vim ### phaser auto completion works without vim omni completion ctrl x + ctrl o also. For that.. auto completion plugin ( neocomplet ..) vim/nvim must be compiled with +lua , +python same goes for tern plugin. And disable autocmd. Omnisesrch. types in vimrc/imit.vim in doc. Of neocomplete github configuration file . ######## useful link ::https://github.com/neovim/neovim/wiki/Installing-Neovimhttps://neovim.io/doc/user/provider.html#provider-python Test result phaser with neovim :: Link to comment Share on other sites More sharing options...
espace Posted December 17, 2017 Author Share Posted December 17, 2017 hi, Thanks for your time. I success with your method to have completion with tern info on NEOVIM but only when i press ctrl-x,ctrl-o. The first screen show that the auto-completion works without tern info: The second screen show that the tern info work only if i press ctrl-x and ctrl-o. On the third screen i put a checkhealth status to proove that nvim is correctly set with python. I try with neocomplete and lua support but this link say that is not possible : https://github.com/neovim/neovim/wiki/FAQ#can-i-use-lua-based-vim-plugins-eg-neocomplete So how do you do to have this feature ? could you post your checkstatus and your init.vim ? You speak about disable autocmd i set in in my init.vim => noautocmd You speak also about disable omnisearch but i don't find how to do that ... http://lmgtfy.com/?q=vim+disable+omnisearch I have try with deoplete (successor of neocomplete) but the result is the same : Autocompletion ok but not with tern info, i must press ctrl-x and ctrl-o to enable that . Just to be sure i put all the commands i perform here : //install neovim and python curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs sudo add-apt-repository ppa:neovim-ppa/stable && sudo apt-get update && sudo apt-get install neovim sudo apt-get install python-dev python-pip python3-dev python3-pip sudo -H pip3 install --upgrade neovim sudo npm install -g neovim curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim //put phaser.js in ~/.vim/plugged/tern_for_vim/nodes_modules/tern/plugin http://redchilligame.com/tutorials/vim_phaser/js/phaser.js //put .tern-project at the root directory of the game { "ecmaVersion": 6, "libs": ["browser"], "loadEagerly": [], "plugins": { "phaser" : {}, "doc_comment": true } } //init.vim set encoding=utf8 set number set mouse=a set clipboard=unnamedplus set incsearch set cursorline set ignorecase set wildignorecase "" true color " relative number set relativenumber set background=dark set termguicolors set autoindent "" colors colorscheme onedark set termguicolors "" key " Plugins will be downloaded under the specified directory. call plug#begin('~/.vim/plugged') "inoremap <Tab>, <C-x><C-o> if has('nvim') Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } else Plug 'Shougo/deoplete.nvim' Plug 'roxma/nvim-yarp' Plug 'roxma/vim-hug-neovim-rpc' endif " Declare the list of plugins. Plug 'ternjs/tern_for_vim' " List ends here. Plugins become visible to Vim after this call. call plug#end() noautocmd let g:python_host_prog = '/usr/bin/python3.5' let g:deoplete#enable_at_startup = 1 Link to comment Share on other sites More sharing options...
speedo Posted December 17, 2017 Share Posted December 17, 2017 for NEOVIM auto-completion for phaser:: neocomplete doesn't work in neovim so, switch to deoplete.nvim (its awesome). to use auto-completion with-out the "ctrl x + ctrl o" see following steps:: requirements:: 1] deoplete.nvim (note it requires python3 :checkhealth) For vim-plug :: --> init.vim:: if has('nvim') Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } else Plug 'Shougo/deoplete.nvim' Plug 'roxma/nvim-yarp' Plug 'roxma/vim-hug-neovim-rpc' endif " Use deoplete. let g:deoplete#enable_at_startup = 1 2] deoplete-ternjs (bridge for linking tern plugs) --> init.vim:: Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' } 3] tern_for_vim (it is bread and butter) --> init.vim:: Plug 'marijnh/tern_for_vim' then, put phaser auto completion api to ...tern_for_vim>node_modules>tern>plugin ***for detail follow point no [3] from http://redchilligame.com/how_to_use_phaser_with_vim 3] Now the most important step :: install tern globally sudo npm install -g tern and put another phaser auto completion api to ...node_modules>tern>plugin this time globally also eg:: /usr/lib/node_modules/tern/plugin/.... And BOOM !! there you have it all set Now all the phaser auto-completion is shown as you type . to use tern hints ---> :TernType and :TernDoc (in vim the :TernType and :TernDoc is automatically displayed when matched , no need to type for neocomplete) and if the auto-completion list is not shown then only use "ctrl x + ctrl o" and if you use VIM :: do not toggle off neocomplete by default make a swith key to toggle off/on and use "CTRL X + CTRL O" for unknown listing of phaser auto-completion and switch back if satisfied . for NEOVIM no need to worry about this. (since neocomplete is not needed) --vim/neovim + phaser Rocks!!! espace 1 Link to comment Share on other sites More sharing options...
Recommended Posts