Skip to content

Commit

Permalink
refactor(documentation): redo license inluding
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Dec 29, 2023
1 parent 1979de9 commit dc5c172
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 105 deletions.
34 changes: 0 additions & 34 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Part of the documentation that is included in helm-ls is copied from
the Go standard library. So the following license applies:

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above

copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
- Neither the name of Google Inc. nor the names of its

contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
149 changes: 84 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,62 @@
</pre>

## Helm Language Server Protocol
Helm-ls is a [helm](https://github.com/helm/helm) language server protocol [LSP](https://microsoft.github.io/language-server-protocol/) implementation.

Helm-ls is a [helm](https://github.com/helm/helm) language server protocol [LSP](https://microsoft.github.io/language-server-protocol/) implementation.

<!-- vim-markdown-toc GFM -->

* [Demo](#demo)
* [Getting Started](#getting-started)
* [Download](#download)
* [Make it executable](#make-it-executable)
* [Integration with yaml-language-server](#integration-with-yaml-language-server)
* [Download](#download)
* [Make it executable](#make-it-executable)
* [Integration with yaml-language-server](#integration-with-yaml-language-server)
* [Configuration options](#configuration-options)
* [LSP Server](#lsp-server)
* [yaml-language-server config](#yaml-language-server-config)
* [Emacs eglot setup](#emacs-eglot-setup)
* [LSP Server](#lsp-server)
* [yaml-language-server config](#yaml-language-server-config)
* [Default Configuration](#default-configuration)
* [Editor Config examples](#editor-config-examples)
* [Neovim (using nvim-lspconfig)](#neovim-using-nvim-lspconfig)
* [Vim Helm Plugin](#vim-helm-plugin)
* [Setup laguage server](#setup-laguage-server)
* [Emacs eglot setup](#emacs-eglot-setup)
* [Contributing](#contributing)
* [License](#license)

<!-- vim-markdown-toc -->

## Demo

[![asciicast](https://asciinema.org/a/485522.svg)](https://asciinema.org/a/485522)

## Getting Started

### Download
* Download the latest helm_ls executable file from [here](https://github.com/mrjosh/helm-ls/releases/latest) and move it to your binaries directory

* You can download it with curl, replace the {os} and {arch} variables
- Download the latest helm_ls executable file from [here](https://github.com/mrjosh/helm-ls/releases/latest) and move it to your binaries directory

- You can download it with curl, replace the {os} and {arch} variables

```bash
curl -L https://github.com/mrjosh/helm-ls/releases/download/master/helm_ls_{os}_{arch} --output /usr/local/bin/helm_ls
```

If you are using neovim with [mason](https://github.com/williamboman/mason.nvim) you can also install it with mason.

### Make it executable

```bash
chmod +x /usr/local/bin/helm_ls
```

### Integration with [yaml-language-server](https://github.com/redhat-developer/yaml-language-server)

Helm-ls will use yaml-language-server to provide additional capabilities, if it is installed.
This feature is expermiental, you can disable it in the config ([see](#configuration-options)).
Having a broken template syntax (e.g. while your are stil typing) will cause diagnostics from yaml-language-server to be shown as errors.

To install it using npm run (or use your preferred package manager):

```bash
npm install --global yaml-language-server
```
Expand All @@ -68,7 +79,6 @@ to use the schemas from the [CRDs-catalog](https://github.com/datreeio/CRDs-cata
# yaml-language-server: $schema=https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/keda.sh/scaledobject_v1alpha1.json
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
...
```
## Configuration options
Expand All @@ -81,69 +91,74 @@ You can configure helm-ls with lsp workspace configurations.
### yaml-language-server config
- **Enable yaml-language-server**: Toggle support of this feature.
- **Path to yaml-language-server**: Specify the executable location.
- **Diagnostics Settings**:
- **Limit**: Number of displayed diagnostics per file.
- **Show Directly**: Show diagnostics while typing.

- **Additional Settings** (see [yaml-language-server](https://github.com/redhat-developer/yaml-language-server#language-server-settings)):
- **Schemas**: Define YAML schemas.
- **Completion**: Enable code completion.
- **Hover Information**: Enable hover details.

### Default Configuration

```lua
settings = {
['helm-ls'] = {
logLevel = "debug",
yamlls = {
enabled = true,
diagnosticsLimit = 50,
showDiagnosticsDirectly = false,
path = "yaml-language-server",
config = {
schemas = {
kubernetes = "**",
},
completion = true,
hover = true,
-- any other config: https://github.com/redhat-developer/yaml-language-server#language-server-settings
}
- **Enable yaml-language-server**: Toggle support of this feature.
- **Path to yaml-language-server**: Specify the executable location.
- **Diagnostics Settings**:
- **Limit**: Number of displayed diagnostics per file.
- **Show Directly**: Show diagnostics while typing.
- **Additional Settings** (see [yaml-language-server](https://github.com/redhat-developer/yaml-language-server#language-server-settings)):
- **Schemas**: Define YAML schemas.
- **Completion**: Enable code completion.
- **Hover Information**: Enable hover details.
### Default Configuration
```lua
settings = {
['helm-ls'] = {
logLevel = "debug",
yamlls = {
enabled = true,
diagnosticsLimit = 50,
showDiagnosticsDirectly = false,
path = "yaml-language-server",
config = {
schemas = {
kubernetes = "**",
},
completion = true,
hover = true,
-- any other config: https://github.com/redhat-developer/yaml-language-server#language-server-settings
}
}
}
```

## Editor Config examples

### Neovim (using nvim-lspconfig)
#### Vim Helm Plugin
You'll need [vim-helm](https://github.com/towolf/vim-helm) plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager):
```lua
Plug 'towolf/vim-helm'
```

#### Setup laguage server
```lua
local lspconfig = require('lspconfig')

lspconfig.helm_ls.setup {
settings = {
['helm-ls'] = {
yamlls = {
path = "yaml-language-server",
}
}
}
```

## Editor Config examples

### Neovim (using nvim-lspconfig)

#### Vim Helm Plugin

You'll need [vim-helm](https://github.com/towolf/vim-helm) plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager):

```lua
Plug 'towolf/vim-helm'
```

#### Setup laguage server

```lua
local lspconfig = require('lspconfig')

lspconfig.helm_ls.setup {
settings = {
['helm-ls'] = {
yamlls = {
path = "yaml-language-server",
}
}
```
}
}
```

See [examples/nvim/init.lua](https://github.com/mrjosh/helm-ls/blob/master/examples/nvim/init.lua) for an
complete example, which also includes yaml-language-server.


### Emacs eglot setup
### Emacs eglot setup

Integrating helm-ls with [eglot](https://github.com/joaotavora/eglot) for emacs consists of two steps: wiring up Helm template files into a specific major mode and then associating that major mode with `helm_ls` via the `eglot-server-programs` variable.
The first step is necessary because without a Helm-specific major mode, using an existing major mode like `yaml-mode` for `helm_ls` in `eglot-server-programs` may invoke the language server for other, non-Helm yaml files.
Expand Down Expand Up @@ -178,7 +193,11 @@ Alternatively, you can include a comment such as the following at the top of Hel
# -*- mode: helm -*-

## Contributing

Thank you for considering contributing to HelmLs project!

## License

The HelmLs is open-source software licensed under the MIT license.

Part of the documentation that is included in helm-ls is copied from the Go standard library. The original license is included in the files containing the documentation.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The content of the Snippet was taken from https://pkg.go.dev/text/template
// The content of the snippets was taken from https://pkg.go.dev/text/template
// So the following license applies to them:

// Copyright (c) 2009 The Go Authors. All rights reserved.
Expand Down Expand Up @@ -30,9 +30,9 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package handler
package go_docs

Check failure on line 33 in internal/documentation/go_docs/gotemplate.go

View workflow job for this annotation

GitHub Actions / lint (1.19.1, ubuntu-latest)

var-naming: don't use an underscore in package name (revive)

Check failure on line 33 in internal/documentation/go_docs/gotemplate.go

View workflow job for this annotation

GitHub Actions / lint (1.19.1, ubuntu-latest)

var-naming: don't use an underscore in package name (revive)

type HelmSnippet struct {
type GoTemplateSnippet struct {
Name string
Detail string
Doc string
Expand All @@ -41,7 +41,7 @@ type HelmSnippet struct {
}

var (
textSnippets = []HelmSnippet{
TextSnippets = []GoTemplateSnippet{
{
Name: "comment",
Detail: "{{- /* a comment with white space trimmed from preceding and following text */ -}}",
Expand All @@ -53,7 +53,6 @@ var (
Detail: "template",
Doc: "",
Snippet: "{{- $0 }}",
Filter: "{}", // TODO: is this useful?
},
{
Name: "if",
Expand Down
4 changes: 3 additions & 1 deletion internal/handler/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"go.lsp.dev/jsonrpc2"
lsp "go.lsp.dev/protocol"
yaml "gopkg.in/yaml.v2"

"github.com/mrjosh/helm-ls/internal/documentation/go_docs"
)

var (
Expand All @@ -28,7 +30,7 @@ func init() {
functionsCompletionItems = append(functionsCompletionItems, getFunctionCompletionItems(helmFuncs)...)
functionsCompletionItems = append(functionsCompletionItems, getFunctionCompletionItems(builtinFuncs)...)
functionsCompletionItems = append(functionsCompletionItems, getFunctionCompletionItems(sprigFuncs)...)
textCompletionsItems = append(textCompletionsItems, getTextCompletionItems(textSnippets)...)
textCompletionsItems = append(textCompletionsItems, getTextCompletionItems(go_docs.TextSnippets)...)
}

func (h *langHandler) handleTextDocumentCompletion(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) (err error) {
Expand Down

0 comments on commit dc5c172

Please sign in to comment.