I’m noob in Lua and after many hours of searching, it wasn’t successful.
I want to load some EFM language server configurations depends on a project setup. So, I found this: Project local settings · neovim/nvim-lspconfig Wiki · GitHub
For example: in A project I have a “black” code formatter, in B project I have “yapf” code formatter.
After that I wrote custom on_init handler:
... on_init = function(client) -- We need to register only available linters and formatters, because it improves perfomance↴ local result = vim.fn.systemlist( [[ poetry run pip list --disable-pip-version-check | grep -w -o '^black \|^yapf \|^flake8 \|^isort \|^mypy ' ]] for _, package_name in pairs(result) do local package_config = M[string.gsub(package_name, "%s+", "")] if package_config then table.insert(client.config.settings.languages.python, package_config) end end client.notify("workspace/didChangeConfiguration") return true end, ...
Well, it works, but i have a problem with a custom cmd command, it’s sync and freezes UI on first LSP load. Is it possible to load on_init async or execute cmd async?