aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-05-04 14:11:18 -0700
committerGitHub <noreply@github.com>2025-05-04 14:11:18 -0700
commit2a6517453feb6f00e3d64bcb4fde61934897f4bd (patch)
treedc681744b655f6eb40478ef6d7ae5495686f2b71
parentfeat: support :LspStart/LspRestart in Nvim 0.11.2+ #3734 (diff)
downloadnvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.gz
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.bz2
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.lz
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.xz
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.zst
nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.zip
fix(configs): eliminate some usages of root_pattern #3820
Problem: `root_pattern` is not necessary for non-glob patterns. Solution: Replace non-glob cases with `vim.fs.root()`..
-rw-r--r--lsp/elmls.lua5
-rw-r--r--lsp/intelephense.lua6
-rw-r--r--lsp/kotlin_language_server.lua8
-rw-r--r--lsp/lean3ls.lua5
-rw-r--r--lsp/phan.lua6
-rw-r--r--lsp/phpactor.lua6
-rw-r--r--lsp/rust_analyzer.lua6
-rw-r--r--lsp/smarty_ls.lua6
-rw-r--r--lua/lspconfig/util.lua8
9 files changed, 22 insertions, 34 deletions
diff --git a/lsp/elmls.lua b/lsp/elmls.lua
index bee05b89..a7f27789 100644
--- a/lsp/elmls.lua
+++ b/lsp/elmls.lua
@@ -7,11 +7,8 @@
--- npm install -g elm elm-test elm-format @elm-tooling/elm-language-server
--- ```
-local util = require 'lspconfig.util'
local api = vim.api
-local elm_root_pattern = util.root_pattern 'elm.json'
-
return {
cmd = { 'elm-language-server' },
-- TODO(ashkan) if we comment this out, it will allow elmls to operate on elm.json. It seems like it could do that, but no other editor allows it right now.
@@ -20,7 +17,7 @@ return {
local fname = api.nvim_buf_get_name(bufnr)
local filetype = api.nvim_buf_get_option(0, 'filetype')
if filetype == 'elm' or (filetype == 'json' and fname:match 'elm%.json$') then
- on_dir(elm_root_pattern(fname))
+ on_dir(vim.fs.root(fname, 'elm.json'))
return
end
on_dir(nil)
diff --git a/lsp/intelephense.lua b/lsp/intelephense.lua
index bf03985d..b18736a9 100644
--- a/lsp/intelephense.lua
+++ b/lsp/intelephense.lua
@@ -25,17 +25,15 @@
--- }
--- ```
-local util = require 'lspconfig.util'
-
return {
cmd = { 'intelephense', '--stdio' },
filetypes = { 'php' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local cwd = assert(vim.uv.cwd())
- local root = util.root_pattern('composer.json', '.git')(fname)
+ local root = vim.fs.root(fname, { 'composer.json', '.git' })
-- prefer cwd if root is a descendant
- on_dir(vim.fs.relpath(cwd, root) and cwd or root)
+ on_dir(root and vim.fs.relpath(cwd, root) and cwd)
end,
}
diff --git a/lsp/kotlin_language_server.lua b/lsp/kotlin_language_server.lua
index 661822e5..d70afa78 100644
--- a/lsp/kotlin_language_server.lua
+++ b/lsp/kotlin_language_server.lua
@@ -16,10 +16,6 @@
--- For faster startup, you can setup caching by specifying a storagePath
--- in the init_options. The default is your home directory.
-local util = require 'lspconfig.util'
-
-local bin_name = 'kotlin-language-server'
-
--- The presence of one of these files indicates a project root directory
--
-- These are configuration files for the various build systems supported by
@@ -37,9 +33,9 @@ local root_files = {
return {
filetypes = { 'kotlin' },
root_markers = root_files,
- cmd = { bin_name }, -- kotlin-language-server
+ cmd = { 'kotlin-language-server' },
init_options = {
-- Enables caching and use project root to store cache data.
- storagePath = util.root_pattern(unpack(root_files))(vim.fn.expand '%:p:h'),
+ storagePath = vim.fs.root(vim.fn.expand '%:p:h', root_files),
},
}
diff --git a/lsp/lean3ls.lua b/lsp/lean3ls.lua
index 977e04b9..07ff0599 100644
--- a/lsp/lean3ls.lua
+++ b/lsp/lean3ls.lua
@@ -14,8 +14,6 @@
--- that plugin fully handles the setup of the Lean language server,
--- and you shouldn't set up `lean3ls` both with it and `lspconfig`.
-local util = require 'lspconfig.util'
-
return {
cmd = { 'lean-language-server', '--stdio', '--', '-M', '4096', '-T', '100000' },
filetypes = { 'lean3' },
@@ -33,8 +31,7 @@ return {
end
on_dir(
- util.root_pattern 'leanpkg.toml'(fname)
- or util.root_pattern 'leanpkg.path'(fname)
+ vim.fs.root(fname, { 'leanpkg.toml', 'leanpkg.path' })
or stdlib_dir
or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1])
)
diff --git a/lsp/phan.lua b/lsp/phan.lua
index c001f39c..50b0a78a 100644
--- a/lsp/phan.lua
+++ b/lsp/phan.lua
@@ -4,8 +4,6 @@
---
--- Installation: https://github.com/phan/phan#getting-started
-local util = require 'lspconfig.util'
-
local cmd = {
'phan',
'-m',
@@ -25,9 +23,9 @@ return {
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local cwd = assert(vim.uv.cwd())
- local root = util.root_pattern('composer.json', '.git')(fname)
+ local root = vim.fs.root(fname, { 'composer.json', '.git' })
-- prefer cwd if root is a descendant
- on_dir(vim.fs.relpath(cwd, root) and cwd or root)
+ on_dir(root and vim.fs.relpath(cwd, root) and cwd)
end,
}
diff --git a/lsp/phpactor.lua b/lsp/phpactor.lua
index 87e6c59d..9b7d3d82 100644
--- a/lsp/phpactor.lua
+++ b/lsp/phpactor.lua