Skip to content

Inconsistent line formatting when using ruff #13264

Answered by dhruvmanila
bavo96 asked this question in Q&A

You must be logged in to vote

Do you think maybe the pylsp is overlapping with ruff?

This could happen. The snippet that you've provided would send the formatting request to all the server that supports formatting. What you want instead is to only send it to a specific server which can be done by:

-- Auto formatting when saving file
vim.api.nvim_create_autocmd("BufWritePre", {
    buffer = buff,
    callback = function()
        vim.lsp.buf.format { 
			async = false,
			filter = function(client)
				return client.name == "ruff"
			end
		}
    end
})

Replies: 1 comment 8 replies

You must be logged in to vote
8 replies
@MichaReiser

@bavo96

@MichaReiser

@dhruvmanila

Answer selected by bavo96
@bavo96

@bavo96

@bavo96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
formatter Related to the formatter
3 participants