# HG changeset patch # User zegervdv # Date 1608567376 -3600 # Node ID 3b25f3aa701482a7286c8f010b50d2b6578d2318 # Parent deb606f02fc4936e28415eb8fdd9bfdeb4068fb1 Use efm folders to store efm configuration per language To add a language configuration: - create a file under lua/efm/.lua - require the langauges table from efm/languages - add the configuration diff -r deb606f02fc4 -r 3b25f3aa7014 dot_config/nvim/config.lua --- a/dot_config/nvim/config.lua Mon Dec 21 11:03:07 2020 +0100 +++ b/dot_config/nvim/config.lua Mon Dec 21 17:16:16 2020 +0100 @@ -130,23 +130,12 @@ end if (vim.fn.executable('efm-langserver') == 1) then - languages = {}; + require 'efm/python' - 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 + -- May not be installed, use pcall to handle errors + pcall(require, 'efm/systemverilog') + + local language_cfg = require'efm/languages' lsp.efm.setup{ on_attach = on_attach; @@ -154,7 +143,7 @@ root_dir = lsputil.root_pattern('.git', '.hg'); settings = { rootMarkers = {".git/", ".hg/"}, - languages = languages + languages = language_cfg }; } end diff -r deb606f02fc4 -r 3b25f3aa7014 dot_config/nvim/lua/efm/languages.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dot_config/nvim/lua/efm/languages.lua Mon Dec 21 17:16:16 2020 +0100 @@ -0,0 +1,3 @@ +local configs = {} + +return setmetatable({}, configs) diff -r deb606f02fc4 -r 3b25f3aa7014 dot_config/nvim/lua/efm/python.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dot_config/nvim/lua/efm/python.lua Mon Dec 21 17:16:16 2020 +0100 @@ -0,0 +1,20 @@ +local languages = require'efm/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 +