File tree 5 files changed +21
-22
lines changed
5 files changed +21
-22
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ _check_deprecated_in_nvim_0_11() {
57
57
echo ' Use vim.iter(vim.fs.parents(fname)):find(…) instead of util.path.search_ancestors(fname,…)'
58
58
exit 1
59
59
fi
60
+ if git grep -P ' validate_bufnr' -- ' lsp/*.lua' ; then
61
+ echo
62
+ echo ' Do not use util.validate_bufnr(). Nvim stdlib already treats bufnr=0 as "current buffer".'
63
+ exit 1
64
+ fi
60
65
}
61
66
62
67
_check_deprecated_utils () {
Original file line number Diff line number Diff line change 11
11
--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
12
12
--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
13
13
14
- local util = require ' lspconfig.util'
15
-
16
14
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
17
15
local function switch_source_header (bufnr )
18
16
local method_name = ' textDocument/switchSourceHeader'
19
- bufnr = util .validate_bufnr (bufnr )
20
17
local client = vim .lsp .get_clients ({ bufnr = bufnr , name = ' clangd' })[1 ]
21
18
if not client then
22
19
return vim .notify ((' method %s is not supported by any servers active on the current buffer' ):format (method_name ))
Original file line number Diff line number Diff line change 15
15
---
16
16
--- ```
17
17
18
- local util = require ' lspconfig.util'
19
-
20
18
local bin_name = ' ds-pinyin-lsp'
21
19
if vim .fn .has ' win32' == 1 then
22
20
bin_name = bin_name .. ' .exe'
23
21
end
24
22
25
23
local function ds_pinyin_lsp_off (bufnr )
26
- bufnr = util .validate_bufnr (bufnr )
27
24
local ds_pinyin_lsp_client = vim .lsp .get_clients ({ bufnr = bufnr , name = ' ds_pinyin_lsp' })[1 ]
28
25
if ds_pinyin_lsp_client then
29
26
ds_pinyin_lsp_client .notify (' $/turn/completion' , {
@@ -35,7 +32,6 @@ local function ds_pinyin_lsp_off(bufnr)
35
32
end
36
33
37
34
local function ds_pinyin_lsp_on (bufnr )
38
- bufnr = util .validate_bufnr (bufnr )
39
35
local ds_pinyin_lsp_client = vim .lsp .get_clients ({ bufnr = bufnr , name = ' ds_pinyin_lsp' })[1 ]
40
36
if ds_pinyin_lsp_client then
41
37
ds_pinyin_lsp_client .notify (' $/turn/completion' , {
Original file line number Diff line number Diff line change 24
24
local util = require ' lspconfig.util'
25
25
26
26
local function reload_workspace (bufnr )
27
- bufnr = util .validate_bufnr (bufnr )
28
27
local clients = vim .lsp .get_clients { bufnr = bufnr , name = ' rust_analyzer' }
29
28
for _ , client in ipairs (clients ) do
30
29
vim .notify ' Reloading Cargo Workspace'
Original file line number Diff line number Diff line change @@ -20,20 +20,6 @@ M.default_config = {
20
20
-- global on_setup hook
21
21
M .on_setup = nil
22
22
23
- function M .bufname_valid (bufname )
24
- if bufname :match ' ^/' or bufname :match ' ^[a-zA-Z]:' or bufname :match ' ^zipfile://' or bufname :match ' ^tarfile:' then
25
- return true
26
- end
27
- return false
28
- end
29
-
30
- function M .validate_bufnr (bufnr )
31
- if nvim_eleven then
32
- validate (' bufnr' , bufnr , ' number' )
33
- end
34
- return bufnr == 0 and api .nvim_get_current_buf () or bufnr
35
- end
36
-
37
23
local function escape_wildcards (path )
38
24
return path :gsub (' ([%[%]%?%*])' , ' \\ %1' )
39
25
end
@@ -374,4 +360,20 @@ function M.get_managed_clients()
374
360
return clients
375
361
end
376
362
363
+ --- @deprecated Will be removed. Do not use.
364
+ function M .bufname_valid (bufname )
365
+ if bufname :match ' ^/' or bufname :match ' ^[a-zA-Z]:' or bufname :match ' ^zipfile://' or bufname :match ' ^tarfile:' then
366
+ return true
367
+ end
368
+ return false
369
+ end
370
+
371
+ --- @deprecated Will be removed. Do not use.
372
+ function M .validate_bufnr (bufnr )
373
+ if nvim_eleven then
374
+ validate (' bufnr' , bufnr , ' number' )
375
+ end
376
+ return bufnr == 0 and api .nvim_get_current_buf () or bufnr
377
+ end
378
+
377
379
return M
You can’t perform that action at this time.
0 commit comments