enable fmt on save for python with ruff
parent
0fba8d146c
commit
db4e0da978
@ -0,0 +1,26 @@
|
||||
function enable_autocomplete(client, buf)
|
||||
if client.supports_method('textDocument/completion') then
|
||||
vim.lsp.completion.enable(true, client.id, buf, {autotrigger = true})
|
||||
end
|
||||
end
|
||||
|
||||
function enable_autoformat(client, buf)
|
||||
if client.supports_method('textDocument/formatting') then
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({bufnr = buf, id = client.id})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local buf = args.buf
|
||||
|
||||
-- enable_autocomplete(client, buf)
|
||||
enable_autoformat(client, buf)
|
||||
end,
|
||||
})
|
Loading…
Reference in New Issue