General purpose Language Server that integrate with linter to support diagnostic features
Main features
- diagnostic with linters
- document format
screenshot with neovim and coc

Install
yarn global add diagnostic-languageserver
make sure your yarn's global bin path is include in
PATH
for example
export PATH="$(yarn global bin):$PATH"
Config & Document
languageserver config:
linters field:
filetypes field:
formatters field:
formatFiletypes field:
Args additional syntax
args: ["%text", "%filename", "%relativepath", "%file", "%filepath", "%dirname", "%tempfile"]
%filenamewill replace with basename of file%textwill replace with file content%filewill replace with full path to the file and not use stdio%filepathwill replace with full path to the file%relativepathwill replace with relative path of file%dirnamewill replace with dirname of file%tempfilewill replace with the full path to a temporary file written with the contents of the document and not use stdio; this file will automatically be deleted when the command completes
How to config a new linter
shellcheck for example:
file test.sh:
#!/usr/bin/env bash echo `ls -al`
then:
shellcheck --format=gcc test.sh
output:
t.sh:3:6: warning: Quote this to prevent word splitting. [SC2046]
t.sh:3:6: note: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. [SC2005]
t.sh:3:6: note: Use $(...) notation instead of legacy backticked `...`. [SC2006]
write pattern to match the line for line column message security:
const line = "t.sh:3:6: warning: Quote this to prevent word splitting. [SC2046]" const formatPattern = "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$" const match = line.match(new RegExp(formatPattern)) console.log(match)
output:
so you got:
line:match[1]column:match[2]message:match[4]security:match[3]
and your formatPattern field will be:
Notes if the linter's message for per issue more then one line, you have to set the
formatLinesto fill your pattern, and you can view the languagetool pattern for example whichformatLines = 2
Example with coc.nvim
Each LSP client should support
initializationOptionsoption, all you need fordiagnostic-languageserveris put the config ininitializationOptionsoption.
- shellcheck for shell
- languagetool for grammer check
- more Linters config example.
coc-settings.json:
you can use this extension https://github.com/iamcco/coc-diagnostic
TODO
- local node_modules linter support like eslint or textlint
- diagnostic severity
- root pattern
- document format
References
- inspired by efm-langserver
