aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2020-02-15 02:59:41 +0000
committermitermayer <mitermayer.reis@gmail.com>2020-02-15 03:51:53 +0000
commit82ad83f4053adbc59c130180cc1bddae30f63d97 (patch)
tree615b8770f85bb0f442e73f22f248bcab78106578
parent3093ca04047ac38598b515e2e62f4697174c3e0e (diff)
downloadvim-prettier-82ad83f4053adbc59c130180cc1bddae30f63d97.tar.xz
Adding support for prettier python plugin
- updating Dockerfile to include python3 on vim test bed image in order to work with prettier python plugin - prettier python plugin seems to require python3 to be available on the system
-rw-r--r--Dockerfile1
-rw-r--r--ftplugin/python.vim10
-rw-r--r--tests/__snapshots__/formatting.test.js.snap18
-rw-r--r--tests/fixtures/foo.py12
4 files changed, 41 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
index 262d875..2c8ff50 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -34,6 +34,7 @@ ENV PACKAGES="\
bash \
git \
python \
+ python3 \
py-pip \
nodejs \
npm \
diff --git a/ftplugin/python.vim b/ftplugin/python.vim
new file mode 100644
index 0000000..15dccff
--- /dev/null
+++ b/ftplugin/python.vim
@@ -0,0 +1,10 @@
+let b:prettier_ft_default_args = {
+ \ 'parser': 'python',
+ \ }
+
+augroup Prettier
+ autocmd!
+ if get(g:, 'prettier#autoformat')
+ autocmd BufWritePre *.py call prettier#Autoformat()
+ endif
+augroup end
diff --git a/tests/__snapshots__/formatting.test.js.snap b/tests/__snapshots__/formatting.test.js.snap
index 67cd15b..205221b 100644
--- a/tests/__snapshots__/formatting.test.js.snap
+++ b/tests/__snapshots__/formatting.test.js.snap
@@ -156,6 +156,24 @@ $a = 'a';
$b = $a . $a . ' asda';"
`;
+exports[`Prettier formats foo.py file with :Prettier command 1`] = `
+"def foo(a, *, example=False, **kwargs):
+ print(\\"hello world\\", example)
+
+
+def i18n_patterns(*urls, prefix_default_language=True):
+ pass"
+`;
+
+exports[`Prettier formats foo.py file with :PrettierAsync command 1`] = `
+"def foo(a, *, example=False, **kwargs):
+ print(\\"hello world\\", example)
+
+
+def i18n_patterns(*urls, prefix_default_language=True):
+ pass"
+`;
+
exports[`Prettier formats foo.scss file with :Prettier command 1`] = `
".redClass {
background: \\"red\\";
diff --git a/tests/fixtures/foo.py b/tests/fixtures/foo.py
new file mode 100644
index 0000000..b284e14
--- /dev/null
+++ b/tests/fixtures/foo.py
@@ -0,0 +1,12 @@
+def foo(a,
+ *,
+ example=False, **kwargs):
+ print(
+ "hello world",
+ example
+ )
+def i18n_patterns(
+ *urls,
+ prefix_default_language=True
+ ):
+ pass