Reputation: 329
I'm trying to use Ballerina with neovim editor and would like to use the Language Server Protocol (LSP) with it. However, It is unclear to me from the documentation here (https://github.com/ballerina-platform/ballerina-lang/tree/master/language-server) how I should go about achieving that.
Is the suggested workflow for me to build a language server executable from the java source in the repo linked above and use that, or is it published as an artifact somewhere?
Upvotes: 4
Views: 276
Reputation: 66
Language server executable comes with Ballerina installation itself and you can run it using bal start-language-server
command. In order to configure Neovim to use it (assuming you have already configured LSP in general) I would,
1.Add Ballerina file type (in init.lua
)
vim.filetype.add({
extension = {
bal = 'ballerina'
}
})
This allows you to have configurations specific to ballerina
2.Create a new LSP client when we have a ballerina file (in ftplugin/ballerina.lua
)
vim.lsp.start({
name = 'ballerina-lsp',
cmd = { 'bal', 'start-language-server' },
root_dir = vim.fs.dirname(vim.fs.find({ 'Ballerina.toml' }, { upward = true })[1])
})
Upvotes: 5