Compare commits
1 commit
main
...
legacy-for
| Author | SHA1 | Date | |
|---|---|---|---|
| 12297f538e |
1 changed files with 16 additions and 1 deletions
|
|
@ -1,6 +1,18 @@
|
||||||
-- {{ ansible_managed }}
|
-- {{ ansible_managed }}
|
||||||
|
|
||||||
local enable_formatting = vim.env.enable_formatting == 'true';
|
local enable_formatting = vim.env.enable_formatting == 'true';
|
||||||
|
local legacy_formatting = nil;
|
||||||
|
|
||||||
|
-- TODO: move to utils file
|
||||||
|
-- TODO: add efm-languageserver to lsp.lua
|
||||||
|
if vim.env.VIRTUAL_ENV ~= nil and enable_formatting == true then
|
||||||
|
local formatters = vim.fs.find(
|
||||||
|
{ 'isort', 'black' },
|
||||||
|
{ limit = 1, type = 'file', path = vim.fs.joinpath(vim.env.VIRTUAL_ENV, 'bin') }
|
||||||
|
)
|
||||||
|
|
||||||
|
legacy_formatting = #formatters > 0;
|
||||||
|
end
|
||||||
|
|
||||||
if (enable_formatting) then
|
if (enable_formatting) then
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
|
@ -14,7 +26,10 @@ if (enable_formatting) then
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.format {
|
vim.lsp.buf.format {
|
||||||
async = false,
|
async = false,
|
||||||
id = args.data.client_id
|
id = args.data.client_id,
|
||||||
|
filter = function(format_client)
|
||||||
|
return format_client.name ~= 'ruff' or not legacy_formatting
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue