Skip to content

koskev/jsonnet-language-server

 
 

Repository files navigation

Jsonnet Language Server

Warning

I won't maintain this fork any further. If you liked some of the new feature just use my new LSP.

A Language Server Protocol (LSP) server for Jsonnet.

Master is (probably) always somehow broken or not tested on a complex codebase. Tags should be stable though

Features of this fork

  • Autocomplete function parameter names
  • Autocomplete function parameter with their default values
  • Find references
  • Rename
  • Very basic signature help
  • Inlay hints
    • unnamed function parameters
    • Index (e.g. extcode variables)
  • Bugfixes
    • Infinite loops
    • Completion with named args and objects without a space
    • Binary Object completion
  • Complete rework of the autocomplete code
    • Proper extcode support
    • Complete extVar/Code variables and all valid values e.g. std.extVar("PARAMS")
    • Complete for objects
    • Supports completion after newlines and whitespaces e.g. myobj.\n myVal
    • Completes returns of functions
      • e.g. myFunc({val: 5}).argVal.val
      • Builder pattern
    • Complete imports from all jpaths
    • Complete import function calls (import 'a.libsonnet')("myArg").val
    • Support super completion
    • Complete keywords (super, self, local)
    • Complete conditionals
      • Currently not all conditions are supported
    • Complete array access
    • Complete unused argument names: myFunc(1, arg3=3, arg2=),
  • Basic automatic ast fix
  • Basic semantic token support
    • Only the basic stuff. It is assumed you are also using something like tree sitter

TODO

  • Reimplement
    • Go to definition
    • Inlay hints
  • Refactor/Cleanup new features
  • General cleanup after understanding more lsp stuff
  • Code actions?
  • Flow typing?

Features

LSP Config parameter

Documentation Full default Config:

{
  "log_level": "panic",
  "resolve_paths_with_tanka": false,
  "jpath": [],
  "ext_vars": null,
  "ext_code": null,
  "formatting": {
    "Indent": 2,
    "MaxBlankLines": 2,
    "StringStyle": 1,
    "CommentStyle": 1,
    "PrettyFieldNames": true,
    "PadArrays": false,
    "PadObjects": true,
    "SortImports": true,
    "UseImplicitPlus": true,
    "StripEverything": false,
    "StripComments": false,
    "StripAllButComments": false
  },
  "diagnostics": {
    "enable_eval_diagnostics": false,
    "enable_lint_diagnostics": false
  },
  "inlay": {
    "enable_debug_ast": false,
    "enable_index_value": false,
    "enable_function_args": false,
    "function_args": {
      "show_with_same_name": false
    },
    "max_length": 120
  },
  "enable_semantic_tokens": false,
  "workarounds": {
    "assume_true_condition_on_error": false
  },
  "completion": {
    "enable_snippets": false,
    "enable_keywords": true,
    "use_type_in_detail": false,
    "show_docstring": false
  }
}

New features

functionbody.mp4
forloop.mp4
rename.mp4

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 82.8%
  • Jsonnet 15.4%
  • Nix 0.5%
  • Shell 0.5%
  • Vim Script 0.3%
  • Emacs Lisp 0.3%
  • Other 0.2%