|
4 | 4 | --- |
5 | 5 | --- Language server for Swift and C/C++/Objective-C. |
6 | 6 |
|
7 | | -local util = require 'lspconfig.util' |
8 | | - |
9 | 7 | return { |
10 | 8 | cmd = { 'sourcekit-lsp' }, |
11 | 9 | filetypes = { 'swift', 'objc', 'objcpp', 'c', 'cpp' }, |
12 | 10 | root_dir = function(bufnr, on_dir) |
13 | | - local filename = vim.api.nvim_buf_get_name(bufnr) |
14 | 11 | 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' }) |
20 | 23 | ) |
21 | 24 | end, |
22 | 25 | get_language_id = function(_, ftype) |
|
0 commit comments