diff options
Diffstat (limited to '.config/nvim')
| -rw-r--r-- | .config/nvim/after/ftplugin/python.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.config/nvim/after/ftplugin/python.lua b/.config/nvim/after/ftplugin/python.lua new file mode 100644 index 0000000..fa39ee8 --- /dev/null +++ b/.config/nvim/after/ftplugin/python.lua @@ -0,0 +1,17 @@ +vim.opt_local.textwidth = vim.g.dotfiles.textwidth.python +vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth' +vim.opt_local.complete = { + "o", -- 'omnifunc' +} + +vim.b.autoformat = true +vim.b.format_func = function() + local ret = vim.system({ "black", "--check", "-" }, { stdin = vim.api.nvim_buf_get_lines(0, 0, -1, false) }):wait() + if ret.code > 1 then + vim.notify("black failed (" .. ret.code .. "):\n" .. ret.stderr, vim.log.levels.WARN) + return + end + local view = vim.fn.winsaveview() + vim.cmd("%!black --quiet -") + vim.fn.winrestview(view) +end |
