summaryrefslogtreecommitdiff
path: root/nvim/lsp/sourcekit.lua
diff options
context:
space:
mode:
authoranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
committeranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
commitb7ef29a8886a57aadb787807a7c6cf74c1f0ed3a (patch)
tree366a68240fbc9da6b1d567bd6c46d1350ad814de /nvim/lsp/sourcekit.lua
Nixos
Diffstat (limited to 'nvim/lsp/sourcekit.lua')
-rwxr-xr-xnvim/lsp/sourcekit.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/nvim/lsp/sourcekit.lua b/nvim/lsp/sourcekit.lua
new file mode 100755
index 0000000..4292b5f
--- /dev/null
+++ b/nvim/lsp/sourcekit.lua
@@ -0,0 +1,39 @@
+---@brief
+---
+--- https://github.com/swiftlang/sourcekit-lsp
+---
+--- Language server for Swift and C/C++/Objective-C.
+
+local util = require 'lspconfig.util'
+
+return {
+ cmd = { 'sourcekit-lsp' },
+ filetypes = { 'swift', 'objc', 'objcpp', 'c', 'cpp' },
+ root_dir = function(bufnr, on_dir)
+ local filename = vim.api.nvim_buf_get_name(bufnr)
+ on_dir(
+ util.root_pattern 'buildServer.json'(filename)
+ or util.root_pattern('*.xcodeproj', '*.xcworkspace')(filename)
+ -- better to keep it at the end, because some modularized apps contain multiple Package.swift files
+ or util.root_pattern('compile_commands.json', 'Package.swift')(filename)
+ or vim.fs.dirname(vim.fs.find('.git', { path = filename, upward = true })[1])
+ )
+ end,
+ get_language_id = function(_, ftype)
+ local t = { objc = 'objective-c', objcpp = 'objective-cpp' }
+ return t[ftype] or ftype
+ end,
+ capabilities = {
+ workspace = {
+ didChangeWatchedFiles = {
+ dynamicRegistration = true,
+ },
+ },
+ textDocument = {
+ diagnostic = {
+ dynamicRegistration = true,
+ relatedDocumentSupport = true,
+ },
+ },
+ },
+}