facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.08k stars 1.86k forks source link

A formatter for Flow? #9210

Closed mlp1802 closed 3 weeks ago

mlp1802 commented 3 weeks ago

Does it exist? I use nvim and this is my setup: lsp.configure('flow', { cmd = { 'npx', 'flow', 'lsp' }, -- Flow LSP command filetypes = { 'javascript', 'javascriptreact' }, root_dir = require('lspconfig').util.root_pattern('.flowconfig'), on_attach = function(client, bufnr) -- Default keymaps for LSP lsp.default_keymaps({ buffer = bufnr })

                -- Enable autoformat on save
                if client.server_capabilities.documentFormattingProvider then
                    vim.api.nvim_create_autocmd("BufWritePre", {
                        buffer = bufnr,
                        callback = function()
                            vim.lsp.buf.format({ async = false })
                        end
                    })
                end

                -- Set indentation settings (adjust to your preferences)
                vim.bo.tabstop = 2 -- Number of spaces per tab
                vim.bo.shiftwidth = 2 -- Number of spaces to use for indentation
                vim.bo.expandtab = true -- Convert tabs to spaces
            end,
        })

Flow language server works, but whenever it tried to format the text, I get the error:[LSP] Format request failed, no matching language servers. is there maybe a command line tool or something? in case lsp doesn't support it

SamChou19815 commented 3 weeks ago

Flow doesn't ship with a formatter. We recommend to use prettier