LunarVim/lua/lsp/efm-general-ls.lua

80 lines
2.7 KiB
Lua
Raw Normal View History

2021-03-18 05:24:49 +01:00
-- Example configuations here: https://github.com/mattn/efm-langserver
2021-03-19 04:47:03 +01:00
-- 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}
2021-03-23 03:10:02 +01:00
local prettier_global = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true}
2021-03-19 04:47:03 +01:00
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
}
2021-03-19 05:10:21 +01:00
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
}
2021-03-20 22:22:44 +01:00
local markdownlint = {
-- TODO default to global lintrc
-- lintcommand = 'markdownlint -s -c ./markdownlintrc',
lintCommand = 'markdownlint -s',
lintStdin = true,
lintFormats = { '%f:%l %m', '%f:%l:%c %m', '%f: %l: %m' }
}
local markdownPandocFormat = {
formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2',
formatStdin = true
}
2021-03-19 05:10:21 +01:00
2021-03-19 06:08:11 +01:00
2021-03-17 19:15:20 +01:00
require"lspconfig".efm.setup {
2021-03-19 04:47:03 +01:00
-- init_options = {initializationOptions},
init_options = {documentFormatting = true, codeAction = false},
2021-03-20 22:22:44 +01:00
filetypes = {"lua", "python", "javascriptreact", "javascript", "sh", "html", "css", "json", "yaml", "markdown"},
2021-03-17 19:15:20 +01:00
settings = {
rootMarkers = {".git/"},
languages = {
2021-03-19 04:47:03 +01:00
lua = {luaFormat},
python = {isort, yapf},
2021-03-22 04:14:11 +01:00
-- javascriptreact = {prettier, eslint},
-- javascript = {prettier, eslint},
javascriptreact = {prettier},
javascript = {prettier},
2021-03-19 06:08:11 +01:00
sh = {shellcheck, shfmt},
2021-03-23 03:10:02 +01:00
html = {prettier_global},
css = {prettier_global},
json = {prettier_global},
yaml = {prettier_global},
2021-03-20 22:22:44 +01:00
-- markdown = {markdownPandocFormat, markdownlint},
markdown = {markdownPandocFormat},
2021-03-17 19:15:20 +01:00
}
}
}
2021-03-17 20:48:52 +01:00
2021-03-18 05:24:49 +01:00
-- 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