• Stars
    star
    880
  • Rank 51,881 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

General purpose Language Server

efm-langserver

Actions Status

General purpose Language Server that can use specified error message format generated from specified command. This is useful for editing code with linter.

efm

Usage

Usage of efm-langserver:
  -c string
        path to config.yaml
  -d    dump configuration
  -logfile string
        logfile
  -loglevel int
        loglevel (default 1)
  -q    Run quieter
  -v    Print the version

Configuration

Configuration can be done with either a config.yaml file, or through a DidChangeConfiguration notification from the client. DidChangeConfiguration can be called any time and will overwrite only provided properties.

DidChangeConfiguration only supports V2 configuration and cannot set LogFile.

InitializeParams

Because the configuration can be updated on the fly, capabilities might change throughout the lifetime of the server. To enable support for capabilities that will be available later, set them in the InitializeParams

Example

{
    "initializationOptions": {
        "documentFormatting": true,
        "hover": true,
        "documentSymbol": true,
        "codeAction": true,
        "completion": true
    }
}

Example for config.yaml

Location of config.yaml is:

  • UNIX: $XDG_CONFIG_HOME/efm-langserver/config.yaml or $HOME/.config/efm-langserver/config.yaml
  • Windows: %APPDATA%\efm-langserver\config.yaml

Below is example for config.yaml for Windows.

version: 2
root-markers:
  - .git/
lint-debounce: 1s
commands:
  - command: notepad
    arguments:
      - ${INPUT}
    title: パヒ帳

tools:
  any-excitetranslate: &any-excitetranslate
    hover-command: 'excitetranslate'
    hover-stdin: true

  blade-blade-formatter: &blade-blade-formatter
    format-command: 'blade-formatter --stdin'
    format-stdin: true

  css-prettier: &css-prettier
    format-command: './node_modules/.bin/prettier ${--tab-width:tabWidth} ${--single-quote:singleQuote} --parser css'

  csv-csvlint: &csv-csvlint
    lint-command: 'csvlint'

  dockerfile-hadolint: &dockerfile-hadolint
    lint-command: 'hadolint'
    lint-formats:
      - '%f:%l %m'

  eruby-erb: &eruby-erb
    lint-debounce: 2s
    lint-command: 'erb -x -T - | ruby -c'
    lint-stdin: true
    lint-offset: 1
    format-stdin: true
    format-command: htmlbeautifier

  html-prettier: &html-prettier
    format-command: './node_modules/.bin/prettier ${--tab-width:tabWidth} ${--single-quote:singleQuote} --parser html'

  javascript-eslint: &javascript-eslint
    lint-command: 'eslint -f visualstudio --stdin --stdin-filename ${INPUT}'
    lint-ignore-exit-code: true
    lint-stdin: true
    lint-formats:
      - "%f(%l,%c): %tarning %m"
      - "%f(%l,%c): %rror %m"

  json-fixjson: &json-fixjson
    format-command: 'fixjson'

  json-jq: &json-jq
    lint-command: 'jq .'

  json-prettier: &json-prettier
    format-command: './node_modules/.bin/prettier ${--tab-width:tabWidth} --parser json'

  lua-lua-format: &lua-lua-format
    format-command: 'lua-format -i'
    format-stdin: true

  make-checkmake: &make-checkmake
    lint-command: 'checkmake'
    lint-stdin: true

  markdown-markdownlint: &markdown-markdownlint
    lint-command: 'markdownlint -s -c %USERPROFILE%\.markdownlintrc'
    lint-stdin: true
    lint-formats:
      - '%f:%l %m'
      - '%f:%l:%c %m'
      - '%f: %l: %m'

  markdown-pandoc: &markdown-pandoc
    format-command: 'pandoc -f markdown -t gfm -sp --tab-stop=2'

  mix_credo: &mix_credo
    lint-command: "mix credo suggest --format=flycheck --read-from-stdin ${INPUT}"
    lint-stdin: true
    lint-formats:
      - '%f:%l:%c: %t: %m'
      - '%f:%l: %t: %m'
    root-markers:
      - mix.lock
      - mix.exs

  php-phpstan: &php-phpstan
    lint-command: './vendor/bin/phpstan analyze --error-format raw --no-progress'

  php-psalm: &php-psalm
    lint-command: './vendor/bin/psalm --output-format=emacs --no-progress'
    lint-formats:
      - '%f:%l:%c:%trror - %m'
      - '%f:%l:%c:%tarning - %m'

  python-autopep8: &python-autopep8
    format-command: 'autopep8 -'
    format-stdin: true

  python-black: &python-black
    format-command: 'black --quiet -'
    format-stdin: true

  python-flake8: &python-flake8
    lint-command: 'flake8 --stdin-display-name ${INPUT} -'
    lint-stdin: true
    lint-formats:
      - '%f:%l:%c: %m'

  python-isort: &python-isort
    format-command: 'isort --quiet -'
    format-stdin: true

  python-mypy: &python-mypy
    lint-command: 'mypy --show-column-numbers'
    lint-formats:
      - '%f:%l:%c: %trror: %m'
      - '%f:%l:%c: %tarning: %m'
      - '%f:%l:%c: %tote: %m'

  python-pylint: &python-pylint
    lint-command: 'pylint --output-format text --score no --msg-template {path}:{line}:{column}:{C}:{msg} ${INPUT}'
    lint-stdin: false
    lint-formats:
      - '%f:%l:%c:%t:%m'
    lint-offset-columns: 1
    lint-category-map:
      I: H
      R: I
      C: I
      W: W
      E: E
      F: E

  python-yapf: &python-yapf
    format-command: 'yapf --quiet'
    format-stdin: true

  rst-lint: &rst-lint
    lint-command: 'rst-lint'
    lint-formats:
      - '%tNFO %f:%l %m'
      - '%tARNING %f:%l %m'
      - '%tRROR %f:%l %m'
      - '%tEVERE %f:%l %m'

  rst-pandoc: &rst-pandoc
    format-command: 'pandoc -f rst -t rst -s --columns=79'

  sh-shellcheck: &sh-shellcheck
    lint-command: 'shellcheck -f gcc -x'
    lint-source: 'shellcheck'
    lint-formats:
      - '%f:%l:%c: %trror: %m'
      - '%f:%l:%c: %tarning: %m'
      - '%f:%l:%c: %tote: %m'

  sh-shfmt: &sh-shfmt
    format-command: 'shfmt -ci -s -bn'
    format-stdin: true

  vim-vint: &vim-vint
    lint-command: 'vint -'
    lint-stdin: true
    lint-formats:
      - '%f:%l:%c: %m'

  yaml-yamllint: &yaml-yamllint
    lint-command: 'yamllint -f parsable -'
    lint-stdin: true

languages:
  blade:
    - <<: *blade-blade-formatter

  css:
    - <<: *css-prettier

  csv:
    - <<: *csv-csvlint

  dockerfile:
    - <<: *dockerfile-hadolint

  elixir:
    - <<: *mix_credo

  eruby:
    - <<: *eruby-erb

  html:
    - <<: *html-prettier

  javascript:
    - <<: *javascript-eslint

  json:
    - <<: *json-fixjson
    - <<: *json-jq
    # - <<: *json-prettier

  lua:
    - <<: *lua-lua-format

  make:
    - <<: *make-checkmake

  markdown:
    - <<: *markdown-markdownlint
    - <<: *markdown-pandoc

  php:
    - <<: *php-phpstan
    - <<: *php-psalm

  python:
    - <<: *python-black
    - <<: *python-flake8
    - <<: *python-isort
    - <<: *python-mypy
    # - <<: *python-autopep8
    # - <<: *python-yapf

  rst:
    - <<: *rst-lint
    - <<: *rst-pandoc

  sh:
    - <<: *sh-shellcheck
    - <<: *sh-shfmt

  vim:
    - <<: *vim-vint

  yaml:
    - <<: *yaml-yamllint

  =:
    - <<: *any-excitetranslate

If you want to debug output of commands:

version: 2
log-file: /path/to/output.log
log-level: 1

Example for DidChangeConfiguration notification

{
    "settings": {
        "rootMarkers": [".git/"],
        "languages": {
            "lua": {
                "formatCommand": "lua-format -i",
                "formatStdin": true
            }
        }
    }
}

Configuration for vim-lsp

augroup LspEFM
  au!
  autocmd User lsp_setup call lsp#register_server({
      \ 'name': 'efm-langserver',
      \ 'cmd': {server_info->['efm-langserver', '-c=/path/to/your/config.yaml']},
      \ 'allowlist': ['vim', 'eruby', 'markdown', 'yaml'],
      \ })
augroup END

vim-lsp-settings provide installer for efm-langserver.

Configuration for coc.nvim

coc-settings.json

  // languageserver
  "languageserver": {
    "efm": {
      "command": "efm-langserver",
      "args": [],
      // custom config path
      // "args": ["-c", "/path/to/your/config.yaml"],
      "filetypes": ["vim", "eruby", "markdown", "yaml"]
    }
  },

Configuration for elgot

Add to eglot-server-programs with major mode you want.

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
    `(markdown-mode . ("efm-langserver"))))

Configuration for neovim builtin LSP with nvim-lspconfig

init.vim

lua << EOF
require "lspconfig".efm.setup {
    init_options = {documentFormatting = true},
    settings = {
        rootMarkers = {".git/"},
        languages = {
            lua = {
                {formatCommand = "lua-format -i", formatStdin = true}
            }
        }
    }
}
EOF
  • be sure to declare languages as a table:
lua = {
    {formatCommand = "lua-format -i", formatStdin = true}
}
-- NOT
lua = {
    formatCommand = "lua-format -i", formatStdin = true
}

-- and for multiple formatters, add to the table
lua = {
    {formatCommand = "lua-format -i", formatStdin = true},
    {formatCommand = "lua-pretty -i"}
}
  • install supported formatters

efm does not include formatters for any languages, you must install these manually, e.g.

Supported Lint tools

Installation

go install github.com/mattn/efm-langserver@latest

Homebrew

brew install efm-langserver

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)

More Repositories

1

go-sqlite3

sqlite3 driver for go using database/sql
C
7,722
star
2

emmet-vim

emmet for vim: http://emmet.io/
Vim Script
6,288
star
3

goreman

foreman clone written in go language
Go
2,330
star
4

go-gtk

Go binding for GTK
Go
2,108
star
5

vim-gist

Vim plugin for Gist
Vim Script
1,688
star
6

gom

Go Manager - bundle for go
Go
1,389
star
7

anko

Scriptable interpreter written in golang
Go
1,364
star
8

go-generics-example

Example code for Go generics
Go
1,324
star
9

vim-lsp-settings

Auto configurations for Language Server for vim-lsp
Vim Script
1,110
star
10

memo

πŸ““ Memo Life For You
Go
924
star
11

goveralls

Go
789
star
12

go-isatty

Go
739
star
13

sudo

sudo for windows
Go
732
star
14

go-colorable

Go
713
star
15

webapi-vim

vim interface to Web API
Vim Script
680
star
16

longcat

Looooooooooooooooooooooooooooooooooooooooooooooong cat
Go
645
star
17

go-oci8

Oracle driver for Go using database/sql
Go
618
star
18

docx2md

Convert Microsoft Word Document to Markdown
Go
575
star
19

awesome-twitter-communities

Awesome Twitter Communities for Engineers
561
star
20

go-mastodon

mastodon client for golang
Go
553
star
21

go-runewidth

wcwidth for golang
Go
544
star
22

go-shellwords

Parse line as shell words
Go
491
star
23

vim-sonictemplate

Easy and high speed coding method
Vim Script
329
star
24

go-webkit

webkit widget for go-gtk
Go
291
star
25

twty

command-line twitter client written in golang
Go
280
star
26

gopher

Windows Desktop Mascot Applicaiton "Gopher"
Go
279
star
27

go-tflite

Go binding for TensorFlow Lite
Jupyter Notebook
270
star
28

go-v8

Go binding for v8
Go
264
star
29

calendar-vim

calendar vimscript
Vim Script
253
star
30

flappyvird-vim

Vim Script
235
star
31

growl-for-linux

Growl Implementation For Linux #growl4linux
C
207
star
32

go-zglob

Go
195
star
33

go-redmine

Go
186
star
34

ft

File Transferer
Go
185
star
35

go-tty

Go
184
star
36

goemon

五右葛門
Go
179
star
37

gof

Go
177
star
38

qq

Go
166
star
39

vim-maketable

Vim Script
150
star
40

vim-goimports

Vim plugin for Minimalist Gopher
Vim Script
149
star
41

go-pipeline

Go
147
star
42

etcdenv

Go
142
star
43

jvgrep

grep for japanese vimmer
Go
140
star
44

go-sixel

DRCS/Sixel Encoder/Decoder
Go
137
star
45

go-vue-example

Example App using Go, Vue.js, Element, Axios
Go
135
star
46

tailscale-systray

Linux port of tailscale system tray menu.
Go
134
star
47

go-adodb

Microsoft ActiveX Object DataBase driver for go that using exp/sql
Go
133
star
48

vim-particle

This plugin works on Windows
C
129
star
49

todo

A simple command-line todo list written in Go.
Go
129
star
50

jedie

Static site generator written in golang
Go
128
star
51

clask

Web micro-framework like flask in C++.
C++
124
star
52

golisp

Lisp Interpreter
Go
123
star
53

go-pointer

Go
118
star
54

godown

Convert HTML into Markdown
Go
113
star
55

go-gimei

Go
113
star
56

vim-trex

Running T-Rex with Vim
JavaScript
111
star
57

golang-wasm-example

Example app using Go's wasm support.
JavaScript
111
star
58

livestyle-vim

Emmet LiveStyle for Vim
Vim Script
110
star
59

go-pubsub

Go
107
star
60

go-scan

Go
103
star
61

go-slim

Slim Template Engine for golang
Go
103
star
62

vim-notification

Message notification system for Vim8
Vim Script
103
star
63

gowasmer

WebAssembly runtime for wasmer-go
Go
102
star
64

bsky

A cli application for bluesky social
Go
101
star
65

dotfiles

100
star
66

vim-starwars

Playing StarWars on Vim
Vim Script
97
star
67

vim-brain

Neural Networks written in Vim script
Vim Script
96
star
68

go-nulltype

Null friendly types
Go
96
star
69

go-jsonpointer

Go
95
star
70

files

Fast file find
Go
92
star
71

mkup

Portable Markdown Previewer
JavaScript
92
star
72

go-uv

Go binding for libuv
Go
92
star
73

dboxpaper

client for Dropbox Paper
Go
92
star
74

mruby-uv

interface to libuv for mruby(experimental)
C
91
star
75

davfs

Go
90
star
76

tinytinyhttpd

tiny tiny httpd
C++
88
star
77

echo-scaffold

Echo scaffold is CLI to generate scaffolds for the echo framework.
Go
87
star
78

vim-chatgpt

Vim Script
85
star
79

streeem

ごめんγͺさいごめんγͺさい
Go
85
star
80

go-mruby

go-mruby make interface to embed mruby into go.
Go
83
star
81

algia

A cli application for nostr
Go
80
star
82

http-server

C
76
star
83

go-ieproxy

Go
76
star
84

cho

Go
76
star
85

vim-sqlfmt

Vim Script
74
star
86

vim-molder

Vim Script
71
star
87

vim-treesitter

Go
70
star
88

vimtweak

VimTweak : The tweaking dll for GVim.exe.
C
69
star
89

gomate

Go
68
star
90

awesome-sonomasakada

68
star
91

ansicolor-w32.c

C
67
star
92

gh-ost

gh extension to meet ghost.
Shell
66
star
93

http-gonsole

Speak HTTP like a local. (the simple, intuitive HTTP console, golang version)
Go
65
star
94

vim-fz

Ultra Fast Fuzzy Finder for Vim8
Vim Script
65
star
95

vdbi-vim

Database client for Vim
Vim Script
64
star
96

chatgpt

Go
63
star
97

xgopher

Linux port of https://github.com/mattn/gopher
C
61
star
98

gntp-send

command line program that send to growl using GNTP protocol.
C
57
star
99

vim-usa_president_2016

Vim Script
55
star
100

go-uwsgi

uwsgi implement for go
Go
54
star