Skip to content

Commit 9a2e074

Browse files
committed
feat(sourcekit): do not use lspconfig.util
1 parent e8b9bbf commit 9a2e074

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lsp/sourcekit.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
---
55
--- Language server for Swift and C/C++/Objective-C.
66

7-
local util = require 'lspconfig.util'
8-
97
return {
108
cmd = { 'sourcekit-lsp' },
119
filetypes = { 'swift', 'objc', 'objcpp', 'c', 'cpp' },
1210
root_dir = function(bufnr, on_dir)
13-
local filename = vim.api.nvim_buf_get_name(bufnr)
1411
on_dir(
15-
util.root_pattern 'buildServer.json'(filename)
16-
or util.root_pattern('*.xcodeproj', '*.xcworkspace')(filename)
17-
-- better to keep it at the end, because some modularized apps contain multiple Package.swift files
18-
or util.root_pattern('compile_commands.json', 'Package.swift')(filename)
19-
or vim.fs.dirname(vim.fs.find('.git', { path = filename, upward = true })[1])
12+
vim.fs.root(bufnr, 'buildServer.json')
13+
or vim.fs.root(bufnr, function(name, _)
14+
local patterns = { '*.xcodeproj', '*.xcworkspace' }
15+
for _, pattern in ipairs(patterns) do
16+
if vim.glob.to_lpeg(pattern):match(name) ~= nil then
17+
return true
18+
end
19+
end
20+
return false
21+
end) -- better to keep it at the end, because some modularized apps contain multiple Package.swift files
22+
or vim.fs.root(bufnr, { 'compile_commands.json', 'Package.swift', '.git' })
2023
)
2124
end,
2225
get_language_id = function(_, ftype)

0 commit comments

Comments
 (0)