fix(lsp)!: pass buffer number to root_dir function

Problem:

The root dir function is not passed any context and can only assume the
current buffer is the one being attached.

The main use case is for getting the path of the buffer using
`nvim_buf_get_name`.

Solution:

Pass the buffer number as the first argument.
This commit is contained in:
Lewis Russell
2025-03-08 09:30:36 +00:00
committed by Lewis Russell
parent 3b0fe2659e
commit debabaf884
3 changed files with 13 additions and 10 deletions

View File

@@ -6348,7 +6348,8 @@ describe('LSP', function()
vim.lsp.config('foo', {
cmd = server.cmd,
filetypes = { 'foo' },
root_dir = function(cb)
root_dir = function(bufnr, cb)
assert(tmp1 == vim.api.nvim_buf_get_name(bufnr))
vim.system({ 'sleep', '0' }, {}, function()
cb('some_dir')
end)