Skip to content

Commit d97d014

Browse files
committed
fix: guard buffer-local prettier default args with filetype check to prevent override during nested syntax loads
1 parent 336d8e4 commit d97d014

15 files changed

Lines changed: 71 additions & 45 deletions

File tree

ftplugin/css.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'css',
3-
\ }
1+
if &filetype =~# '\v<css>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'css',
4+
\ }
5+
endif

ftplugin/graphql.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'graphql',
3-
\ }
1+
if &filetype =~# '\v<graphql>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'graphql',
4+
\ }
5+
endif

ftplugin/html.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" markdown/php files run this as well
22
" https://stackoverflow.com/questions/22839269/why-does-vim-default-markdown-ftplugin-source-html-ftplugins-is-there-any-ways
3-
if expand('%:e') ==# 'html'
3+
if &filetype =~# '\v<html>'
44
let b:prettier_ft_default_args = {
55
\ 'parser': 'html',
66
\ }

ftplugin/json.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'json',
3-
\ }
1+
if &filetype =~# '\v<json>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'json',
4+
\ }
5+
endif

ftplugin/less.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'less',
3-
\ }
1+
if &filetype =~# '\v<less>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'less',
4+
\ }
5+
endif

ftplugin/lua.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'lua',
3-
\ }
1+
if &filetype =~# '\v<lua>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'lua',
4+
\ }
5+
endif

ftplugin/markdown.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'markdown',
3-
\ }
1+
if &filetype =~# '\v<markdown>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'markdown',
4+
\ }
5+
endif

ftplugin/php.vim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
let s:ROOT_DIR = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
22
let s:plugin_path = s:ROOT_DIR . '/node_modules/@prettier/plugin-php/src/index.mjs'
33

4-
let b:prettier_ft_default_args = {
5-
\ 'parser': 'php',
6-
\ }
4+
if &filetype =~# '\v<php>'
5+
let b:prettier_ft_default_args = {
6+
\ 'parser': 'php',
7+
\ }
78

8-
if filereadable(s:plugin_path)
9-
let b:prettier_ft_default_args['bundledPlugins'] = [s:plugin_path]
9+
if filereadable(s:plugin_path)
10+
let b:prettier_ft_default_args['bundledPlugins'] = [s:plugin_path]
11+
endif
1012
endif

ftplugin/ruby.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'ruby',
3-
\ }
1+
if &filetype =~# '\v<ruby>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'ruby',
4+
\ }
5+
endif

ftplugin/scss.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
let b:prettier_ft_default_args = {
2-
\ 'parser': 'scss',
3-
\ }
1+
if &filetype =~# '\v<scss>'
2+
let b:prettier_ft_default_args = {
3+
\ 'parser': 'scss',
4+
\ }
5+
endif

0 commit comments

Comments
 (0)