Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Running a formatter in a specific directory #616

Discussion options

You must be logged in to vote

By default, null-ls will resolve its root directory from a few patterns, the most common of which is a Git root. You can either modify root directory detection based on your project or set the cwd for the process dynamically (I haven't tested this, but it should get you on the right track):

local ufmt = {
    method = null_ls.methods.FORMATTING,
    filetypes = { "python" },
    generator = null_ls.formatter({
        command = "ufmt",
        args = {
            "format",
            "$FILENAME",
        },
        stdin = false,
        to_temp_file = true,
    }),
    cwd = function(params)
        return vim.fn.fnamemodify(params.bufname, ":p:h")
    end,
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jotacosta-fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants