@@ -245,7 +245,7 @@ ADDING NEW SERVERS *lspconfig-new*
245
245
246
246
The steps for adding and enabling a new server configuration are:
247
247
248
- 1. Define the configuration (see also | vim.fs.root() | ) : >lua
248
+ 1. Define the configuration: >lua
249
249
local lspconfig = require 'lspconfig'
250
250
local configs = require 'lspconfig.configs'
251
251
@@ -256,7 +256,7 @@ The steps for adding and enabling a new server configuration are:
256
256
cmd = {'/home/neovim/lua-language-server/run.sh'} ,
257
257
filetypes = {'lua'} ,
258
258
root_dir = function(fname)
259
- return lspconfig.util.find_git_ancestor (fname)
259
+ return vim.fs.root (fname, '.git' )
260
260
end,
261
261
settings = {},
262
262
},
@@ -295,34 +295,38 @@ below returns a function that takes as its argument the current buffer path.
295
295
the patterns are specified. >
296
296
root_dir = util.root_pattern('pyproject.toml', 'requirements.txt')
297
297
298
+ - WARNING: `util.root_pattern` is deprecated and will be removed in the future.
299
+ Instead, use >lua
300
+ vim.fs.dirname(vim.fs.find({ 'pyproject.toml', 'requirements.txt' }, { path = fname, upward = true })[1])
301
+ <
298
302
- Locate the first parent dir containing a ".git" file or directory: >lua
299
- vim.fs.dirname(vim.fs.find('.git', { path = root_dir , upward = true })[1])
303
+ vim.fs.dirname(vim.fs.find('.git', { path = fname , upward = true })[1])
300
304
<
301
305
If you have Nvim 0.10 or newer then >lua
302
- vim.fs.root(root_dir , ".git")
306
+ vim.fs.root(fname , ".git")
303
307
<
304
308
can be used instead.
305
- - Note : The old `util.find_git_ancestor` API is deprecated and will
309
+ - WARNING : The old `util.find_git_ancestor` API is deprecated and will
306
310
be removed.
307
311
<
308
312
- Locate the first parent dir containing a "node_modules" dir: >lua
309
- vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir , upward = true })[1])
313
+ vim.fs.dirname(vim.fs.find('node_modules', { path = fname , upward = true })[1])
310
314
<
311
315
If you have Nvim 0.10 or newer then >lua
312
- vim.fs.root(root_dir , "node_modules")
316
+ vim.fs.root(fname , "node_modules")
313
317
<
314
318
can be used instead.
315
- - Note : The old `util.find_node_modules_ancestor` API is deprecated and will
319
+ - WARNING : The old `util.find_node_modules_ancestor` API is deprecated and will
316
320
be removed.
317
321
318
322
- Locate the first parent dir containing a "package.json" dir: >lua
319
- vim.fs.dirname(vim.fs.find('package.json', { path = root_dir , upward = true })[1])
323
+ vim.fs.dirname(vim.fs.find('package.json', { path = fname , upward = true })[1])
320
324
<
321
325
If you have Nvim 0.10 or newer then >lua
322
- vim.fs.root(root_dir , "package.json")
326
+ vim.fs.root(fname , "package.json")
323
327
<
324
328
can be used instead.
325
- - Note : The old `util.find_package_json_ancestor` API is deprecated and will
329
+ - WARNING : The old `util.find_package_json_ancestor` API is deprecated and will
326
330
be removed.
327
331
<
328
332
Note: On Windows, `lspconfig` always assumes forward slash normalized paths with
@@ -354,8 +358,8 @@ for some project structures. Example (for Kotlin): >lua
354
358
'build.gradle.kts', -- Gradle
355
359
}
356
360
root_dir = function(fname)
357
- local primary = util.root_pattern(unpack(root_files))( fname)
358
- local fallback = util.root_pattern(unpack(fallback_root_files))( fname)
361
+ local primary = vim.fs.root( fname, root_files )
362
+ local fallback = vim.fs.root( fname, fallback_root_files )
359
363
return primary or fallback
360
364
end
361
365
<
0 commit comments