Skip to content

Error on unsupported #211

Description

@ignamartinoli

Hey, really nice plugin, I love using it.
The other day I tried to use it on a JSON file. I forgot it wasn't possible to comment JSON, but after I did I received this error message:

E5108: Error executing lua Vim(lua):E5108: Error executing lua .../site/pack/packer/opt/Comment.nvim/lua/Comment/utils.lua:156: [Comment] Invalid commentstring - "". Run :h 'commentstring' for help.
stack traceback:
        [C]: in function 'assert'
        .../site/pack/packer/opt/Comment.nvim/lua/Comment/utils.lua:156: in function 'parse_cstr'
        ...site/pack/packer/opt/Comment.nvim/lua/Comment/optfunc.lua:62: in function 'opfunc'
        ...im/site/pack/packer/opt/Comment.nvim/lua/Comment/api.lua:279: in function 'current'
        [string ":lua"]:1: in main chunk
        [C]: at 0x55d7ba838e46
stack traceback:
        [C]: at 0x55d7ba838e46

It's totally correct for the plugin to refuse to comment in a language that hasn't that feature.
But what I would suggest is avoiding to crash and break the user experience.
The plugin could show a yellow message under the statusline with something like

Comment.nvim: commenting unsupported

For example, in nvim-lspconfig, when a Language Server crashes, it's reported this way.

Thanks for your time and your awesome plugin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions