123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- -- Example configuations here: https://github.com/mattn/efm-langserver
- -- python
- local flake8 = {
- LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",
- lintStdin = true,
- lintFormats = {"%f:%l:%c: %m"}
- }
- local isort = {formatCommand = "isort --quiet -", formatStdin = true}
- local yapf = {formatCommand = "yapf --quiet", formatStdin = true}
- -- lua
- local luaFormat = {
- formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=120",
- formatStdin = true
- }
- -- JavaScript/React/TypeScript
- local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true}
- local eslint = {
- lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
- lintIgnoreExitCode = true,
- lintStdin = true,
- lintFormats = {"%f:%l:%c: %m"},
- formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
- formatStdin = true
- }
- local shellcheck = {
- LintCommand = 'shellcheck -f gcc -x',
- lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'}
- }
- local shfmt = {
- formatCommand = 'shfmt -ci -s -bn',
- formatStdin = true
- }
- require"lspconfig".efm.setup {
- -- init_options = {initializationOptions},
- init_options = {documentFormatting = true, codeAction = false},
- filetypes = {"lua", "python", "javascriptreact", "javascript", "sh"},
- settings = {
- rootMarkers = {".git/"},
- languages = {
- lua = {luaFormat},
- python = {isort, yapf},
- javascriptreact = {prettier, eslint},
- javascript = {prettier, eslint},
- sh = {shellcheck, shfmt}
- }
- }
- }
- -- TODO turn these eslint and prettier examples into something good
- -- TODO also shellcheck and shell formatting
- -- Also find way to toggle format on save
- -- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim
|