mirror of
https://github.com/neovim/neovim.git
synced 2026-05-02 03:55:00 +00:00
feat(provider): support bun as node.js provider #38517
Problem: Neovim's Node.js provider does not support the Bun package manager. PR #26829 attempted to add this but used a hardcoded path and was abandoned. Solution: - Use `bun pm bin -g` to dynamically locate the global binary directory. - Update `health.lua` to recognize bun installations.
This commit is contained in:
@@ -83,6 +83,22 @@ function! provider#node#Detect() abort
|
||||
let pnpm_opts.job_id = jobstart('pnpm --loglevel silent root -g', pnpm_opts)
|
||||
endif
|
||||
|
||||
if executable('bun')
|
||||
let bun_bin_dir = trim(system(['bun', 'pm', 'bin', '-g']))
|
||||
if v:shell_error == 0 && !empty(bun_bin_dir)
|
||||
if has('win32')
|
||||
"On Windows Node.js cannot execute the .cmd shims created by Bun.
|
||||
let bun_root_dir = fnamemodify(bun_bin_dir, ':h')
|
||||
let bun_default_path = bun_root_dir . '/install/global/node_modules/neovim/bin/cli.js'
|
||||
else
|
||||
let bun_default_path = bun_bin_dir . '/neovim-node-host'
|
||||
endif
|
||||
if filereadable(bun_default_path)
|
||||
return [bun_default_path, '']
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" npm returns the directory faster, so let's check that first
|
||||
if !empty(npm_opts)
|
||||
let result = jobwait([npm_opts.job_id])
|
||||
|
||||
@@ -163,7 +163,7 @@ PERFORMANCE
|
||||
|
||||
PLUGINS
|
||||
|
||||
• todo
|
||||
• provider: add bun support for Node.js plugins
|
||||
|
||||
STARTUP
|
||||
|
||||
|
||||
@@ -174,11 +174,12 @@ local function node()
|
||||
vim.fn.executable('npm') == 0
|
||||
and vim.fn.executable('yarn') == 0
|
||||
and vim.fn.executable('pnpm') == 0
|
||||
and vim.fn.executable('bun') == 0
|
||||
)
|
||||
then
|
||||
health.warn(
|
||||
'`node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.',
|
||||
'Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`) commands work.'
|
||||
'`node` and `npm` (or `yarn`, `pnpm`, `bun`) must be in $PATH.',
|
||||
'Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`, `bun`) commands work.'
|
||||
)
|
||||
return
|
||||
end
|
||||
@@ -199,10 +200,11 @@ local function node()
|
||||
local node_detect_table = vim.fn['provider#node#Detect']() ---@type string[]
|
||||
local host = node_detect_table[1]
|
||||
if host:find('^%s*$') then
|
||||
health.warn('Missing "neovim" npm (or yarn, pnpm) package.', {
|
||||
health.warn('Missing "neovim" npm (or yarn, pnpm, bun) package.', {
|
||||
'Run in shell: npm install -g neovim',
|
||||
'Run in shell (if you use yarn): yarn global add neovim',
|
||||
'Run in shell (if you use pnpm): pnpm install -g neovim',
|
||||
'Run in shell (if you use bun): bun install -g neovim',
|
||||
'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim',
|
||||
})
|
||||
return
|
||||
@@ -255,9 +257,10 @@ local function node()
|
||||
'Run in shell: npm install -g neovim',
|
||||
'Run in shell (if you use yarn): yarn global add neovim',
|
||||
'Run in shell (if you use pnpm): pnpm install -g neovim',
|
||||
'Run in shell (if you use bun): bun install -g neovim',
|
||||
})
|
||||
else
|
||||
health.ok('Latest "neovim" npm/yarn/pnpm package is installed: ' .. current_npm)
|
||||
health.ok('Latest "neovim" npm/yarn/pnpm/bun package is installed: ' .. current_npm)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user