Skip to content

Commit

Permalink
Merge branch 'fork-master'
Browse files Browse the repository at this point in the history
* fork-master: (35 commits)
  Build only linux amd64
  Support list of glob patterns
  feat: support values lookup for range on mapping (mrjosh#86)
  feat(symbol-table): read in template context with variables (mrjosh#85)
  fix: prevent panic on empty or unsupported template context (mrjosh#83)
  feat: use helm as a libary instead of copying code (mrjosh#77)
  feat: completion for unfinished_selector_expression
  fix: update ts grammar
  feat(completion): tests and refactoring
  feat(hover): template context hover usecase
  feat: references for templateContext
  feat: add references
  feat(reference): symbol-tables provides definition references
  feat(symboltable): add symboltable
  feat(docs): add coc config and reword readme
  build(deps): bump golang.org/x/net from 0.19.0 to 0.23.0
  fix(handler): remove all unimplemented panics (mrjosh#73)
  fix(hover): format numbers correctly
  fix(hover): format list as yaml
  fix(go-to-definition): support range values
  ...
  • Loading branch information
Krismix1 committed May 26, 2024
2 parents fb951df + 154adf8 commit f1b34ac
Show file tree
Hide file tree
Showing 165 changed files with 12,586 additions and 13,053 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: artifacts
strategy:
matrix:
go-version: [1.19.1]
go-version: [1.21.5]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: build
run: |
make build-release
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ jobs:
name: lint
strategy:
matrix:
go-version: [1.19.1]
go-version: [1.21.5]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Lint
run: make lint
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ jobs:
name: tests
strategy:
matrix:
go-version: [1.19.1]
os: [ubuntu-latest, macos-latest]
go-version: [1.21.5]
os: [ubuntu-latest, macos-latest, windows-2022]
runs-on: ${{ matrix.os }}
steps:

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Run tests
run: make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/bin
/dist
__debug_bin*
.vscode
.coverage
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "testdata/charts"]
path = testdata/charts
url = https://github.com/qvalentin/charts.git
10 changes: 10 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with-expecter: true
packages:
go.lsp.dev/protocol:
# place your package-specific config here
config:
interfaces:
# select the interfaces you want mocked
Client:
# Modify package-level config for this specific interface (if applicable)
config:
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export BIN=$(ROOT)/bin
export GOBIN?=$(BIN)
export GO=$(shell which go)
export PACKAGE_NAME=github.com/mrjosh/helm-ls
export GOLANG_CROSS_VERSION=v1.20.6
export GOLANG_CROSS_VERSION=v1.21.5
export CGO_ENABLED=1

$(eval GIT_COMMIT=$(shell git rev-parse --short HEAD))
$(eval BRANCH_NAME=$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match))
Expand Down Expand Up @@ -54,8 +55,20 @@ install-metalinter:
@$(GO) get -v github.com/golangci/golangci-lint/cmd/[email protected]
@$(GO) install -v github.com/golangci/golangci-lint/cmd/[email protected]

install-yamlls:
npm install --global yaml-language-server

integration-test-deps:
@YAMLLS_BIN=$$(command -v yaml-language-server) || { echo "yaml-language-server command not found! Installing..." && $(MAKE) install-yamlls; };
git submodule init
git submodule update --depth 1

test:
@$(GO) test ./... -v -race
$(MAKE) integration-test-deps
@$(GO) test ./... -v -race -tags=integration

coverage:
@$(GO) test -coverprofile=.coverage -tags=integration -coverpkg=./internal/... ./internal/... && go tool cover -html=.coverage

.PHONY: build-release
build-release:
Expand Down
135 changes: 108 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,35 @@ ln -s ~/projects/helm-ls/dist/linux-amd64_linux_amd64_v1/helm-ls ~/.local/share/
\/ /_/ \___|_|_| |_| |_\____/___/
</pre>

## Helm Language Server Protocol
## Helm Language Server

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)
* [Installation with a package manager](#installation-with-a-package-manager)
* [Download](#download)
* [Installation with a package manager](#installation-with-a-package-manager)
* [Homebrew](#homebrew)
* [Nix](#nix)
* [Arch Linux](#arch-linux)
* [Windows](#windows)
* [mason (neovim)](#mason-neovim)
* [Manual download](#manual-download)
* [Make it executable](#make-it-executable)
* [Integration with yaml-language-server](#integration-with-yaml-language-server)
* [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)
* [Default Configuration](#default-configuration)
* [General](#general)
* [Values Files](#values-files)
* [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)
* [VSCode](#vscode)
* [Emacs eglot setup](#emacs-eglot-setup)
* [Neovim (using nvim-lspconfig)](#neovim-using-nvim-lspconfig)
* [Vim Helm Plugin](#vim-helm-plugin)
* [nvim-lspconfig setup](#nvim-lspconfig-setup)
* [coc.nvim setup](#cocnvim-setup)
* [VSCode](#vscode)
* [Emacs eglot setup](#emacs-eglot-setup)
* [Contributing](#contributing)
* [License](#license)

Expand All @@ -55,7 +62,48 @@ Helm-ls is currently available as a package for some package managers.

[![Packaging status](https://repology.org/badge/vertical-allrepos/helm-ls.svg)](https://repology.org/project/helm-ls/versions)

### Download
These are some of the supported package managers. Thanks to everyone who packaged it!

#### Homebrew

If you are using MacOS or Linux with [Homebrew](https://brew.sh/) you can install it with brew.

```bash
brew install helm-ls
```

#### Nix

```bash
nix-shell -p helm-ls
```

#### Arch Linux

You can install it from the [aur](https://aur.archlinux.org/packages/helm-ls/) using your preferred aur helper, e.g. yay:

```bash
yay -S helm-ls
```

#### Windows

You can use [scoop](https://scoop.sh/) to install it:

```powershell
scoop bucket add extras
scoop install extras/helm-ls
```

#### mason (neovim)

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

```vim
:MasonInstall helm-ls
```

### Manual 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

Expand All @@ -65,9 +113,7 @@ Helm-ls is currently available as a package for some package managers.
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
#### Make it executable

```bash
chmod +x /usr/local/bin/helm_ls
Expand All @@ -76,8 +122,11 @@ 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.

> [!WARNING]
>
> This feature is experimental, you can disable it in the config ([see](#configuration-options)) if you are getting a lot of errors beginning with `Yamlls:`.
> Having a broken template syntax (e.g. while your are still typing) will also cause diagnostics from yaml-language-server to be shown as errors.
To install it using npm run (or use your preferred package manager):

Expand All @@ -99,17 +148,23 @@ kind: ScaledObject
You can configure helm-ls with lsp workspace configurations.
### LSP Server
### General
- **Log Level**: Adjust log verbosity.
### Values Files
- **Main Values File**: Path to the main values file (values.yaml per default)
- **Lint Overlay Values File**: Path to the lint overlay values file, which will be merged with the main values file for linting
- **Additional Values Files Glob Pattern**: Pattern for additional values files, which will be shown for completion and hover
### 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.
- **Limit**: Number of displayed diagnostics per file. Set this to 0 to disable all diagnostics from yaml-language-server but keep other features such as hover.
- **Show Directly**: Show diagnostics while typing.
- **Additional Settings** (see [yaml-language-server](https://github.com/redhat-developer/yaml-language-server#language-server-settings)):
Expand All @@ -122,19 +177,24 @@ You can configure helm-ls with lsp workspace configurations.
```lua
settings = {
['helm-ls'] = {
logLevel = "debug",
logLevel = "info",
valuesFiles = {
mainValuesFile = "values.yaml",
lintOverlayValuesFile = "values.lint.yaml",
additionalValuesFilesGlobPattern = "values*.yaml"
},
yamlls = {
enabled = true,
diagnosticsLimit = 50,
showDiagnosticsDirectly = false,
path = "yaml-language-server",
config = {
schemas = {
kubernetes = "**",
kubernetes = "templates/**",
},
completion = true,
hover = true,
-- any other config: https://github.com/redhat-developer/yaml-language-server#language-server-settings
-- any other config from https://github.com/redhat-developer/yaml-language-server#language-server-settings
}
}
}
Expand All @@ -147,13 +207,15 @@ settings = {

#### 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):
To get filetype detection working, you'll need the [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
#### nvim-lspconfig setup

Add the following to your neovim lua config:

```lua
local lspconfig = require('lspconfig')
Expand All @@ -172,6 +234,25 @@ settings = {
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.

#### coc.nvim setup

You can also use [coc.nvim](https://github.com/neoclide/coc.nvim) to set up the language server.
You will need to configure the use of `helm_ls` in the `langageserver` section of your `coc-settings.json` file.

Open Neovim and type the command `:CocConfig` to access the configuration file. Find the `langageserver` section and add this configuration:

```json
"languageserver": {
"helm": {
"command": "helm_ls",
"args": ["serve"],
"filetypes": ["helm", "helmfile"],
"rootPatterns": ["Chart.yaml"]
}
}
```

Save the configuration file and then either restart Neovim or type `:CocRestart` to restart the language server.

### VSCode

Expand Down Expand Up @@ -213,10 +294,10 @@ Alternatively, you can include a comment such as the following at the top of Hel

## Contributing

Thank you for considering contributing to HelmLs project!
Thank you for considering contributing to Helm-ls project!

## License

The HelmLs is open-source software licensed under the MIT license.
The Helm-ls 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.
8 changes: 6 additions & 2 deletions cmds/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

"github.com/mrjosh/helm-ls/internal/charts"
locallsp "github.com/mrjosh/helm-ls/internal/lsp"
"github.com/spf13/cobra"
"go.lsp.dev/uri"
Expand All @@ -14,16 +15,19 @@ func newLintCmd() *cobra.Command {
Use: "lint",
Short: "Lint a helm project",
RunE: func(cmd *cobra.Command, args []string) error {

if len(args) == 0 {
args = append(args, os.Getenv("PWD"))
}

msgs, err := locallsp.GetDiagnostics(uri.New(args[0]), []string{})
rootPath := uri.File(args[0])
chartStore := charts.NewChartStore(rootPath, charts.NewChart)
chart, err := chartStore.GetChartForURI(rootPath)
if err != nil {
return err
}

msgs := locallsp.GetDiagnostics(rootPath, chart.ValuesFiles.MainValuesFile.Values)

for _, msg := range msgs {
fmt.Println(msg)
}
Expand Down
Loading

0 comments on commit f1b34ac

Please sign in to comment.