comparison dot_config/nvim/config.lua @ 322:deb606f02fc4

Test if flake8, black are available before adding
author zegervdv <zegervdv@me.com>
date Mon, 21 Dec 2020 11:03:07 +0100
parents aa0a095f8759
children 3b25f3aa7014
comparison
equal deleted inserted replaced
321:aa0a095f8759 322:deb606f02fc4
128 on_attach = on_attach; 128 on_attach = on_attach;
129 } 129 }
130 end 130 end
131 131
132 if (vim.fn.executable('efm-langserver') == 1) then 132 if (vim.fn.executable('efm-langserver') == 1) then
133 languages = {};
134
135 languages.python = {};
136 if (vim.fn.executable('black') == 1) then
137 table.insert(languages.python, {
138 formatCommand = "black -",
139 formatStdin = true
140 })
141 end
142 if (vim.fn.executable('flake8') == 1) then
143 table.insert(languages.python, {
144 lintCommand = "flake8 --stdin-display-name ${INPUT} -",
145 lintStdin = true,
146 lintIgnoreExitCode = true,
147 lintFormats = {"%f:%l:%c: %m"}
148 })
149 end
150
133 lsp.efm.setup{ 151 lsp.efm.setup{
134 on_attach = on_attach; 152 on_attach = on_attach;
135 init_options = {documentFormatting = true}; 153 init_options = {documentFormatting = true};
136 root_dir = lsputil.root_pattern('.git', '.hg'); 154 root_dir = lsputil.root_pattern('.git', '.hg');
137 settings = { 155 settings = {
138 rootMarkers = {".git/", ".hg/"}, 156 rootMarkers = {".git/", ".hg/"},
139 languages = { 157 languages = languages
140 python = {
141 {
142 formatCommand = "black -",
143 formatStdin = true
144 },
145 {
146 lintCommand = "flake8 --stdin-display-name ${INPUT} -",
147 lintStdin = true,
148 lintIgnoreExitCode = true,
149 lintFormats = {"%f:%l:%c: %m"}
150 }
151 }
152 }
153 }; 158 };
154 } 159 }
155 end 160 end