Giter Site home page Giter Site logo

grafana / jsonnet-language-server Goto Github PK

View Code? Open in Web Editor NEW
159.0 123.0 15.0 1.41 MB

A Language Server Protocol (LSP) server for Jsonnet (https://jsonnet.org)

License: GNU Affero General Public License v3.0

Emacs Lisp 0.48% Go 72.47% Nix 0.92% Jsonnet 25.02% Shell 0.60% Vim Script 0.50%
jsonnet language-server lsp-server

jsonnet-language-server's Introduction

Jsonnet Language Server

A Language Server Protocol (LSP) server for Jsonnet.

Features

Jump to definition

self-support.mp4
dollar-support.mp4
multi-defs-demo.mp4

Error/Warning Diagnostics

error-support.mp4

Linting Diagnostics

linting-support.mp4

Standard Library Hover and Autocomplete

stdlib-support.mp4

Formatting

Installation

Download the latest release binary from GitHub: https://github.com/grafana/jsonnet-language-server/releases

Contributing

Contributions are more than welcome and I will try my best to be prompt with reviews.

Commits

Individual commits should be meaningful and have useful commit messages. For tips on writing commit messages, refer to How to write a commit message. Contributions will be rebased before merge to ensure a fast-forward merge.

Contributors must sign the DCO for their contributions to be accepted.

Code style

Go code should be formatted with gofmt and linted with golangci-lint.

Editor integration

jsonnet-language-server's People

Contributors

anguslees avatar dependabot[bot] avatar duologic avatar entombedvirus avatar jdbaldry avatar jjo avatar julienduchesne avatar puddinghat avatar snoord avatar trevorwhitney avatar zzehring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonnet-language-server's Issues

[Bug] Crash (NPE) periodically occurs during some editing operations

I occasinally get the following crash:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 5728 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc0121b1e00, 0x1, 0x2?}, {0xc0128edb31, 0x1}, {0xc0128edb00, 0x33})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0001802c0?, {0xc0128edb00, 0x33}, 0xc007e880c0, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0001802c0, {0xd2?, 0xe0?}, 0xc0006405f0)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc0008be040}, {0xa5bd90, 0xc0001802c0}, 0xc007e88000, {0xa531c8, 0xc0008be000})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc0008be040}, 0xc007e88000, {0xa531c8, 0xc0008be000})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc0008be040}, 0xc00012c078, {0xa531c8?, 0xc0008be000?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Info  - 11:34:20 AM] Connection to server got closed. Server will restart.

During some editing operations. It is difficult to say what causes it... because it just appears to happen randomly.

This is with the latest 0.12 release. If I can, I will try and spot some common operations causing this, but I hope the stack track is enough to maybe project against it

Completion Fails for nested functions

Version 0.13.1

Similar to: #113

Log

time="2023-11-16T11:47:36-08:00" level=info msg="Starting the language server"
time="2023-11-16T11:47:36-08:00" level=info msg="Initializing jsonnet-language-server version 0.13.1"
time="2023-11-16T11:47:36-08:00" level=info msg="Reading stdlib"
time="2023-11-16T11:47:36-08:00" level=info msg="configuration updated: {ResolvePathsWithTanka:true JPaths:[/<MYPATH>/lib/] ExtVars:map[] ExtCode:map[] FormattingOptions:{Indent:2 MaxBlankLines:2 StringStyle:1 CommentStyle:1 PrettyFieldNames:true PadArrays:false PadObjects:true SortImports:true UseImplicitPlus:true StripEverything:false StripComments:false StripAllButComments:false} EnableEvalDiagnostics:true EnableLintDiagnostics:false}"
...
time="2023-11-16T11:48:23-08:00" level=error msg="DocumentSymbol: error parsing the document"
time="2023-11-16T11:48:23-08:00" level=error msg="Completion: error finding ranges: field Critical() was not found in ast.DesugaredObject"
time="2023-11-16T11:48:24-08:00" level=error msg="DocumentSymbol: error parsing the document"
time="2023-11-16T11:48:41-08:00" level=error msg="Definition: error finding definition" error="cannot find definition"

Library

{

  // Stack Criticality modifiers
  Critical: function(warning_period=3) {
    critical: true,
    warning_period: warning_period,

    TimeZone: function(time_zone='America/Los_Angeles') self {
      timezone: time_zone,
    }
  },

  NonCritical: function() $.Critical() {
    critical: false,
  },
}

Live Configuration

local crit = import crit.libsonnet;

{
   test: crit.Critical().
                      // ^^^
                      // IntelliSense cannot resolve the nested function TimeZone, resulting in the error
                      // "Completion: error finding ranges: field Critical() was not found in ast.DesugaredObject"
                      //  however it can resolve both Critital and NonCritical on the local var/object crit
}

License question

Hi, thanks for this great tool!

Tanka & jsonnet-bundler are Apache-2.0, why not this repo? The choice of AGPL seems quite arbitrary to me. Furthermore, as you may know, this specific license is entirely forbidden in several open-source friendly companies such as Google (see here, even for personal productivity use.

Would you consider Apache-2.0 instead?

Thanks!

Invalid URL escape "%2B"

In the last week or so the language server has stopped working for me. I connect to a desktop from my laptop using Remote SSH and do most of my development this way. Recently, the language server has been going into a crash loop with an error that looks like this:

panic: failed to parse request URI: parse "vscode-remote://ssh-remote%2Bwork/home/josh/work/catalyst-world": invalid URL escape "%2B"

Where, ssh-remote+work represents an SSH remote session to the work profile, and /home/josh/work/catalyst-world being the current working directory. I'm not sure if this format has changed recently, as I've successfully been using this language server for a few months now, but for one reason or another it's stopped accepting this URI format.

Any help in resolving this issue is appreciated :)

Crash on diagnostics, VSCode

Empty jsonnet file, pressing ctrl+enter for suggestions/diagnostic after s crashes the server

{
 s
}

debug output:

time="2022-08-23T04:41:32+03:00" level=info msg="Starting the language server"
time="2022-08-23T04:41:32+03:00" level=info msg="Using tanka mode. Will fall back to the following jpaths: []"
time="2022-08-23T04:41:32+03:00" level=info msg="Initializing jsonnet-language-server version 0.7.2"
time="2022-08-23T04:41:32+03:00" level=info msg="Reading stdlib"
panic: runtime error: index out of range [9] with length 0

goroutine 51 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.(*server).getEvalDiags(0xa03ec8?, 0xc00011a000)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:153 +0x629
github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1.1()
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:55 +0x2a
created by github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:54 +0x238
[Info  - 04:41:33] Connection to server got closed. Server will restart.

VSCode 1.70.2
jsonnet-language-server 0.7.2
vscode-jsonnet: 0.2.4
windows

Looking into the sources of diagnostics.go suggests the fail of regexp match: there is match[9] access,
but match is likely to be empty.

   diag.Message = match[9]
   diag.Severity = protocol.SeverityError

Will this project be available through NixPkgs?

I couldn't help but notice that this project has Nix files but it is not submitted to NixPkgs? Why is this the case? It will be really nice to be able to install this project trough Nix without extra steps.

Server crashing in vscode

I got a popup from vscode saying the language server had crashed 5 times in the last 3 minutes (or something like that). I looked at the output and here it is:

time="2023-06-01T18:19:15+01:00" level=error msg="Hover: error parsing the document"
time="2023-06-01T18:19:16+01:00" level=error msg="DocumentSymbol: error parsing the document"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 6941 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc01c98d900, 0x1, 0x2?}, {0xc001d18c20, 0x8}, {0xc001d18c09, 0x20})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0000f62c0?, {0xc001d18c09, 0x20}, 0xc05e27d650, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0000f62c0, {0xce?, 0xd0?}, 0xc00bbc8b90)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc000396b40}, {0xa5bd90, 0xc0000f62c0}, 0xc05e27d5f0, {0xa531c8, 0xc000396b00})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc000396b40}, 0xc05e27d5f0, {0xa531c8, 0xc000396b00})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc000396b40}, 0xc0002ac618, {0xa531c8?, 0xc000396b00?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Info  - 18:19:19] Connection to server got closed. Server will restart.
time="2023-06-01T18:19:19+01:00" level=info msg="Starting the language server"
time="2023-06-01T18:19:19+01:00" level=info msg="Initializing jsonnet-language-server version 0.12.0"
time="2023-06-01T18:19:19+01:00" level=info msg="Reading stdlib"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 12 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc0005ba500, 0x1, 0x2?}, {0xc000e1e120, 0x8}, {0xc000e1e109, 0x22})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0001a62c0?, {0xc000e1e109, 0x22}, 0xc000daf950, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0001a62c0, {0xb7?, 0xc0?}, 0xc0002820f0)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc00009ae40}, {0xa5bd90, 0xc0001a62c0}, 0xc000daf620, {0xa531c8, 0xc00009ae00})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc00009ae40}, 0xc000daf620, {0xa531c8, 0xc00009ae00})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc00009ae40}, 0xc0007c4de0, {0xa531c8?, 0xc00009ae00?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Info  - 18:19:19] Connection to server got closed. Server will restart.
time="2023-06-01T18:19:19+01:00" level=info msg="Starting the language server"
time="2023-06-01T18:19:19+01:00" level=info msg="Initializing jsonnet-language-server version 0.12.0"
time="2023-06-01T18:19:19+01:00" level=info msg="Reading stdlib"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 13 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc000194460, 0x1, 0x2?}, {0xc0005b6ee0, 0x8}, {0xc0005b6ec9, 0x23})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0000f62c0?, {0xc0005b6ec9, 0x23}, 0xc0002a2330, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0000f62c0, {0xb7?, 0xc0?}, 0xc0000140f0)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc000438840}, {0xa5bd90, 0xc0000f62c0}, 0xc0002a2000, {0xa531c8, 0xc000438800})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc000438840}, 0xc0002a2000, {0xa531c8, 0xc000438800})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc000438840}, 0xc00012d350, {0xa531c8?, 0xc000438800?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Info  - 18:19:19] Connection to server got closed. Server will restart.
time="2023-06-01T18:19:19+01:00" level=info msg="Starting the language server"
time="2023-06-01T18:19:19+01:00" level=info msg="Initializing jsonnet-language-server version 0.12.0"
time="2023-06-01T18:19:19+01:00" level=info msg="Reading stdlib"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 65 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc00021fcc0, 0x1, 0x2?}, {0xc00073c120, 0x8}, {0xc00073c109, 0x23})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0001a62c0?, {0xc00073c109, 0x23}, 0xc00025e390, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0001a62c0, {0xb7?, 0xc0?}, 0xc000014960)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc000809b80}, {0xa5bd90, 0xc0001a62c0}, 0xc00025e060, {0xa531c8, 0xc000809b40})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc000809b80}, 0xc00025e060, {0xa531c8, 0xc000809b40})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc000809b80}, 0xc000502cd8, {0xa531c8?, 0xc000809b40?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Info  - 18:19:19] Connection to server got closed. Server will restart.
time="2023-06-01T18:19:19+01:00" level=info msg="Starting the language server"
time="2023-06-01T18:19:19+01:00" level=info msg="Initializing jsonnet-language-server version 0.12.0"
time="2023-06-01T18:19:19+01:00" level=info msg="Reading stdlib"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x83eabb]

goroutine 65 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.typeToString({0x0?, 0x0?})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:205 +0x27b
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItem({_, _}, {_, _}, _, {_, _})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:180 +0x125
github.com/grafana/jsonnet-language-server/pkg/server.createCompletionItemsFromRanges({0xc0001c4460, 0x1, 0x2?}, {0xc0007bcee0, 0x8}, {0xc0007bcec9, 0x24})
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:151 +0x359
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).completionFromStack(0xc0001a62c0?, {0xc0007bcec9, 0x24}, 0xc0007f0360, 0x874180?)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:93 +0x1f8
github.com/grafana/jsonnet-language-server/pkg/server.(*Server).Completion(0xc0001a62c0, {0xb7?, 0xc0?}, 0xc0002780a0)
	/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/completion.go:46 +0x21b
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.serverDispatch({0xa53078, 0xc0004ba5c0}, {0xa5bd90, 0xc0001a62c0}, 0xc0007f0030, {0xa531c8, 0xc0004ba580})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/tsserver.go:382 +0x1bd1
github.com/jdbaldry/go-language-server-protocol/lsp/protocol.ServerHandler.func1({0xa53078, 0xc0004ba5c0}, 0xc0007f0030, {0xa531c8, 0xc0004ba580})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/lsp/protocol/protocol.go:154 +0x90
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.MustReplyHandler.func1({0xa53078, 0xc0004ba5c0}, 0xc00012e750, {0xa531c8?, 0xc0004ba580?})
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:35 +0xf6
github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1.2()
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:103 +0xa3
created by github.com/jdbaldry/go-language-server-protocol/jsonrpc2.AsyncHandler.func1
	/home/runner/go/pkg/mod/github.com/jdbaldry/[email protected]/jsonrpc2/handler.go:100 +0x20a
[Error - 18:19:19] The Jsonnet Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Fails on code which import `/dev/stdin`

👋

We have (🤦) some code which imports /dev/stdin for which we're unable to run the jsonnet-langauge-server on.

I don't know whether the appropriate fix lies within the language server itself, or should be handled by upstream go-jsonnet code (have not dug that deeply into the code so far).

But if you can point me towards how/where you'd see the fix for this problem, i'd be happy to take a go at it.

Thanks in advance.

Tasks

No tasks being tracked yet.

Failing to expand helm chart

RUNTIME ERROR: Expanding Helm Chart: exec: "helm": executable file not found in $PATH /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jsonnet-libs/tanka-util/helm.libsonnet:46:23-67 thunk <chartData> from <function <anonymous>> /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jsonnet-libs/tanka-util/helm.libsonnet:48:21-30 thunk from <function <anonymous>> /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jsonnet-libs/tanka-util/k8s.libsonnet:43:7-13 thunk from <function <anonymous>> /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jsonnet-libs/tanka-util/k8s.libsonnet:13:21-27 thunk from <function <anonymous>> <std>:31:26-27 thunk from <function <anonymous>> <std>:31:17-28 function <anonymous> /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jsonnet-libs/tanka-util/k8s.libsonnet:13:8-28 function <anonymous> /Users/cyril/work/deployment_tools/ksonnet/vendor/github.com/grafana/jso...

While I do have helm in the path, vs-code seems to complains, not sure how to resolve it.

Allow passing argument to jsonnet binary

Hi,

i'm using jrsonnet binary as jsonnet binary replacement and use an experimental feature there, for that reason i need to pass an extra argument to the binary. It would be nice to allow setting this via the language server to use inside of vs code rather than command line

New release (0.7.1) keeps crashing

Hi, I was working with the previous release (0.7.0) and all good so far. As soon as I upgraded the version to the latest one (0.7.1) the language server keeps crashing:

[Info  - 3:54:06 PM] Connection to server got closed. Server will restart.
[Info  - 3:54:06 PM] Connection to server got closed. Server will restart.
[Info  - 3:54:06 PM] Connection to server got closed. Server will restart.
[Info  - 3:54:06 PM] Connection to server got closed. Server will restart.
[Error - 3:54:06 PM] Connection to server got closed. Server will not be restarted.

Any ideas how to get more logs so I can help here?
Also, any ideas how to rollback to the previous version in my setup?

unexpected warnings on `std.native` function calls

Versions

  • VS Code Jsonnet Language Server Extension v0.3.3
  • jsonnet-language-server v0.11.0

Example Code

local nextID = std.native('nextID');

{
  id: nextID(),
}

Error Message

RUNTIME ERROR: Unexpected type null, expected function
	/tmp/test.jsonnet:4:7-15	object <anonymous>
	Field "id"	
	During manifestation	
jsonnet evaluation

Support grafonnet autocompletion

Hello!
We now have autocomplete feature, unfortunately it doesn't work for generated grafonnet lib:
https://github.com/grafana/grafonnet

Is there a way to add it?

This library is very important for designing clean Grafana dashboards as-code. And such autocompletion can add dramatic speed boost to this process, getting near to composing dashboards in Grafana UI.

Completion fails when not in an object/array

When I try to use completion outside an object/array, then if fails.

Does not work:

local hello = import 'hello.jsonnet';

hello.<tab>

Works:

local hello = import 'hello.jsonnet';
[
  hello.<tab>
]
local hello = import 'hello.jsonnet';
{
  a: hello.<tab>
}

Library:

// hello.jsonnet
local hello = {
  hello: {
    to: {
      the: 'world',
    },
  },
};

hello

Error log:

level=error msg="Completion: error finding ranges: could not find bind for hello"

Unable to run vscode extension

I've installed the latest v0.3.1 version. Opening the Visual Studio Code console shows this:

Not using custom binary path. Using default path
Binary path is /Users/heydonovan/Library/Application Support/Code/User/globalStorage/grafana.vscode-jsonnet/bin/jsonnet-language-server (exists: true)
Auto-update is enabled. Fetching latest release from https://api.github.com/repos/grafana/jsonnet-language-server/releases/latest
Latest release is 0.8.0
Failed to get current version from /Users/heydonovan/Library/Application Support/Code/User/globalStorage/grafana.vscode-jsonnet/bin/jsonnet-language-server
Error: Command failed: /Users/heydonovan/Library/Application Support/Code/User/globalStorage/grafana.vscode-jsonnet/bin/jsonnet-language-server --version

Manually attemping to run that binary results in:

$ cd /Users/heydonovan/Library/Application\ Support/Code/User/globalStorage/grafana.vscode-jsonnet/bin/

$ ls -lah
total 13M
drwxr-xr-x 3 heydonovan staff  96 Aug 30 13:25 ./
drwxr-xr-x 3 heydonovan staff  96 Aug 30 13:25 ../
-rwxrwxrwx 1 heydonovan staff 12M Aug 31 14:33 jsonnet-language-server*

$ ./jsonnet-language-server
fish: Job 1, './jsonnet-language-server' terminated by signal SIGKILL (Forced quit)

$ ./jsonnet-language-server --version
fish: Job 1, './jsonnet-language-server --ver…' terminated by signal SIGKILL (Forced quit)
$ uname -m
arm64

$ sw_vers
ProductName:	macOS
ProductVersion:	12.5
BuildVersion:	21G72

Lint alway warning when use std.get

When I use std.get, LSP get two warning from lint

local getValue(obj, key) = std.get(obj, key, null);

it always reports Indexed object has no field "get" and Called value must be a function, but it is assumed to be void

Double completion ends up with wrong result

When autocompleting g.hello.<tab>, the language server gives an additional hello before going deeper into the object ending up with g.hello.hello.to which will fail to render.

local g = import 'hello2.jsonnet';
{
  a: g.hello.<tab>,
}

Files:

// hello.jsonnet
{
  hello: {
    to: {
      the: 'world',
    },
  },
}
// hello2.jsonnet
{ hello: (import 'hello.jsonnet').hello }

CodeLens: Add `jb` support

An operation that has to be done quite often for jsonnet projects is to interact with dependencies. A very common package manager for jsonnet is the jsonnet bundler.

The language server could have CodeLens buttons (a-la-gopls) to check for updates and if there are any, buttons to update dependencies. That would prevent users from having to call jb directly

Command: Evaluate at position

The language server currently has the evaluateFile and evaluateExpression commands. Another very useful one, but much harder to implement, is evaluateAtPosition. This could allow a user to check the value of self, or a local at any location

Since locals cannot be queried, we could define temporary attributes at runtime, like this:

{
  local my_key = 'test',
  temp:: my_key, // Line added at eval time (not defined by the user)
}

doesn't work on windows 11

OS: windows11
time="2022-08-19T17:28:13+08:00" level=info msg="Starting the language server"
time="2022-08-19T17:28:13+08:00" level=info msg="Using tanka mode. Will fall back to the following jpaths: []"
time="2022-08-19T17:28:13+08:00" level=info msg="Initializing jsonnet-language-server version 0.7.2"
time="2022-08-19T17:28:13+08:00" level=info msg="Reading stdlib"
panic: runtime error: index out of range [9] with length 0

goroutine 24 [running]:
github.com/grafana/jsonnet-language-server/pkg/server.(*server).getEvalDiags(0x2020202020202020?, 0xc00012a000)
/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:153 +0x629
github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1.1()
/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:55 +0x2a
created by github.com/grafana/jsonnet-language-server/pkg/server.(*server).diagnosticsLoop.func1.1
/home/runner/work/jsonnet-language-server/jsonnet-language-server/pkg/server/diagnostics.go:54 +0x238
[Info - 17:28:14] Connection to server got closed. Server will restart.

Re-read imported functions

Hi folks!

Just noticed that the server does not re-reads imported functions automatically on change in my setup.
Suppose I have this project structure:

lib
|_ main.libsonnet
hello.jsonnet

When adding new function to main.libsonnet and saving the file it seems like it's not visible to the language server until restart.

I have emacs setup from here: https://github.com/grafana/jsonnet-language-server/blob/main/editor/emacs/jsonnet-language-server.el

Is there any option to track local library changes?

required function argument handling

I have a helper.libsonnet file containing this:

function(a, b)
{ sum: a+b }

I get a "Missing argument error" which is correct but quite useless, how can I give the language server a useable default without having to resort to writing that:

function(a = 0, b = 0)
{ sum: a+b }

it works but I don't want these arguments to be optional, is there a way to do that in a way on visible to the language server maybe ?

Completion fails when exposing field at root

When I configure a library to expose an object through fieldaccess (hello.to), then completion fails.

# hello.jsonnet
local hello = {
  hello: {
    to: {
      the: 'world',
    },
  },
};

hello  // works
//hello.to  // does not work

Import:

local hello = import 'hello.jsonnet';

{
  a: hello.<tab>
}

Error log:

level=error msg="Completion: error finding ranges: field  was not found in ast.DesugaredObject"

Support JSON schema validation

Would it ever be possible for jsonnet-language-server to detect JSON schemas and use them to empower completion and warnings?

For instance, at the simplest extreme that could mean that if you have a simple jsonnet file with a "$schema" field, code completion could suggest other valid names for top-level JSON field names from the schema for you, and warn if you use a name that's not defined in the schema.

Enhancement request: ability to disable "No errors or warnings" diagnostic

Most language servers I have used simply do not report anything when there are no errors. Would be nice to be able to switch this diagnostic off. I attached a couple screenshots from NeoVim to show you how it looks in other editors (seems like the repo authors are using VSCode? the diagnostic just might not be as noticeable/bothersome there).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.