├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── .vim └── coc-settings.json ├── LICENSE ├── README.md ├── biome.json ├── esbuild.js ├── package-lock.json ├── package.json ├── src └── index.ts └── tsconfig.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "21:00" 8 | open-pull-requests-limit: 10 9 | reviewers: 10 | - fannheyward 11 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: biome check 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | node-version: [20] 19 | 20 | env: 21 | NODE_ENV: test 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Use Node.js ${{ matrix.node-version }} 26 | uses: actions/setup-node@v4 27 | with: 28 | node-version: ${{ matrix.node-version }} 29 | - name: npm ci 30 | run: | 31 | npm ci 32 | - name: biome format 33 | run: | 34 | npm run fmt 35 | - name: biome check 36 | run: | 37 | npm run lint 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | node_modules 3 | tsconfig.json 4 | *.map 5 | .tags 6 | .DS_Store 7 | esbuild.js 8 | biome.json 9 | .vim 10 | webpack.config.js 11 | yarn.lock 12 | yarn-error.log 13 | .github 14 | .eslintrc.js 15 | .prettierrc 16 | .eslintrc.js 17 | -------------------------------------------------------------------------------- /.vim/coc-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.enable": false 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Heyward Fann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coc-biome 2 | 3 | [Biome](https://github.com/biomejs/biome) extension for coc.nvim 4 | 5 | ## Install 6 | 7 | `:CocInstall coc-biome` 8 | 9 | ## Configurations 10 | 11 | - `biome.enable`: enable coc-biome, default `true` 12 | - `biome.bin`: custom Biome binary path. By default, coc-biome only uses local `biome` binary in your project 13 | - `biome.requireConfiguration`: Require a `biome.json` file to enable Biome's formatting and linting, default `true` 14 | 15 | ## License 16 | 17 | MIT 18 | 19 | --- 20 | 21 | > This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension) 22 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", 3 | "linter": { 4 | "enabled": true, 5 | "rules": { 6 | "recommended": true 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /esbuild.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-var-requires */ 2 | async function start() { 3 | await require("esbuild").build({ 4 | entryPoints: ["src/index.ts"], 5 | bundle: true, 6 | minify: process.env.NODE_ENV === "production", 7 | sourcemap: process.env.NODE_ENV === "development", 8 | mainFields: ["module", "main"], 9 | external: ["coc.nvim"], 10 | platform: "node", 11 | target: "node16", 12 | outfile: "lib/index.js", 13 | }); 14 | } 15 | 16 | start().catch((e) => { 17 | console.error(e); 18 | }); 19 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coc-biome", 3 | "version": "1.8.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "coc-biome", 9 | "version": "1.8.0", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "@biomejs/biome": "^1.8.3", 13 | "@types/node": "16", 14 | "coc.nvim": "^0.0.83-next.18", 15 | "esbuild": "^0.25.0", 16 | "typescript": "^5.5.4" 17 | }, 18 | "engines": { 19 | "coc": "^0.0.82" 20 | } 21 | }, 22 | "node_modules/@biomejs/biome": { 23 | "version": "1.9.4", 24 | "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz", 25 | "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==", 26 | "dev": true, 27 | "hasInstallScript": true, 28 | "bin": { 29 | "biome": "bin/biome" 30 | }, 31 | "engines": { 32 | "node": ">=14.21.3" 33 | }, 34 | "funding": { 35 | "type": "opencollective", 36 | "url": "https://opencollective.com/biome" 37 | }, 38 | "optionalDependencies": { 39 | "@biomejs/cli-darwin-arm64": "1.9.4", 40 | "@biomejs/cli-darwin-x64": "1.9.4", 41 | "@biomejs/cli-linux-arm64": "1.9.4", 42 | "@biomejs/cli-linux-arm64-musl": "1.9.4", 43 | "@biomejs/cli-linux-x64": "1.9.4", 44 | "@biomejs/cli-linux-x64-musl": "1.9.4", 45 | "@biomejs/cli-win32-arm64": "1.9.4", 46 | "@biomejs/cli-win32-x64": "1.9.4" 47 | } 48 | }, 49 | "node_modules/@biomejs/cli-darwin-arm64": { 50 | "version": "1.9.4", 51 | "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz", 52 | "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==", 53 | "cpu": [ 54 | "arm64" 55 | ], 56 | "dev": true, 57 | "optional": true, 58 | "os": [ 59 | "darwin" 60 | ], 61 | "engines": { 62 | "node": ">=14.21.3" 63 | } 64 | }, 65 | "node_modules/@biomejs/cli-darwin-x64": { 66 | "version": "1.9.4", 67 | "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz", 68 | "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==", 69 | "cpu": [ 70 | "x64" 71 | ], 72 | "dev": true, 73 | "optional": true, 74 | "os": [ 75 | "darwin" 76 | ], 77 | "engines": { 78 | "node": ">=14.21.3" 79 | } 80 | }, 81 | "node_modules/@biomejs/cli-linux-arm64": { 82 | "version": "1.9.4", 83 | "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz", 84 | "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==", 85 | "cpu": [ 86 | "arm64" 87 | ], 88 | "dev": true, 89 | "optional": true, 90 | "os": [ 91 | "linux" 92 | ], 93 | "engines": { 94 | "node": ">=14.21.3" 95 | } 96 | }, 97 | "node_modules/@biomejs/cli-linux-arm64-musl": { 98 | "version": "1.9.4", 99 | "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz", 100 | "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==", 101 | "cpu": [ 102 | "arm64" 103 | ], 104 | "dev": true, 105 | "optional": true, 106 | "os": [ 107 | "linux" 108 | ], 109 | "engines": { 110 | "node": ">=14.21.3" 111 | } 112 | }, 113 | "node_modules/@biomejs/cli-linux-x64": { 114 | "version": "1.9.4", 115 | "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz", 116 | "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==", 117 | "cpu": [ 118 | "x64" 119 | ], 120 | "dev": true, 121 | "optional": true, 122 | "os": [ 123 | "linux" 124 | ], 125 | "engines": { 126 | "node": ">=14.21.3" 127 | } 128 | }, 129 | "node_modules/@biomejs/cli-linux-x64-musl": { 130 | "version": "1.9.4", 131 | "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz", 132 | "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==", 133 | "cpu": [ 134 | "x64" 135 | ], 136 | "dev": true, 137 | "optional": true, 138 | "os": [ 139 | "linux" 140 | ], 141 | "engines": { 142 | "node": ">=14.21.3" 143 | } 144 | }, 145 | "node_modules/@biomejs/cli-win32-arm64": { 146 | "version": "1.9.4", 147 | "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz", 148 | "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==", 149 | "cpu": [ 150 | "arm64" 151 | ], 152 | "dev": true, 153 | "optional": true, 154 | "os": [ 155 | "win32" 156 | ], 157 | "engines": { 158 | "node": ">=14.21.3" 159 | } 160 | }, 161 | "node_modules/@biomejs/cli-win32-x64": { 162 | "version": "1.9.4", 163 | "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz", 164 | "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==", 165 | "cpu": [ 166 | "x64" 167 | ], 168 | "dev": true, 169 | "optional": true, 170 | "os": [ 171 | "win32" 172 | ], 173 | "engines": { 174 | "node": ">=14.21.3" 175 | } 176 | }, 177 | "node_modules/@esbuild/aix-ppc64": { 178 | "version": "0.25.5", 179 | "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz", 180 | "integrity": "sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA==", 181 | "cpu": [ 182 | "ppc64" 183 | ], 184 | "dev": true, 185 | "license": "MIT", 186 | "optional": true, 187 | "os": [ 188 | "aix" 189 | ], 190 | "engines": { 191 | "node": ">=18" 192 | } 193 | }, 194 | "node_modules/@esbuild/android-arm": { 195 | "version": "0.25.5", 196 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.5.tgz", 197 | "integrity": "sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA==", 198 | "cpu": [ 199 | "arm" 200 | ], 201 | "dev": true, 202 | "license": "MIT", 203 | "optional": true, 204 | "os": [ 205 | "android" 206 | ], 207 | "engines": { 208 | "node": ">=18" 209 | } 210 | }, 211 | "node_modules/@esbuild/android-arm64": { 212 | "version": "0.25.5", 213 | "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.5.tgz", 214 | "integrity": "sha512-VGzGhj4lJO+TVGV1v8ntCZWJktV7SGCs3Pn1GRWI1SBFtRALoomm8k5E9Pmwg3HOAal2VDc2F9+PM/rEY6oIDg==", 215 | "cpu": [ 216 | "arm64" 217 | ], 218 | "dev": true, 219 | "license": "MIT", 220 | "optional": true, 221 | "os": [ 222 | "android" 223 | ], 224 | "engines": { 225 | "node": ">=18" 226 | } 227 | }, 228 | "node_modules/@esbuild/android-x64": { 229 | "version": "0.25.5", 230 | "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.5.tgz", 231 | "integrity": "sha512-D2GyJT1kjvO//drbRT3Hib9XPwQeWd9vZoBJn+bu/lVsOZ13cqNdDeqIF/xQ5/VmWvMduP6AmXvylO/PIc2isw==", 232 | "cpu": [ 233 | "x64" 234 | ], 235 | "dev": true, 236 | "license": "MIT", 237 | "optional": true, 238 | "os": [ 239 | "android" 240 | ], 241 | "engines": { 242 | "node": ">=18" 243 | } 244 | }, 245 | "node_modules/@esbuild/darwin-arm64": { 246 | "version": "0.25.5", 247 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz", 248 | "integrity": "sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ==", 249 | "cpu": [ 250 | "arm64" 251 | ], 252 | "dev": true, 253 | "license": "MIT", 254 | "optional": true, 255 | "os": [ 256 | "darwin" 257 | ], 258 | "engines": { 259 | "node": ">=18" 260 | } 261 | }, 262 | "node_modules/@esbuild/darwin-x64": { 263 | "version": "0.25.5", 264 | "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.5.tgz", 265 | "integrity": "sha512-1iT4FVL0dJ76/q1wd7XDsXrSW+oLoquptvh4CLR4kITDtqi2e/xwXwdCVH8hVHU43wgJdsq7Gxuzcs6Iq/7bxQ==", 266 | "cpu": [ 267 | "x64" 268 | ], 269 | "dev": true, 270 | "license": "MIT", 271 | "optional": true, 272 | "os": [ 273 | "darwin" 274 | ], 275 | "engines": { 276 | "node": ">=18" 277 | } 278 | }, 279 | "node_modules/@esbuild/freebsd-arm64": { 280 | "version": "0.25.5", 281 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.5.tgz", 282 | "integrity": "sha512-nk4tGP3JThz4La38Uy/gzyXtpkPW8zSAmoUhK9xKKXdBCzKODMc2adkB2+8om9BDYugz+uGV7sLmpTYzvmz6Sw==", 283 | "cpu": [ 284 | "arm64" 285 | ], 286 | "dev": true, 287 | "license": "MIT", 288 | "optional": true, 289 | "os": [ 290 | "freebsd" 291 | ], 292 | "engines": { 293 | "node": ">=18" 294 | } 295 | }, 296 | "node_modules/@esbuild/freebsd-x64": { 297 | "version": "0.25.5", 298 | "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.5.tgz", 299 | "integrity": "sha512-PrikaNjiXdR2laW6OIjlbeuCPrPaAl0IwPIaRv+SMV8CiM8i2LqVUHFC1+8eORgWyY7yhQY+2U2fA55mBzReaw==", 300 | "cpu": [ 301 | "x64" 302 | ], 303 | "dev": true, 304 | "license": "MIT", 305 | "optional": true, 306 | "os": [ 307 | "freebsd" 308 | ], 309 | "engines": { 310 | "node": ">=18" 311 | } 312 | }, 313 | "node_modules/@esbuild/linux-arm": { 314 | "version": "0.25.5", 315 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.5.tgz", 316 | "integrity": "sha512-cPzojwW2okgh7ZlRpcBEtsX7WBuqbLrNXqLU89GxWbNt6uIg78ET82qifUy3W6OVww6ZWobWub5oqZOVtwolfw==", 317 | "cpu": [ 318 | "arm" 319 | ], 320 | "dev": true, 321 | "license": "MIT", 322 | "optional": true, 323 | "os": [ 324 | "linux" 325 | ], 326 | "engines": { 327 | "node": ">=18" 328 | } 329 | }, 330 | "node_modules/@esbuild/linux-arm64": { 331 | "version": "0.25.5", 332 | "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.5.tgz", 333 | "integrity": "sha512-Z9kfb1v6ZlGbWj8EJk9T6czVEjjq2ntSYLY2cw6pAZl4oKtfgQuS4HOq41M/BcoLPzrUbNd+R4BXFyH//nHxVg==", 334 | "cpu": [ 335 | "arm64" 336 | ], 337 | "dev": true, 338 | "license": "MIT", 339 | "optional": true, 340 | "os": [ 341 | "linux" 342 | ], 343 | "engines": { 344 | "node": ">=18" 345 | } 346 | }, 347 | "node_modules/@esbuild/linux-ia32": { 348 | "version": "0.25.5", 349 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.5.tgz", 350 | "integrity": "sha512-sQ7l00M8bSv36GLV95BVAdhJ2QsIbCuCjh/uYrWiMQSUuV+LpXwIqhgJDcvMTj+VsQmqAHL2yYaasENvJ7CDKA==", 351 | "cpu": [ 352 | "ia32" 353 | ], 354 | "dev": true, 355 | "license": "MIT", 356 | "optional": true, 357 | "os": [ 358 | "linux" 359 | ], 360 | "engines": { 361 | "node": ">=18" 362 | } 363 | }, 364 | "node_modules/@esbuild/linux-loong64": { 365 | "version": "0.25.5", 366 | "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.5.tgz", 367 | "integrity": "sha512-0ur7ae16hDUC4OL5iEnDb0tZHDxYmuQyhKhsPBV8f99f6Z9KQM02g33f93rNH5A30agMS46u2HP6qTdEt6Q1kg==", 368 | "cpu": [ 369 | "loong64" 370 | ], 371 | "dev": true, 372 | "license": "MIT", 373 | "optional": true, 374 | "os": [ 375 | "linux" 376 | ], 377 | "engines": { 378 | "node": ">=18" 379 | } 380 | }, 381 | "node_modules/@esbuild/linux-mips64el": { 382 | "version": "0.25.5", 383 | "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.5.tgz", 384 | "integrity": "sha512-kB/66P1OsHO5zLz0i6X0RxlQ+3cu0mkxS3TKFvkb5lin6uwZ/ttOkP3Z8lfR9mJOBk14ZwZ9182SIIWFGNmqmg==", 385 | "cpu": [ 386 | "mips64el" 387 | ], 388 | "dev": true, 389 | "license": "MIT", 390 | "optional": true, 391 | "os": [ 392 | "linux" 393 | ], 394 | "engines": { 395 | "node": ">=18" 396 | } 397 | }, 398 | "node_modules/@esbuild/linux-ppc64": { 399 | "version": "0.25.5", 400 | "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.5.tgz", 401 | "integrity": "sha512-UZCmJ7r9X2fe2D6jBmkLBMQetXPXIsZjQJCjgwpVDz+YMcS6oFR27alkgGv3Oqkv07bxdvw7fyB71/olceJhkQ==", 402 | "cpu": [ 403 | "ppc64" 404 | ], 405 | "dev": true, 406 | "license": "MIT", 407 | "optional": true, 408 | "os": [ 409 | "linux" 410 | ], 411 | "engines": { 412 | "node": ">=18" 413 | } 414 | }, 415 | "node_modules/@esbuild/linux-riscv64": { 416 | "version": "0.25.5", 417 | "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.5.tgz", 418 | "integrity": "sha512-kTxwu4mLyeOlsVIFPfQo+fQJAV9mh24xL+y+Bm6ej067sYANjyEw1dNHmvoqxJUCMnkBdKpvOn0Ahql6+4VyeA==", 419 | "cpu": [ 420 | "riscv64" 421 | ], 422 | "dev": true, 423 | "license": "MIT", 424 | "optional": true, 425 | "os": [ 426 | "linux" 427 | ], 428 | "engines": { 429 | "node": ">=18" 430 | } 431 | }, 432 | "node_modules/@esbuild/linux-s390x": { 433 | "version": "0.25.5", 434 | "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.5.tgz", 435 | "integrity": "sha512-K2dSKTKfmdh78uJ3NcWFiqyRrimfdinS5ErLSn3vluHNeHVnBAFWC8a4X5N+7FgVE1EjXS1QDZbpqZBjfrqMTQ==", 436 | "cpu": [ 437 | "s390x" 438 | ], 439 | "dev": true, 440 | "license": "MIT", 441 | "optional": true, 442 | "os": [ 443 | "linux" 444 | ], 445 | "engines": { 446 | "node": ">=18" 447 | } 448 | }, 449 | "node_modules/@esbuild/linux-x64": { 450 | "version": "0.25.5", 451 | "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.5.tgz", 452 | "integrity": "sha512-uhj8N2obKTE6pSZ+aMUbqq+1nXxNjZIIjCjGLfsWvVpy7gKCOL6rsY1MhRh9zLtUtAI7vpgLMK6DxjO8Qm9lJw==", 453 | "cpu": [ 454 | "x64" 455 | ], 456 | "dev": true, 457 | "license": "MIT", 458 | "optional": true, 459 | "os": [ 460 | "linux" 461 | ], 462 | "engines": { 463 | "node": ">=18" 464 | } 465 | }, 466 | "node_modules/@esbuild/netbsd-arm64": { 467 | "version": "0.25.5", 468 | "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.5.tgz", 469 | "integrity": "sha512-pwHtMP9viAy1oHPvgxtOv+OkduK5ugofNTVDilIzBLpoWAM16r7b/mxBvfpuQDpRQFMfuVr5aLcn4yveGvBZvw==", 470 | "cpu": [ 471 | "arm64" 472 | ], 473 | "dev": true, 474 | "license": "MIT", 475 | "optional": true, 476 | "os": [ 477 | "netbsd" 478 | ], 479 | "engines": { 480 | "node": ">=18" 481 | } 482 | }, 483 | "node_modules/@esbuild/netbsd-x64": { 484 | "version": "0.25.5", 485 | "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.5.tgz", 486 | "integrity": "sha512-WOb5fKrvVTRMfWFNCroYWWklbnXH0Q5rZppjq0vQIdlsQKuw6mdSihwSo4RV/YdQ5UCKKvBy7/0ZZYLBZKIbwQ==", 487 | "cpu": [ 488 | "x64" 489 | ], 490 | "dev": true, 491 | "license": "MIT", 492 | "optional": true, 493 | "os": [ 494 | "netbsd" 495 | ], 496 | "engines": { 497 | "node": ">=18" 498 | } 499 | }, 500 | "node_modules/@esbuild/openbsd-arm64": { 501 | "version": "0.25.5", 502 | "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.5.tgz", 503 | "integrity": "sha512-7A208+uQKgTxHd0G0uqZO8UjK2R0DDb4fDmERtARjSHWxqMTye4Erz4zZafx7Di9Cv+lNHYuncAkiGFySoD+Mw==", 504 | "cpu": [ 505 | "arm64" 506 | ], 507 | "dev": true, 508 | "license": "MIT", 509 | "optional": true, 510 | "os": [ 511 | "openbsd" 512 | ], 513 | "engines": { 514 | "node": ">=18" 515 | } 516 | }, 517 | "node_modules/@esbuild/openbsd-x64": { 518 | "version": "0.25.5", 519 | "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.5.tgz", 520 | "integrity": "sha512-G4hE405ErTWraiZ8UiSoesH8DaCsMm0Cay4fsFWOOUcz8b8rC6uCvnagr+gnioEjWn0wC+o1/TAHt+It+MpIMg==", 521 | "cpu": [ 522 | "x64" 523 | ], 524 | "dev": true, 525 | "license": "MIT", 526 | "optional": true, 527 | "os": [ 528 | "openbsd" 529 | ], 530 | "engines": { 531 | "node": ">=18" 532 | } 533 | }, 534 | "node_modules/@esbuild/sunos-x64": { 535 | "version": "0.25.5", 536 | "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.5.tgz", 537 | "integrity": "sha512-l+azKShMy7FxzY0Rj4RCt5VD/q8mG/e+mDivgspo+yL8zW7qEwctQ6YqKX34DTEleFAvCIUviCFX1SDZRSyMQA==", 538 | "cpu": [ 539 | "x64" 540 | ], 541 | "dev": true, 542 | "license": "MIT", 543 | "optional": true, 544 | "os": [ 545 | "sunos" 546 | ], 547 | "engines": { 548 | "node": ">=18" 549 | } 550 | }, 551 | "node_modules/@esbuild/win32-arm64": { 552 | "version": "0.25.5", 553 | "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.5.tgz", 554 | "integrity": "sha512-O2S7SNZzdcFG7eFKgvwUEZ2VG9D/sn/eIiz8XRZ1Q/DO5a3s76Xv0mdBzVM5j5R639lXQmPmSo0iRpHqUUrsxw==", 555 | "cpu": [ 556 | "arm64" 557 | ], 558 | "dev": true, 559 | "license": "MIT", 560 | "optional": true, 561 | "os": [ 562 | "win32" 563 | ], 564 | "engines": { 565 | "node": ">=18" 566 | } 567 | }, 568 | "node_modules/@esbuild/win32-ia32": { 569 | "version": "0.25.5", 570 | "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.5.tgz", 571 | "integrity": "sha512-onOJ02pqs9h1iMJ1PQphR+VZv8qBMQ77Klcsqv9CNW2w6yLqoURLcgERAIurY6QE63bbLuqgP9ATqajFLK5AMQ==", 572 | "cpu": [ 573 | "ia32" 574 | ], 575 | "dev": true, 576 | "license": "MIT", 577 | "optional": true, 578 | "os": [ 579 | "win32" 580 | ], 581 | "engines": { 582 | "node": ">=18" 583 | } 584 | }, 585 | "node_modules/@esbuild/win32-x64": { 586 | "version": "0.25.5", 587 | "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz", 588 | "integrity": "sha512-TXv6YnJ8ZMVdX+SXWVBo/0p8LTcrUYngpWjvm91TMjjBQii7Oz11Lw5lbDV5Y0TzuhSJHwiH4hEtC1I42mMS0g==", 589 | "cpu": [ 590 | "x64" 591 | ], 592 | "dev": true, 593 | "license": "MIT", 594 | "optional": true, 595 | "os": [ 596 | "win32" 597 | ], 598 | "engines": { 599 | "node": ">=18" 600 | } 601 | }, 602 | "node_modules/@types/node": { 603 | "version": "16.18.118", 604 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.118.tgz", 605 | "integrity": "sha512-YgPbVGrf+mL4Qp8KTcd18OXfIsm1QYwHkldmWTNIR8aZH2EYSPNyLFFZHEXZIGYvYrwnW++xGoWyt4w279QDrQ==", 606 | "dev": true 607 | }, 608 | "node_modules/coc.nvim": { 609 | "version": "0.0.83-next.22", 610 | "resolved": "https://registry.npmjs.org/coc.nvim/-/coc.nvim-0.0.83-next.22.tgz", 611 | "integrity": "sha512-Ru9LOZp/Cz7et51cq+LEEWrM2MaT3u2xBcITn+NKQBk2uxbQcV81zTwOa4e3YWnbLpgmqSeVJ5tVnNlmTrMC2Q==", 612 | "dev": true, 613 | "license": "MIT", 614 | "engines": { 615 | "node": ">=16.18.0" 616 | }, 617 | "funding": { 618 | "type": "opencollective", 619 | "url": "https://opencollective.com/cocnvim" 620 | }, 621 | "peerDependencies": { 622 | "@types/node": "^16.18.0" 623 | } 624 | }, 625 | "node_modules/esbuild": { 626 | "version": "0.25.5", 627 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz", 628 | "integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==", 629 | "dev": true, 630 | "hasInstallScript": true, 631 | "license": "MIT", 632 | "bin": { 633 | "esbuild": "bin/esbuild" 634 | }, 635 | "engines": { 636 | "node": ">=18" 637 | }, 638 | "optionalDependencies": { 639 | "@esbuild/aix-ppc64": "0.25.5", 640 | "@esbuild/android-arm": "0.25.5", 641 | "@esbuild/android-arm64": "0.25.5", 642 | "@esbuild/android-x64": "0.25.5", 643 | "@esbuild/darwin-arm64": "0.25.5", 644 | "@esbuild/darwin-x64": "0.25.5", 645 | "@esbuild/freebsd-arm64": "0.25.5", 646 | "@esbuild/freebsd-x64": "0.25.5", 647 | "@esbuild/linux-arm": "0.25.5", 648 | "@esbuild/linux-arm64": "0.25.5", 649 | "@esbuild/linux-ia32": "0.25.5", 650 | "@esbuild/linux-loong64": "0.25.5", 651 | "@esbuild/linux-mips64el": "0.25.5", 652 | "@esbuild/linux-ppc64": "0.25.5", 653 | "@esbuild/linux-riscv64": "0.25.5", 654 | "@esbuild/linux-s390x": "0.25.5", 655 | "@esbuild/linux-x64": "0.25.5", 656 | "@esbuild/netbsd-arm64": "0.25.5", 657 | "@esbuild/netbsd-x64": "0.25.5", 658 | "@esbuild/openbsd-arm64": "0.25.5", 659 | "@esbuild/openbsd-x64": "0.25.5", 660 | "@esbuild/sunos-x64": "0.25.5", 661 | "@esbuild/win32-arm64": "0.25.5", 662 | "@esbuild/win32-ia32": "0.25.5", 663 | "@esbuild/win32-x64": "0.25.5" 664 | } 665 | }, 666 | "node_modules/typescript": { 667 | "version": "5.8.3", 668 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", 669 | "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", 670 | "dev": true, 671 | "license": "Apache-2.0", 672 | "bin": { 673 | "tsc": "bin/tsc", 674 | "tsserver": "bin/tsserver" 675 | }, 676 | "engines": { 677 | "node": ">=14.17" 678 | } 679 | } 680 | } 681 | } 682 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coc-biome", 3 | "version": "1.8.0", 4 | "description": "Biome extension for coc.nvim", 5 | "author": "Heyward Fann ", 6 | "license": "MIT", 7 | "main": "lib/index.js", 8 | "keywords": [ 9 | "coc.nvim" 10 | ], 11 | "engines": { 12 | "coc": "^0.0.82" 13 | }, 14 | "scripts": { 15 | "fmt": "biome format --write ./src", 16 | "lint": "biome check ./src", 17 | "build": "node esbuild.js", 18 | "prepare": "node esbuild.js" 19 | }, 20 | "devDependencies": { 21 | "@biomejs/biome": "^1.8.3", 22 | "@types/node": "16", 23 | "coc.nvim": "^0.0.83-next.18", 24 | "esbuild": "^0.25.0", 25 | "typescript": "^5.5.4" 26 | }, 27 | "activationEvents": [ 28 | "onLanguage:css", 29 | "onLanguage:vue", 30 | "onLanguage:json", 31 | "onLanguage:jsonc", 32 | "onLanguage:astro", 33 | "onLanguage:svelte", 34 | "onLanguage:javascript", 35 | "onLanguage:javascriptreact", 36 | "onLanguage:typescript", 37 | "onLanguage:typescriptreact" 38 | ], 39 | "contributes": { 40 | "jsonValidation": [ 41 | { 42 | "fileMatch": "biome.jsonc", 43 | "url": "https://raw.githubusercontent.com/biomejs/biome/main/packages/%40biomejs/biome/configuration_schema.json" 44 | }, 45 | { 46 | "fileMatch": "biome.json", 47 | "url": "https://raw.githubusercontent.com/biomejs/biome/main/packages/%40biomejs/biome/configuration_schema.json" 48 | } 49 | ], 50 | "configuration": { 51 | "type": "object", 52 | "title": "coc-biome configuration", 53 | "properties": { 54 | "biome.enable": { 55 | "type": "boolean", 56 | "default": true, 57 | "description": "Enable coc-biome extension" 58 | }, 59 | "biome.bin": { 60 | "type": [ 61 | "string", 62 | "null" 63 | ], 64 | "default": null, 65 | "description": "Custom biome binary path" 66 | }, 67 | "biome.requireConfiguration": { 68 | "type": "boolean", 69 | "default": true, 70 | "markdownDescription": "Require a Biome configuration file to enable syntax errors, formatting and linting." 71 | }, 72 | "biome.trace.server": { 73 | "type": "string", 74 | "default": "off", 75 | "enum": [ 76 | "off", 77 | "messages", 78 | "verbose" 79 | ], 80 | "enumDescriptions": [ 81 | "No traces", 82 | "Error only", 83 | "Full log" 84 | ], 85 | "description": "Traces the communication between VS Code and the language server." 86 | } 87 | } 88 | }, 89 | "commands": [] 90 | }, 91 | "dependencies": {} 92 | } 93 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { spawn } from "node:child_process"; 2 | import { existsSync } from "node:fs"; 3 | import { type Socket, connect } from "node:net"; 4 | import os from "node:os"; 5 | import { join } from "node:path"; 6 | import { 7 | type ExtensionContext, 8 | LanguageClient, 9 | type LanguageClientOptions, 10 | type ServerOptions, 11 | type StreamInfo, 12 | services, 13 | window, 14 | workspace, 15 | } from "coc.nvim"; 16 | 17 | function resolveBiomeBin(): string { 18 | // 1. biome.bin in coc-settings 19 | // 2. local node_modules 20 | const cfg = workspace.getConfiguration("biome"); 21 | let bin = cfg.get("bin", null); 22 | if (bin && existsSync(bin)) { 23 | return bin; 24 | } 25 | 26 | bin = join(workspace.root, "node_modules", ".bin", "biome"); 27 | return existsSync(bin) ? bin : ""; 28 | } 29 | 30 | async function getSocketPath(command: string): Promise { 31 | const nvim = workspace.nvim; 32 | const tmpdir = ((await nvim.eval("$TMPDIR")) || os.tmpdir()) as string; 33 | const child = spawn(command, ["__print_socket"], { 34 | stdio: "pipe", 35 | shell: true, 36 | env: { ...process.env, TMPDIR: tmpdir }, 37 | }); 38 | return new Promise((resolve, reject) => { 39 | child.once("error", (err) => { 40 | console.error(err); 41 | reject(""); 42 | }); 43 | 44 | child.stdout.on("data", (data) => { 45 | resolve(data.toString("utf-8").trim()); 46 | }); 47 | }); 48 | } 49 | 50 | async function createMessageTransports(command: string): Promise { 51 | const socketPath = await getSocketPath(command); 52 | if (!socketPath) { 53 | throw new Error("Could not get socket path from `biome __print_socket`"); 54 | } 55 | 56 | let socket: Socket; 57 | try { 58 | socket = connect(socketPath); 59 | } catch (err) { 60 | throw new Error(`Could not connect to the Biome server at: ${socketPath}`); 61 | } 62 | 63 | await new Promise((resolve, reject) => { 64 | socket.once("ready", resolve); 65 | socket.once("error", (err) => reject(err)); 66 | }); 67 | 68 | return { writer: socket, reader: socket }; 69 | } 70 | 71 | export async function activate(context: ExtensionContext): Promise { 72 | const enable = workspace.getConfiguration("biome").get("enable"); 73 | if (!enable) { 74 | return; 75 | } 76 | 77 | const outputChannel = window.createOutputChannel("Biome"); 78 | const requireConfiguration = workspace 79 | .getConfiguration("biome") 80 | .get("requireConfiguration", true); 81 | if (requireConfiguration) { 82 | const files = await workspace.findFiles("**/biome.{json,jsonc}"); 83 | if (files.length === 0) { 84 | outputChannel.appendLine("No biome.json file found"); 85 | return; 86 | } 87 | } 88 | 89 | const command = resolveBiomeBin(); 90 | if (!command) { 91 | outputChannel.appendLine("No biome binary file found"); 92 | return; 93 | } 94 | 95 | const serverOptions: ServerOptions = createMessageTransports.bind( 96 | undefined, 97 | command, 98 | ); 99 | const clientOptions: LanguageClientOptions = { 100 | outputChannel, 101 | progressOnInitialization: true, 102 | documentSelector: [ 103 | { scheme: "file", language: "css" }, 104 | { scheme: "file", language: "vue" }, 105 | { scheme: "file", language: "json" }, 106 | { scheme: "file", language: "jsonc" }, 107 | { scheme: "file", language: "astro" }, 108 | { scheme: "file", language: "svelte" }, 109 | { scheme: "file", language: "javascript" }, 110 | { scheme: "file", language: "javascriptreact" }, 111 | { scheme: "file", language: "typescript" }, 112 | { scheme: "file", language: "typescriptreact" }, 113 | ], 114 | }; 115 | 116 | const client = new LanguageClient("biome", serverOptions, clientOptions); 117 | context.subscriptions.push(services.registerLanguageClient(client)); 118 | } 119 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "lib": [ 5 | "es2017", 6 | "es2018" 7 | ], 8 | "module": "commonjs", 9 | "declaration": false, 10 | "sourceMap": false, 11 | "outDir": "lib", 12 | "strict": true, 13 | "moduleResolution": "node", 14 | "noImplicitAny": false, 15 | "esModuleInterop": true 16 | }, 17 | "include": [ 18 | "src" 19 | ] 20 | } 21 | --------------------------------------------------------------------------------