Skip to content

Commit b538e29

Browse files
committed
fix: add compatibility smoke and plugin coverage
1 parent a9a2b62 commit b538e29

12 files changed

Lines changed: 231 additions & 47 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Compatibility Smoke
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
smoke:
9+
name: Targeted Vim smoke check
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: yarn
21+
22+
- name: Install Vim
23+
run: sudo apt-get update && sudo apt-get install -y vim
24+
25+
- name: Report Yarn version
26+
run: yarn --version
27+
28+
- name: Install dependencies
29+
run: yarn install --frozen-lockfile
30+
31+
- name: Run targeted smoke check
32+
run: yarn test:smoke
33+
34+
full-formatting-discovery:
35+
name: Full formatting suite discovery
36+
runs-on: ubuntu-latest
37+
continue-on-error: true
38+
39+
steps:
40+
- name: Check out repository
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: 20
47+
cache: yarn
48+
49+
- name: Install Vim
50+
run: sudo apt-get update && sudo apt-get install -y vim
51+
52+
- name: Report Yarn version
53+
run: yarn --version
54+
55+
- name: Install dependencies
56+
run: yarn install --frozen-lockfile
57+
58+
- name: Run full formatting suite as discovery
59+
run: yarn test

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ plugin versions:
107107
stored snapshots under the current Prettier 3.0.3 toolchain.
108108
- Remaining external plugin failures are no-op formatting for Lua, PHP, Ruby,
109109
and XML, consistent with stale or unresolved bundled parser plugins.
110+
- Added an initial GitHub Actions smoke workflow. It runs the Vim 9 config
111+
version regression as a blocking check and runs the full formatting suite as
112+
non-blocking discovery until plugin compatibility is restored.
113+
- Updated targeted Prettier 3.0.3 snapshots for GraphQL, SCSS, Vue, and YAML
114+
after confirming those were core formatter deltas.
115+
- Added explicit `plugins` CLI config support and scoped automatic bundled
116+
plugin loading for PHP and XML to Prettier executables under this checkout.
117+
PHP and XML fixture tests now pass with the current bundled packages.
118+
- Lua and Ruby fixture tests still fail as no-op formatting. Current bundled Lua
119+
and Ruby plugin versions are not viable Prettier 3 targets and need separate
120+
support decisions before being advertised.
110121

111122
## Work Stages
112123

@@ -121,13 +132,18 @@ plugin versions:
121132

122133
### Stage 1: Define Reproducible Tooling
123134

135+
- [x] Add an initial CI smoke workflow for the known Vim 9 regression and
136+
non-blocking full-suite discovery.
124137
- [ ] Add CI with an editor and Prettier compatibility matrix.
125138
- [ ] Decide whether lint runs from a pinned container or installable local deps.
126139
- [ ] Replace or deprecate the current Dockerfile path.
127140
- [ ] Document supported Node and package-manager versions.
128141

129142
### Stage 2: Prettier and Plugin Compatibility
130143

144+
- [x] Update classified Prettier 3.0.3 core snapshots for GraphQL, SCSS, Vue,
145+
and YAML without changing plugin-language snapshots broadly.
146+
- [x] Add explicit plugin argument support for PHP/XML bundled fallback tests.
131147
- [ ] Validate core Prettier language fixtures on Prettier 2.8.8 and 3.x.
132148
- [ ] Audit bundled parser-plugin versions for PHP, Ruby, XML, Lua, and Svelte.
133149
- [ ] Decide whether bundled plugin support remains in scope.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ let g:prettier#config#use_tabs = 'auto'
260260
" default: ''
261261
let g:prettier#config#parser = ''
262262
263+
" Prettier plugin paths to load. Accepts a string or list of strings.
264+
" default: []
265+
let g:prettier#config#plugins = []
266+
263267
" cli-override|file-override|prefer-file
264268
" default: 'file-override'
265269
let g:prettier#config#config_precedence = 'file-override'

autoload/prettier/resolver/config.vim

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,44 @@ function! s:Flag_parser(config_and_sel, ...) abort
106106
endif
107107
endfunction
108108

109+
" Returns repeated '--plugin=PLUGIN' args or ''.
110+
function! s:Flag_plugins(config_and_sel, ...) abort
111+
let l:value = get(
112+
\ a:config_and_sel.config,
113+
\ 'plugins',
114+
\ get(g:, 'prettier#config#plugins', []))
115+
116+
if type(l:value) == type('')
117+
let l:plugins = l:value ==# '' ? [] : [l:value]
118+
elseif type(l:value) == type([])
119+
let l:plugins = copy(l:value)
120+
else
121+
return ''
122+
endif
123+
124+
if prettier#resolver#executable#isUnderPluginRoot(
125+
\ prettier#resolver#executable#getPath())
126+
let l:bundled_value = get(a:config_and_sel.config, 'bundledPlugins', [])
127+
128+
if type(l:bundled_value) == type('')
129+
if l:bundled_value !=# ''
130+
call add(l:plugins, l:bundled_value)
131+
endif
132+
elseif type(l:bundled_value) == type([])
133+
call extend(l:plugins, l:bundled_value)
134+
endif
135+
endif
136+
137+
let l:flags = []
138+
for l:plugin in l:plugins
139+
if type(l:plugin) == type('') && l:plugin !=# ''
140+
call add(l:flags, '--plugin=' . shellescape(l:plugin))
141+
endif
142+
endfor
143+
144+
return join(l:flags, ' ')
145+
endfunction
146+
109147
" Returns '--stdin-filepath=' concatenated with the full path of the opened
110148
" file.
111149
function! s:Flag_stdin_filepath(...) abort
@@ -160,6 +198,11 @@ let s:FLAGS = {
160198
\ 'json_name': 'parser',
161199
\ 'global_name': 'parser',
162200
\ 'mapper': function('s:Flag_parser')},
201+
\ '--plugin': {
202+
\ 'json_name': 'plugins',
203+
\ 'global_name': 'plugins',
204+
\ 'mapper': function('s:Flag_plugins'),
205+
\ 'since': '1.10.0'},
163206
\ '--range-start': {
164207
\ 'json_name': '',
165208
\ 'global_name': '',

autoload/prettier/resolver/executable.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
let s:ROOT_DIR = fnamemodify(resolve(expand('<sfile>:p')), ':h')
2+
let s:PLUGIN_ROOT_DIR = fnamemodify(s:ROOT_DIR, ':h:h:h')
3+
4+
function! s:NormalizePath(path) abort
5+
let l:path = substitute(a:path, '\\ ', ' ', 'g')
6+
return substitute(resolve(fnamemodify(l:path, ':p')), '\\', '/', 'g')
7+
endfunction
8+
9+
function! prettier#resolver#executable#isUnderPluginRoot(path) abort
10+
if type(a:path) != type('') || a:path ==# ''
11+
return 0
12+
endif
13+
14+
if a:path !~# '^\(/\|[A-Za-z]:[/\\]\)'
15+
return 0
16+
endif
17+
18+
let l:plugin_root = s:NormalizePath(s:PLUGIN_ROOT_DIR)
19+
let l:path = s:NormalizePath(a:path)
20+
return l:path ==# l:plugin_root || stridx(l:path, l:plugin_root . '/') ==# 0
21+
endfunction
222

323
" By default we will search for the following
424
" => user defined prettier cli path from vim configuration file

doc/prettier.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ However they can be configured by:
193193
" default: ''
194194
let g:prettier#config#parser = ''
195195
196+
" Prettier plugin paths to load. Accepts a string or list of strings.
197+
" default: []
198+
let g:prettier#config#plugins = []
199+
196200
" cli-override|file-override|prefer-file
197201
" default: 'file-override'
198202
let g:prettier#config#config_precedence = 'file-override'

ftplugin/php.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
let s:ROOT_DIR = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
2+
let s:plugin_path = s:ROOT_DIR . '/node_modules/@prettier/plugin-php/src/index.js'
3+
14
let b:prettier_ft_default_args = {
25
\ 'parser': 'php',
36
\ }
7+
8+
if filereadable(s:plugin_path)
9+
let b:prettier_ft_default_args['bundledPlugins'] = [s:plugin_path]
10+
endif

ftplugin/xml.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
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
33
if expand('%:e') ==# 'xml'
4+
let s:ROOT_DIR = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
5+
let s:plugin_path = s:ROOT_DIR . '/node_modules/@prettier/plugin-xml/src/plugin.js'
6+
47
let b:prettier_ft_default_args = {
58
\ 'parser': 'xml',
69
\ }
10+
11+
if filereadable(s:plugin_path)
12+
let b:prettier_ft_default_args['bundledPlugins'] = [s:plugin_path]
13+
endif
714
endif

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"url": "git://github.com/prettier/vim-prettier.git"
1010
},
1111
"scripts": {
12-
"test": "vim --version && LOG_LEVEL=error jest",
12+
"test": "node scripts/vim-version.js && LOG_LEVEL=error jest",
13+
"test:smoke": "node scripts/vim-version.js && LOG_LEVEL=error jest tests/formatting.test.js --runInBand --testNamePattern=\"Prettier config version detection works inside vim-driver execute\"",
1314
"lint": "vint --version && vint ."
1415
},
1516
"dependencies": {

plugin/prettier.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ let g:prettier#config#use_tabs = get(g:,'prettier#config#use_tabs', 'auto')
7979
" See more: https://prettier.io/docs/en/options.html#parser
8080
let g:prettier#config#parser = get(g:,'prettier#config#parser', '')
8181

82+
" Prettier plugin paths to load. Accepts a string or list of strings.
83+
let g:prettier#config#plugins = get(g:, 'prettier#config#plugins', [])
84+
8285
" cli-override|file-override|prefer-file
8386
" default: 'file-override'
8487
" See more: https://prettier.io/docs/en/cli.html#--config-precedence

0 commit comments

Comments
 (0)