neoclide / coc-smartf

Make jump to character easier.
72 stars 6 forks source link

Pressing f removes all " in a json file #5

Closed desmap closed 5 years ago

desmap commented 5 years ago

Before:

{                                                                                                                                                                                                                      "coc.preferences.formatOnType": true,
    "signature.enable": true,
    "tsserver.npm": "/home/name/.nvm/versions/node/v12.6.0",
    "tsserver.formatOnType": false,
    "typescript.showUnused": false,
    "javascript.preferences.quoteStyle": "single",
    "javascript.validate.enable": false,
    "suggest.noselect": false
}

after pressing f:

{
  coc.preferences.formatOnType: true,
  signature.enable: true,
  tsserver.npm: /home/r/.nvm/versions/node/v12.6.0,
  tsserver.formatOnType: false,
  typescript.showUnused: false,
  javascript.preferences.quoteStyle: single,
  javascript.validate.enable: false,suggest.noselect: false
}

Setting json.format.enable: false makes no difference. I have coc-json installed. If I uninstall it it'a a bit better: the " are removed after f and once I press the target they come back.

chemzqm commented 5 years ago

It's just hidden since it uses conceal feature of vim and your json syntax plugin mark " as concealled. Disable conceal feature of your json plugin can avoid it.

desmap commented 5 years ago

Ok, I tried set conceallevel=0. I tried also set cocu="" and set cocu= but the problem is still there. Do you mean this? Or is it a coc-json-setting, I didn't find any setting there...

chemzqm commented 5 years ago

It's problem of your json syntax plugin.

chemzqm commented 5 years ago

let g:vim_json_syntax_conceal=0 might helps.

desmap commented 5 years ago

It's problem of your json syntax plugin.

I don't have any json-syntax plugin installed except coc-json or do you mean coc-json with json syntax plugin?

let g:vim_json_syntax_conceal=0 might helps.

I tried this too

desmap commented 5 years ago

When I uninstall coc-smartf again, remove all mappings, restart nvim the problem is gone

desmap commented 5 years ago

I saw that manager.ts is modding conceallevel and concealcursor:

    ...    
    nvim.call('eval', ['&conceallevel'], true)
    nvim.call('eval', ['&concealcursor'], true)
    if (this.hasIndentLine) {
      nvim.command('silent! IndentLinesDisable', true)
    }
    nvim.command(`setl conceallevel=2`, true)
    nvim.command(`setl concealcursor=n`, true)
    ...

Maybe it's not set back to 0 consistently? Didn't have time to get through the entire code and grasp what is happening. So just a thought...

desmap commented 5 years ago

Now, I now what you mean with vim-json plugin. nvim has this splugin built-in: https://github.com/neovim/neovim/blob/master/runtime/syntax/json.vim

But there's now way to turn it off. set conceallevel=0 just works until the first time you execute smartf.

desmap commented 5 years ago

Ok found a so-so work-around: you have to turn-off neovim's built-in json.vim with au BufRead,BufNewFile *.json setfiletype disabled at the beginning of your init.vim. Then you loose syntax highlighting though but this trade-off is ok since it's json and nobody works all the day on json files ;)

chemzqm commented 5 years ago

I can't reproduce your issue, it makes " hidden when activated, but also reset conceallevel as expected.

desmap commented 5 years ago

This is odd. Let me test this again these days, FWIW: i'vev run the latest nvim nightly and the latest coc.vim

desmap commented 5 years ago

I reinstalled coc-smartf and tried it again, same, tried it without any Plug-plugin, same.

chemzqm commented 5 years ago

@desmap Please provide minimal vimrc and steps to reproduce.