NullVoxPopuli / coc-ember

ember-language-server integration with coc, an intellisense / language server engine for (neo)vim
MIT License
32 stars 3 forks source link

coc-ember starts without error but autocompletion doesn't work in template files #401

Closed andrewheartsxd closed 2 years ago

andrewheartsxd commented 2 years ago

First off, thanks for the work on this extension, I really want to use it! 😄

vim version: NVIM v0.7.0
node version: v14.19.1
coc.nvim version: 0.0.80-master
coc.nvim directory: /Users/andrew/.local/share/nvim/plugged/coc.nvim
term: tmux
platform: darwin

I am using the demo project cloned from: https://github.com/ember-learn/super-rentals

Here are the steps I'm taking and the corresponding output:

cd ~/Development/super-rentals and start nvim: nvim . -u ../coc-ember/docs/minimal-config.vim

Output of PlugInstall:

Updated. Elapsed time: 0.042147 sec.
[====]

- Finishing ... Done!
- coc-ember: Already installed
- vim-ember-hbs: Already installed
- typescript-vim: Already installed
- coc.nvim: Already installed

Open a template file :e ~/Development/super-rentals/app/templates/application.hbs and run :CocInfo:

## Log of coc.nvim

2022-04-23T13:56:18.149 WARN (pid:71603) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. 
    at new t.Actions (/Users/andrew/.config/coc/extensions/node_modules/coc-actions/out/index.js:1:8301)
    at Object.t.activate (/Users/andrew/.config/coc/extensions/node_modules/coc-actions/out/index.js:1:15288)
2022-04-23T13:56:18.181 INFO (pid:71603) [coc-git] - Looking for git in: git
2022-04-23T13:56:18.192 INFO (pid:71603) [services] - registered service "highlight"
2022-04-23T13:56:18.298 INFO (pid:71603) [plugin] - coc.nvim initialized with node: v14.19.1 after 227ms
2022-04-23T13:56:28.675 INFO (pid:71603) [extension:coc-ember] - isEmberCli true
2022-04-23T13:56:28.676 INFO (pid:71603) [extension:coc-ember] - UELS bin @ /Users/andrew/.config/coc/extensions/node_modules/coc-ember/node_modules/@lifeart/ember-language-server/lib/start-server.js
2022-04-23T13:56:28.676 INFO (pid:71603) [services] - registered service "ember-language-server"
2022-04-23T13:56:28.690 INFO (pid:71603) [core-watchman] - watchman watching project: /Users/andrew/Development/super-rentals
2022-04-23T13:56:34.908 INFO (pid:71603) [services] - registered service "eslint"
2022-04-23T13:56:34.908 INFO (pid:71603) [services] - ESLint state change: stopped => starting
2022-04-23T13:56:34.910 INFO (pid:71603) [services] - registered service "html"
2022-04-23T13:56:34.910 INFO (pid:71603) [services] - HTML language server state change: stopped => starting
2022-04-23T13:56:35.033 INFO (pid:71603) [services] - ESLint state change: starting => running
2022-04-23T13:56:35.038 INFO (pid:71603) [services] - service eslint started
2022-04-23T13:56:35.320 INFO (pid:71603) [services] - HTML language server state change: starting => running
2022-04-23T13:56:35.325 INFO (pid:71603) [services] - service html started

So one thing that jumped out to me is that coc-ember isn't actually running. At this point, if I run :CocList extensions (coc-ember is outside the visible list):

  * coc-prettier 9.2.3 ~/.config/coc/extensions/node_modules/coc-prettier
  * coc-html 1.6.1 ~/.config/coc/extensions/node_modules/coc-html
  * coc-highlight 1.3.0 ~/.config/coc/extensions/node_modules/coc-highlight
  * coc-git 2.4.9 ~/.config/coc/extensions/node_modules/coc-git
  * coc-eslint 1.5.8 ~/.config/coc/extensions/node_modules/coc-eslint
  * coc-actions 1.5.0 ~/.config/coc/extensions/node_modules/coc-actions
  + coc-yaml 1.7.5 ~/.config/coc/extensions/node_modules/coc-yaml
  + coc-vimlsp 0.12.8 ~/.config/coc/extensions/node_modules/coc-vimlsp
  + coc-tsserver 1.10.1 ~/.config/coc/extensions/node_modules/coc-tsserver
  + coc-json 1.4.1 ~/.config/coc/extensions/node_modules/coc-json

If I then open a .js file (:e app/router.js) and run :CocInfo, I can see the Ember Language Server is running :

## Log of coc.nvim

2022-04-23T13:56:18.149 WARN (pid:71603) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. 
    at new t.Actions (/Users/andrew/.config/coc/extensions/node_modules/coc-actions/out/index.js:1:8301)
    at Object.t.activate (/Users/andrew/.config/coc/extensions/node_modules/coc-actions/out/index.js:1:15288)
2022-04-23T13:56:18.181 INFO (pid:71603) [coc-git] - Looking for git in: git
2022-04-23T13:56:18.192 INFO (pid:71603) [services] - registered service "highlight"
2022-04-23T13:56:18.298 INFO (pid:71603) [plugin] - coc.nvim initialized with node: v14.19.1 after 227ms
2022-04-23T13:56:28.675 INFO (pid:71603) [extension:coc-ember] - isEmberCli true
2022-04-23T13:56:28.676 INFO (pid:71603) [extension:coc-ember] - UELS bin @ /Users/andrew/.config/coc/extensions/node_modules/coc-ember/node_modules/@lifeart/ember-language-server/lib/start-server.js
2022-04-23T13:56:28.676 INFO (pid:71603) [services] - registered service "ember-language-server"
2022-04-23T13:56:28.690 INFO (pid:71603) [core-watchman] - watchman watching project: /Users/andrew/Development/super-rentals
2022-04-23T13:56:34.908 INFO (pid:71603) [services] - registered service "eslint"
2022-04-23T13:56:34.908 INFO (pid:71603) [services] - ESLint state change: stopped => starting
2022-04-23T13:56:34.910 INFO (pid:71603) [services] - registered service "html"
2022-04-23T13:56:34.910 INFO (pid:71603) [services] - HTML language server state change: stopped => starting
2022-04-23T13:56:35.033 INFO (pid:71603) [services] - ESLint state change: starting => running
2022-04-23T13:56:35.038 INFO (pid:71603) [services] - service eslint started
2022-04-23T13:56:35.320 INFO (pid:71603) [services] - HTML language server state change: starting => running
2022-04-23T13:56:35.325 INFO (pid:71603) [services] - service html started
2022-04-23T13:57:22.370 INFO (pid:71603) [attach] - receive notification: openList [ 'extensions' ]
2022-04-23T13:58:00.732 INFO (pid:71603) [attach] - receive notification: showInfo []
2022-04-23T14:01:05.673 INFO (pid:71603) [attach] - Request action: listNames []
2022-04-23T14:01:06.178 INFO (pid:71603) [attach] - receive notification: openList [ 'extensions' ]
2022-04-23T14:02:49.419 INFO (pid:71603) [services] - Ember Language Server state change: stopped => starting
2022-04-23T14:02:49.461 INFO (pid:71603) [services] - registered service "tsserver"
2022-04-23T14:02:49.487 INFO (pid:71603) [services] - service tsserver started
2022-04-23T14:02:50.396 INFO (pid:71603) [services] - Ember Language Server state change: starting => running
2022-04-23T14:02:50.398 INFO (pid:71603) [services] - service ember-language-server started
2022-04-23T14:02:50.398 INFO (pid:71603) [extension:coc-ember] - Configuring LanguageServerClient...
2022-04-23T14:02:50.398 INFO (pid:71603) [extension:coc-ember] - UELS Addons @ /Users/andrew/.config/coc/extensions/node_modules/coc-ember/lib/addons
2022-04-23T14:02:50.402 INFO (pid:71603) [extension:coc-ember] - [
  '/Users/andrew/.config/coc/extensions/node_modules/coc-ember/lib/addons/node_modules/els-a11y-addon',
  '/Users/andrew/.config/coc/extensions/node_modules/coc-ember/lib/addons/node_modules/els-intl-addon'
]
2022-04-23T14:03:13.460 INFO (pid:71603) [attach] - receive notification: showInfo []

Autocomplete works in router.js: Screen Shot 2022-04-23 at 2 07 52 PM

Switching back to the template however, no Ember-related autocomplete pops up: Screen Shot 2022-04-23 at 2 15 52 PM Screen Shot 2022-04-23 at 2 15 43 PM

I believe I've followed the setup instructions in the README. Is there something else I'm missing?

NullVoxPopuli commented 2 years ago

While looking into this, I noticed that the coc-nvim install instructions have changed since the minimal-config.vim file was made.

One thing that lead me to check this, was that I kept getting: [coc.nvim] build/index.js not found, please install depnedencies...

Updating to have (at the time of writing, latest):

Plug 'neoclide/coc.nvim', {'branch': 'release'}

What I did to get things working:

rm -rf ~/.local/share/nvim/plugged/coc-ember/
rm -rf ~/.local/share/nvim/plugged/coc.nvim/

then, in neovim, my command is (with updated config, which is pushed at the time of me clicking the "comment" button on this comment):

nvim ./app/templates/about.hbs -u ../../NullVoxPopuli/coc-ember/docs/minimal-config.vim 
```vim
:PlugClean
# quit, re-open
:PlugUpdate
# quit, re-open
:CocUpdate

and... success!!

(I have completions in the template)

andrewheartsxd commented 2 years ago

Thanks for taking a look at this. I updated my minimal-config.vim to match https://github.com/NullVoxPopuli/coc-ember/commit/0607d3671c5de094c035e665443b8fd5caf7a33a and followed the rest of the steps in your comment. Unfortunately, I still get no autocompletion. It still seems like the Ember Language Server doesn't even start in .hbs files, according to :CocInfo.

I'm also on MacOS, I wonder if this is somehow related to https://github.com/NullVoxPopuli/coc-ember/issues/333 ☹️

NullVoxPopuli commented 2 years ago

hm, yeah -- I'm on linux. :thinking:

@lifeart or @alexlafroscia or @JimSchofield, do any of you have thoughts?

NullVoxPopuli commented 2 years ago

oh! @andrewheartsxd I just had a thought -- how are your .hbs files identified?

for me, the filetype is handlebars.

in your screenshots, idk if the filetype is printed anywhere :thinking:

andrewheartsxd commented 2 years ago

That seems to be the issue!

Running :set filetype? prints out html.handlebars.

When I manually :set filetype=handlebars, autocomplete starts working!

This is interesting to me because I believe the vim-ember syntax plugin actually sets the filetype to html.handlebars?: https://github.com/joukevandermaas/vim-ember-hbs/blob/master/ftdetect/handlebars.vim

NullVoxPopuli commented 2 years ago

hmm, html.handlebars should be supported -- I wonder if coc maybe doesn't support languages with . in the name? I'll have to look in to that

NullVoxPopuli commented 2 years ago

Gonna close for now. The filetype thing should maybe be a separate issue

lifeart commented 2 years ago

@NullVoxPopuli there is a few places where we rely on document type === 'handlebars' in LS,

image
NullVoxPopuli commented 2 years ago

hmmm -- gotchya -- so we'll need to expand that to include the alternate types -- as well as gjs/gts (plus template extraction)?

lifeart commented 2 years ago

@NullVoxPopuli html.handlebars is not part of LSP protocol https://microsoft.github.io/language-server-protocol/specification

image

Since gjs, gts types does not agreed - I don't think we need to support html.handlebars name, because it's leads us to bunch of various cases to handle.

NullVoxPopuli commented 2 years ago

yeah, what's even funner is that we don't actually use handlebars either. "ember templates" are their own thing

Since gjs, gts types does not agreed -

how do you mean?

lifeart commented 2 years ago

@NullVoxPopuli there is no agreed identifier for extensions

NullVoxPopuli commented 2 years ago

well, obviously I'm partial to (neo)vim's dot-separated identifies :sweat_smile:

typescript.glimmer javascript.glimmer

ewal commented 2 years ago

If anyone else finds their way in here looking for a solution, this config solved it for me:

let g:coc_filetype_map = {
  \ 'html.handlebars': 'handlebars',
\ }