-- " npm install -g eslint_d local eslint = { lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}", lintStdin = true, lintFormats = {"%f:%l:%c: %m"}, lintIgnoreExitCode = true, formatCommand = "eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}", formatStdin = true } local shellcheck = { lintCommand = "shellcheck -f gcc -x", lintSource = "shellcheck", lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m", } } local flake8 = { lintCommand = "flake8 --stdin-display-name ${INPUT} -", lintStdin = true, lintFormats = {"%f:%l:%c: %m"} } local black = { formatCommand = "black --quiet -", formatStdin = true } -- sudo pacman -Syu jq local jq = { lintCommand = "jq ." } -- npm install -g fixjson local fixjson = { formatCommand = "fixjson" } -- https://aur.archlinux.org/packages/lua-format/ local luaformat = { formatCommand = 'lua-formatt -i', formatStdin = true } local util = require "lspconfig".util local on_attach_efm = function(client) if client.resolved_capabilities.document_formatting then vim.cmd [[augroup lsp_formatting]] vim.cmd [[autocmd!]] vim.cmd [[autocmd BufWritePre :lua vim.lsp.buf.formatting_seq_sync({}, 1000)]] vim.cmd [[augroup END]] end end require "lspconfig".efm.setup { init_options = {documentFormatting = true}, on_attach = on_attach_efm, filetypes = {"javascript", "json", "sh", "python", "lua"}, root_dir = function(fname) return util.root_pattern("tsconfig.json")(fname) or util.root_pattern(".eslintrc.js", ".git")(fname); end, settings = { rootMarkers = {".eslintrc.js", ".git/"}, languages = { javascript = {eslint}, json = {jq, fixjson}, python = {flake8, black}, sh = {shellcheck}, lua = {luaformat} } } }