# HG changeset patch # User zegervdv # Date 1608544987 -3600 # Node ID deb606f02fc4936e28415eb8fdd9bfdeb4068fb1 # Parent aa0a095f875909457357efc29461950d23ab2016 Test if flake8, black are available before adding diff -r aa0a095f8759 -r deb606f02fc4 dot_config/nvim/config.lua --- a/dot_config/nvim/config.lua Mon Dec 21 09:39:45 2020 +0100 +++ b/dot_config/nvim/config.lua Mon Dec 21 11:03:07 2020 +0100 @@ -130,26 +130,31 @@ end if (vim.fn.executable('efm-langserver') == 1) then + languages = {}; + + languages.python = {}; + if (vim.fn.executable('black') == 1) then + table.insert(languages.python, { + formatCommand = "black -", + formatStdin = true + }) + end + if (vim.fn.executable('flake8') == 1) then + table.insert(languages.python, { + lintCommand = "flake8 --stdin-display-name ${INPUT} -", + lintStdin = true, + lintIgnoreExitCode = true, + lintFormats = {"%f:%l:%c: %m"} + }) + end + lsp.efm.setup{ on_attach = on_attach; init_options = {documentFormatting = true}; root_dir = lsputil.root_pattern('.git', '.hg'); settings = { rootMarkers = {".git/", ".hg/"}, - languages = { - python = { - { - formatCommand = "black -", - formatStdin = true - }, - { - lintCommand = "flake8 --stdin-display-name ${INPUT} -", - lintStdin = true, - lintIgnoreExitCode = true, - lintFormats = {"%f:%l:%c: %m"} - } - } - } + languages = languages }; } end