Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Bicep.LangServer binary with release so the language server can be used in other editors #1141

Closed
damienpontifex opened this issue Dec 14, 2020 · 22 comments · Fixed by #1152
Labels
enhancement New feature or request Needs: Triage 🔍

Comments

@damienpontifex
Copy link

Is your feature request related to a problem? Please describe.
The language server can be used in other tools like neovim lsp. It'd be nice to be able to grab the latest executable of this from a release for use in other tools like this. Currently I clone the repo and build locally to use in this context

Describe the solution you'd like
A release also builds Bicep.LangServer and publishes/attaches a single file application executable such as 'bicep-ls-osx-x64' (and others per platform) to the GitHub release artifacts

@damienpontifex damienpontifex added the enhancement New feature or request label Dec 14, 2020
@ghost ghost added the Needs: Triage 🔍 label Dec 14, 2020
@damienpontifex
Copy link
Author

I'd be happy to contribute to this end if this is deemed a desirable addition

@alex-frankel
Copy link
Collaborator

At one point I think we were publishing the language server binary in our builds, but we took it out. @anthony-c-martin / @majastrz is there a way for us to get damien unblocked?

We also have #480 just as FYI

@damienpontifex
Copy link
Author

Thanks @alex-frankel
I might close this one as it seems very similar to #480

@damienpontifex
Copy link
Author

damienpontifex commented Dec 15, 2020

Just for clarity, this isn't really blocking me as I have workarounds for clone and build so feel free to prioritise appropriately. Just interested in simplifying/streamlining that process

@majastrz
Copy link
Member

I reopened it because #480 is about creating an atom package which is different than this.

For VS code, we're keeping the extension size tiny by publishing runtime-agnostic binaries. Would this apply to your scenario? I would assume that the runtime is already present on your machine.

The alternative would be your suggestion to publish self-contained apps (possible even single-file to reduce size further via runtime trimming) for each runtime we support.

What do you think?

@damienpontifex
Copy link
Author

It's probably a pretty safe assumption that you'd have dotnet on your machine :) and in my case it is on my machine.

I haven't tried the single file publishing with .NET 5 and so was even just curious what an exe published liked this would be like (probably mainly binary size after trimming I was curious).

I was thinking the self-contained app (with trimming) also to the fact that if you happen not to have the runtime, the language server executable would work regardless.

Summary - I'd be happy if just the dll was published as I could use that. But equally happy if a standalone executable was published to simplify things even further

@majastrz
Copy link
Member

Gotcha. So I checked in our builds and the language server bits do get uploaded to artifacts (https://github.com/Azure/bicep/actions/runs/421971130). We just don't have them included with a release.

@majastrz
Copy link
Member

The next release (we're planning on one this week) should include assets with the runtime-agnostic server bits.

@damienpontifex
Copy link
Author

Thanks @majastrz

@damienpontifex
Copy link
Author

damienpontifex commented Dec 22, 2020

I've got this working with neovim lsp. Install lsp shell script is

(cd $(mktemp -d) \
    && curl -fLO https://github.com/Azure/bicep/releases/latest/download/bicep-langserver.zip \
    && rm -rf /usr/local/bin/bicep-langserver \
    && unzip -d /usr/local/bin/bicep-langserver bicep-langserver.zip)

And then in my neovim lsp setup:

local configs = require 'lspconfig/configs'
local lsputil = require 'lspconfig/util'
configs.bicep = {
  default_config = {
    cmd = { "dotnet", "/usr/local/bin/bicep-langserver/Bicep.LangServer.dll" };
    filetypes = { "bicep" };
    root_dir = lsputil.root_pattern(".git");
  };
}

lsp_config.bicep.setup {
  on_attach = on_attach
}

I'll contribute the neovim lua changes to https://github.com/neovim/nvim-lspconfig shortly

@alex-frankel
Copy link
Collaborator

Awesome! Can you share a screenshot of it running?

@damienpontifex
Copy link
Author

Using within the bicep repo at docs/examples/301/servicebus-namespace-vnet/main.bicep I removed the location property to show two different things coming from the language server

  • A warning/error
  • Popup for autocomplete/intellisense

image

@alex-frankel
Copy link
Collaborator

Awesome! Out of curiosity, were you expecting syntax highlighting to be working? Does neovim LSP support that?

@majastrz
Copy link
Member

majastrz commented Jan 4, 2021

I'm not very familiar with neovim LSP, but semantic tokens are a fairly new/experimental LSP feature, which may require some extra config in neovim.

@damienpontifex
Copy link
Author

@alex-frankel I'm not aware of neovim support for sematic tokens with LSP yet. Tracking the support of the in the protocol, there was a comment saying it'd be in the 3.16 spec which is still very recent and the LSP implementation within neovim is still in beta, so probably not a priority vs other language features. It'd be nice to have though :)

@majastrz
Copy link
Member

majastrz commented Jan 9, 2021

BTW, do you know what mechanism is used in neovim for syntax highlighting? Does it support TextMate grammars?

@damienpontifex
Copy link
Author

I'm currently using https://github.com/nvim-treesitter/nvim-treesitter

Saying that, I've seen a variety of ways and plugins for language specific highlighting etc so I assume someone has built something that uses the TextMate grammar for this.

@anthony-c-martin
Copy link
Member

@damienpontifex just FYI, we now have a simple textmate grammar implemented here if you'd like syntax highlighting without semantic token support: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage

@JohanBjoerklund
Copy link

JohanBjoerklund commented Jun 29, 2021

I've got this working with neovim lsp. Install lsp shell script is

(cd $(mktemp -d) \
    && curl -fLO https://github.com/Azure/bicep/releases/latest/download/bicep-langserver.zip \
    && rm -rf /usr/local/bin/bicep-langserver \
    && unzip -d /usr/local/bin/bicep-langserver bicep-langserver.zip)

And then in my neovim lsp setup:

local configs = require 'lspconfig/configs'
local lsputil = require 'lspconfig/util'
configs.bicep = {
  default_config = {
    cmd = { "dotnet", "/usr/local/bin/bicep-langserver/Bicep.LangServer.dll" };
    filetypes = { "bicep" };
    root_dir = lsputil.root_pattern(".git");
  };
}

lsp_config.bicep.setup {
  on_attach = on_attach
}

I'll contribute the neovim lua changes to https://github.com/neovim/nvim-lspconfig shortly

For vim users that uses Ale, you can add this to your vimrc to enable bicep langserv.

if has('unix')
  packloadall
  call ale#linter#Define('bicep', {
  \   'name': 'bicep-ls',
  \   'lsp': 'stdio',
  \   'executable': 'dotnet',
  \   'command': '%e /usr/local/bin/bicep-langserver/Bicep.LangServer.dll',
  \   'project_root': '.'
  \})
endif

if has('win32')
  packloadall
  call ale#linter#Define('bicep', {
  \   'name': 'bicep-ls',
  \   'lsp': 'stdio',
  \   'executable': '%USERPROFILE%/.bicep/bicep-langserver/Bicep.LangServer.exe',
  \   'command': '%e',
  \   'project_root': '.'
  \})
endif

A PR is pending in Ale repo to let Ale hadle loading of bicep langserv.

@barunps3
Copy link

Syntax highlighting still does not work for bicep language server when used with Neovim. I am using treesitter as well. Is there known config I can use ?

@alex-frankel
Copy link
Collaborator

@damienpontifex -- any help you can provide on this one?

@damienpontifex
Copy link
Author

@barunps3 it's ongoing work within Neovim. LSP semantic tokens isn't implemented there yet.
Original attempt neovim/neovim#14122
Seemingly current attempt neovim/neovim#15723

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request Needs: Triage 🔍
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants