Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim and coc.nvim setup does not work #36

Closed
mnegovanovic opened this issue May 29, 2023 · 6 comments
Closed

neovim and coc.nvim setup does not work #36

mnegovanovic opened this issue May 29, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@mnegovanovic
Copy link

  • Millet version: 0.9.8
  • Editor version: neovim 0.9.1
  • OS version: arch linux (latest), mac osx ventura 13.4

Steps to reproduce

configure coc.nvim to point to millet binary and open .sml file inside .mlb project ... errors and warnings are displayed on the left hand side. However this is the only time millet seems to be working. Type "aaaaaaa" inside the .sml file and save it, expected behaviour would be that new error is picked up ... but not. Millet seems not to be working except for that initial file opening.

Expected behavior

millet re-runs on file saving and displays the newly introduced errors and warnings.

Regards

@mnegovanovic mnegovanovic added the bug Something isn't working label May 29, 2023
@azdavis
Copy link
Owner

azdavis commented May 29, 2023

I don't have the most experience with (neo)vim. Is it possible to add more logging to nvim/millet to see if e.g. nvim is sending millet file update messages and millet is ignoring them, or if nvim is not even sending anything? For millet, if the environment variable RUST_LOG is set to e.g. info then there should be a bunch of messages shown to stderr.

Additionally, if you give more detail for how to set up nvim with millet, I can try investigating on my end. As I mentioned I don't use nvim, so I'd appreciate instructions for a minimal reproducer that includes:

  • how to install nvim
  • how to set up a minimal coc.nvim configuration file
  • how to set up nvim to talk to millet
  • how to open a project

@mnegovanovic
Copy link
Author

To install neovim:
brew install neovim or pacman -S neovim

Install plug (the easiest for plugins):
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Create minimal config file for nvim (~/.config/nvim/init.vim):

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath

" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': 'yarn install --frozen-lockfile'}
call plug#end()

" minimal COC setup
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
set updatetime=250

let g:coc_disable_startup_warning = 1

Now we can start nvim and sync the COC install (in nvim):
:PlugUpdate

Now we need to tell COC to use millet (~/.config/nvim/coc-settings.json):

{
  "languageserver": {
    "sml": {
      "command": "/opt/homebrew/bin/millet-ls",
      "filetypes": ["sml"]
    }
  }
}

COC requires node and yarn installed and in PATH. That should be it. Open SML project and you will be able to see what i am talking about.

Regards

@mnegovanovic
Copy link
Author

I will try and enable debugging in nvim and coc.nvim and see how far i get.

Regards

@azdavis
Copy link
Owner

azdavis commented Jun 3, 2023

I believe the issue is that:

  • when millet initializes, we check if the client (the editor, in this case nvim) supports sending 'watched file changes' notifications.
  • if it does, we dynamically register for those such events and ignore the usual text document open/close/change events.
  • nvim does report that it supports sending watched files changes, so millet registers for them and starts ignoring the usual text document events.
  • nvim doesn't actually send the watched file change events, but it does send the text document events.
  • millet ignores the text document events because we're expecting to listen to watched file change events, but there are none coming from the client.

I'm not sure if this is an issue with millet or the client. I can report that using watched file change events works in e.g. vs code (my primary editor). maybe while we investigate the root cause i can add a setting for millet that says: do not try to register for watched file change events, even if the client says they support them. you could then turn that on and millet would not attempt to ask the client to use watched file events, and just always use the text document events and not ignore them.

@azdavis
Copy link
Owner

azdavis commented Jun 4, 2023

As of 0dc5a5a, under "initializationOptions", you can add "fs_watcher": false to your ~/.config/nvim/coc-settings.json:

{
  "languageserver": {
    "sml": {
      "command": "...",
      "filetypes": ["sml"],
      "initializationOptions": {
        "fs_watcher": false
      }
    }
  }
}

This corresponds with the new VS Code extension setting millet.server.fileSystemWatcher.enable which I have documented.

More generally, I've also written up a bit about configuring non-VS-Code editors with the language server init options.

@azdavis azdavis closed this as completed Jun 4, 2023
@azdavis
Copy link
Owner

azdavis commented Jun 4, 2023

I have also released v0.10.1 with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants