Coc.nvim: Add Text Linter Support like Alex and Proselint for Writers

Created on 4 Jun 2020  ·  3Comments  ·  Source: neoclide/coc.nvim

Is your feature request related to a problem? Please describe.
I have been using alex and proselint to check my writing for a while but I always get discouraged to do so because I have to exit vim and run the executable on the file by itself which is really inefficient when writing a long text. I have thought about ALE or syntastic which the README for alex and proselint says can be used to use them within vim but I don't want to install another linting plugin just for text since I love coc more for other things.

Describe the solution you'd like
I think it would be nice if someone could figure out a coc-settings.json language server setup for the alex or proselint executable. Even better an extension for text linting like what coc-clangd uses clangd.

Describe alternatives you've considered
As I said I thought of ALE and syntastic which the README for alex and proselint said has support. But I couldn't find any relevant documentation on github to achieve that, and again I don't want another linting program just for texts making my vim slow.

Additional context
Other than alex and proselint there are also things like GNU style and diction which would work as well but I personally think alex and proselint is (Edit: are...see this is why I need text linting) more accurate and detailed.

help wanted

Most helpful comment

I made up this config for alex. You may have to change the command depending on how you installed it.

"alex": {
    "command": "alexjs",
    "debounce": 200,
    "isStderr": true,
    "args": ["--stdin"],
    "offsetLine": 0,
    "offsetColumn": 0,
    "sourceName": "alex.js",
    "formatLines": 1,
    "formatPattern": [
        "^\\s*(\\d+):(\\d+)-(\\d+):(\\d+)\\s{2}([a-z]+)\\s{2}(.*?)\\s{2,}([a-z-]+)\\s{2,}([a-z-]+)$",
        {
            "line": 1,
            "column": 2,
            "endLine": 3,
            "endColumn": 4,
            "security" : 5,
            "message": 6
        }
    ],
    "securities" : {
        "warning": "warning",
        "error": "error"
    }
}

You can add this to your diagnostic-languageserver.linters to use it with coc-diagnostic.
Hope it helps!

All 3 comments

Thank you @chemzqm for that link.
I managed to get proselint working using coc-diagnostic with this config:

"diagnostic-languageserver.filetypes": {
    "text": ["proselint"]
},
"diagnostic-languageserver.linters": {
    "proselint": {
        "command": "proselint",
        "isStdout": true,
        "isStderr": false,
        "debounce": 100,
        "args": ["-"],
        "offsetLine": 0,
        "offsetColumn": 0,
        "sourceName": "proselint",
        "formatLines": 1,
        "formatPattern": [
            "^[^:]+:(\\d+):(\\d+):(\\s)(.*)$",
            {
                "line": 1,
                "column": 2,
                "security": 3,
                "message": 4
            }
        ],
        "securities": {
            " ": "info"
        }
    }
}

I am still working on GNU diction, style, and alex. I will post the solutions here when I'm done.

I made up this config for alex. You may have to change the command depending on how you installed it.

"alex": {
    "command": "alexjs",
    "debounce": 200,
    "isStderr": true,
    "args": ["--stdin"],
    "offsetLine": 0,
    "offsetColumn": 0,
    "sourceName": "alex.js",
    "formatLines": 1,
    "formatPattern": [
        "^\\s*(\\d+):(\\d+)-(\\d+):(\\d+)\\s{2}([a-z]+)\\s{2}(.*?)\\s{2,}([a-z-]+)\\s{2,}([a-z-]+)$",
        {
            "line": 1,
            "column": 2,
            "endLine": 3,
            "endColumn": 4,
            "security" : 5,
            "message": 6
        }
    ],
    "securities" : {
        "warning": "warning",
        "error": "error"
    }
}

You can add this to your diagnostic-languageserver.linters to use it with coc-diagnostic.
Hope it helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

svenstaro picture svenstaro  ·  4Comments

rkulla picture rkulla  ·  3Comments

cvlmtg picture cvlmtg  ·  3Comments

skylite21 picture skylite21  ·  3Comments

MaskRay picture MaskRay  ·  3Comments