aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2020-02-15 08:55:11 +0000
committermitermayer <mitermayer.reis@gmail.com>2020-02-15 08:55:11 +0000
commit8373441047299fbe528dfda528fa01a4971e7d23 (patch)
tree8a8da5c13adb2edaaa789b1da90038d924a67ced
parentcdf15c260bf90d5052ec02254c091b966dceb9d9 (diff)
downloadvim-prettier-8373441047299fbe528dfda528fa01a4971e7d23.tar.xz
Adding support for the prettier lua plugin
-rw-r--r--ftplugin/lua.vim10
-rw-r--r--tests/__snapshots__/formatting.test.js.snap18
-rw-r--r--tests/fixtures/foo.lua6
3 files changed, 34 insertions, 0 deletions
diff --git a/ftplugin/lua.vim b/ftplugin/lua.vim
new file mode 100644
index 0000000..e363f6b
--- /dev/null
+++ b/ftplugin/lua.vim
@@ -0,0 +1,10 @@
+let b:prettier_ft_default_args = {
+ \ 'parser': 'lua',
+ \ }
+
+augroup Prettier
+ autocmd!
+ if get(g:, 'prettier#autoformat')
+ autocmd BufWritePre *.lua call prettier#Autoformat()
+ endif
+augroup end
diff --git a/tests/__snapshots__/formatting.test.js.snap b/tests/__snapshots__/formatting.test.js.snap
index 161352f..cfa24bf 100644
--- a/tests/__snapshots__/formatting.test.js.snap
+++ b/tests/__snapshots__/formatting.test.js.snap
@@ -118,6 +118,24 @@ exports[`Prettier formats foo.less file with :PrettierAsync command 1`] = `
}"
`;
+exports[`Prettier formats foo.lua file with :Prettier command 1`] = `
+"function deepcopy(orig)
+ local orig_type = type(orig)
+ local copy
+
+ return copy
+end"
+`;
+
+exports[`Prettier formats foo.lua file with :PrettierAsync command 1`] = `
+"function deepcopy(orig)
+ local orig_type = type(orig)
+ local copy
+
+ return copy
+end"
+`;
+
exports[`Prettier formats foo.md file with :Prettier command 1`] = `
"## foo
diff --git a/tests/fixtures/foo.lua b/tests/fixtures/foo.lua
new file mode 100644
index 0000000..c93fc69
--- /dev/null
+++ b/tests/fixtures/foo.lua
@@ -0,0 +1,6 @@
+ function deepcopy(orig)
+ local orig_type = type(orig)
+ local copy
+
+ return copy
+end