update lsp.lua so it works again with sourcekit (swift)

This commit is contained in:
Robin Jenni committed 2026-10-08 08:48:30 +02:00
1 parent 1d77c215ea
commit 00228510f3
1 file changed
+11 -5
+11 -5
View File
@@ -99,6 +99,9 @@ return { {
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions', desc = 'LSP actions',
callback = function(event) callback = function(event)
vim.lsp.inlay_hint.enable(true, { bufnr = event.buf })
vim.lsp.inline_completion.enable(true, { bufnr = event.buf })
-- Autoformat on save -- Autoformat on save
local id = vim.tbl_get(event, 'data', 'client_id') local id = vim.tbl_get(event, 'data', 'client_id')
local client = id and vim.lsp.get_client_by_id(id) local client = id and vim.lsp.get_client_by_id(id)
@@ -196,12 +199,15 @@ return { {
cmd = { cmd = {
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp",
}, },
root_dir = function(filename, _) root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local util = require("lspconfig.util") local util = require("lspconfig.util")
return util.root_pattern("buildServer.json")(filename) on_dir(
or util.root_pattern("*.xcodeproj", "*.xcworkspace")(filename) util.root_pattern("buildServer.json")(fname)
or util.find_git_ancestor(filename) or util.root_pattern("*.xcodeproj", "*.xcworkspace")(fname)
or util.root_pattern("Package.swift")(filename) or util.root_pattern("Package.swift")(fname)
or vim.fs.root(fname, ".git")
)
end, end,
}) })