Open ntdkhang opened 1 year ago
Hmmm I believe you haven't installed autocompletor? or which one are you using?
For xbase to take over and configure the setup. You need to have a configuration defined in xbase opts:
sourcekit = {
on_attach = function() end,
handlers = function() end,
capabilities = function() end,
},
I'm using lsp-zero.nvim which requires nvim-lspconfig and mason.nvim.
I tried adding that sourcekit opt and it prints this error when opening the swift file:
[lspconfig] unhandled error: vim/shared.lua:0: after the second argument: expected table, got function
Oh, my bad, actually try this:
sourcekit = { },
That's what I did initially and it didn't work
How did you setup the sourcekit-lsp?
Well I have custom setup. I use cmp for completion which has it's own complex setup. hmm I guess maybe you are missing https://github.com/hrsh7th/cmp-nvim-lsp
local dcapabilities = vim.lsp.protocol.make_client_capabilities()
local capabilities = vim.tbl_deep_extend("force", dcapabilities, {
offsetEncoding = { "utf-16" }, -- fix issue with null-ls and c servers
experimental = {
hoverActions = true,
hoverRange = true,
serverStatusNotification = true,
snippetTextEdit = true,
codeActionGroup = true,
ssr = true,
},
textDocument = {
completion = {
completionItem = {
snippetSupport = true,
preselectSupport = true,
insertReplaceSupport = true,
labelDetailsSupport = true,
deprecatedSupport = false,
commitCharactersSupport = true,
tagSupport = { valueSet = { 1 } },
resolveSupport = {
properties = { "additionalTextEdits", "documentation", "detail" },
},
},
},
},
})
cmp-nvim-lsp already comes with the lsp-zero setup that I have. The lsp works perfectly for other languages, it work for Swift too (without xbase installed). So I'm wondering if I might be doing anything wrong with my sourcekit-lsp setup that interfere with xbase.
Here's what :LspInfo shows
Client: sourcekit (id: 1, bufnr: [5])
filetypes: swift
autostart: true
root directory: /Users/dk/Documents/Dev/iOS/PersonalProject....
cmd: /usr/bin/sourcekit-lsp --log-level error
Then, :LspLog shows this:
[ERROR][2023-05-22 15:53:15] .../vim/lsp/rpc.lua:733 "rpc" "/usr/bin/sourcekit-lsp" "stderr" "thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', crates/sourcekit-helper/src/main.rs:47:59\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"
Nice that's a clear lead. I will look into it in few hours. Thanks
For what it is worth I'm seeing the same problem
"rpc" "sourcekit-lsp" "stderr" "thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', "
"rpc" "sourcekit-lsp" "stderr" "crates/sourcekit-helper/src/main.rs"
"rpc" "sourcekit-lsp" "stderr" ":47:59\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"
@rsdenijs can you give more information on your project?
Yes, I am a regular neovim user and was playing around with xcode/swiftUI intro tutorials. I was trying to get some level of LSP working in neovim.
Yes, I am a regular neovim user and was playing around with xcode/swiftUI intro tutorials. I was trying to get some level of LSP working in neovim.
Oh nice. You ain't using any type of xcodeproj generator just directly from xcode created.
Correct. Just created the project in Xcode and trying to do some basic development on it in neovim.
@kkharji Can you give your setup repos for example purpose, mate?
I think my setup was failed and need some reference to make the plugin works.
When I start nvim in a .xcodeproject root, xbase starts running, create the buildServer and .compile file and outputs to log as expected, but there was no autocomplete, not even for basic swift commands. When I deleted xbase and run Sourcekit-lsp on its own, the lsp was working fine, showing suggestions for swift commands and functions in that file (but not methods/classes from other files).
Here's my xbase config
My lsp config for sourcekit
When I run ~/.local/share/xbase/xbase it knows that I'm editing the file
And here's the xbase-build-server.log
Versions: macOS 12.5.1 Xcode Version 14.1 (14B47b)