Skip to content

Inconsistent line formatting when using ruff #13264

Answered by dhruvmanila
bavo96 asked this question in Q&A
Discussion options

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

Comment options

You must be logged in to vote
8 replies
@MichaReiser
Comment options

@bavo96
Comment options

@MichaReiser
Comment options

@dhruvmanila
Comment options

Answer selected by bavo96
@bavo96
Comment options

@bavo96
Comment options

@bavo96
Comment options

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