lukas-reineke / lsp-format.nvim

A wrapper around Neovims native LSP formatting.
564 stars 27 forks source link

python not formatting #3

Closed caheredia closed 3 years ago

caheredia commented 3 years ago

I can't this plugin to work with the following settings. Did I goof the setup?

lua <<EOF
require 'format'.setup{
    python = {
        {cmd = {"black", "isort"}}
   }
}
require'colorizer'.setup()
local nvim_lsp = require("nvim_lsp")
local nvim_completion = require("completion")
local nvim_diagnostic = require("diagnostic")

local custom_attach = function()
nvim_completion.on_attach()
nvim_diagnostic.on_attach()
print("LSP Attached.")
end

nvim_lsp.jedi_language_server.setup{ on_attach = custom_attach }
nvim_lsp.jsonls.setup{ on_attach = custom_attach }
nvim_lsp.vimls.setup{ on_attach = custom_attach }

EOF
lukas-reineke commented 3 years ago

Setup looks fine. Can you set let g:format_debug = v:true and call :Format? It should print what its doing (you can check with :messages)

pulcinello commented 3 years ago

Same here. I got the error message: Format error: ...o/.config/nvim/plugged/format.nvim/lua/format/format.lua:35: attempt to index local 'tempfile' (a nil value)

caheredia commented 3 years ago

@lukas-reineke here is the log

Format started job 55: "black reports/~formatting_0-1141_339334_generate_reports.py"
Format event 55: stderr { "reformatted reports/~formatting_0-1141_339334_generate_reports.py", "All done! ✨ 🍰 ✨", "1 file reformatted.", "" }
Format event 55: stdout { "" }
Format event 55: exit 0
Format started job 56: "isort reports/~formatting_0-1141_339334_generate_reports.py"
Format event 56: stderr { "" }
Format event 56: stdout { "" }
Format event 56: exit 0

I made sure to leave some white space that black normally formats, but the original file is left unchanged

lukas-reineke commented 3 years ago

@lukas-reineke here is the log this looks all good :thinking: do you maybe have unsaved changes in the buffer? If so, you need to save first, or run with ! to overwrite the changes.

lukas-reineke commented 3 years ago

@pulcinello I made you a new issue, your problem is different.

caheredia commented 3 years ago

yes that solved it!