Skip to content

Varnish VCL language server

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

M4R7iNP/varnishls

Repository files navigation

varnishls

varnishls is a Varnish Language Server. Provides some autocomplete, jump to definition across files and basic linting. Made for Varnish 6.0 (plus), but it should work with other versions - except Fastly.

asciicast

Setup

make tree-sitter-vcl tree-sitter-vtc
make build

Config

# .varnishls.toml in your workspace dir
main_vcl = "vg/varnish.vcl" # path to the main vcl file varnish uses
vmod_paths = ["/usr/lib/varnish-plus/vmods/"] # paths to directories containing your vmods (.so binaries)
vcc_paths = ["/usr/src/varnish-cache/lib/"] # paths to directories containing vcc files (vmod definition files)
vcl_paths = ["./", "/usr/share/varnish-plus/vcl/"] # paths to directories containing vcl (default ./)
[lint]
prefer_else_if = "hint"
prefer_lowercase_headers = "hint"
prefer_custom_headers_without_prefix = false

Allowed levels for linting rules are error, warning, info, and hint. Set to false to disable a rule.

NOTE: vcc_paths takes precedence over vmod_paths when searching for vmods, since vcc also has documentation.

Neovim lsp setup:

local lspconfig = require('lspconfig')
local lsp_configs = require('lspconfig.configs')

lsp_configs.varnishls = {
  default_config = {
    -- Change the path to varnishls (add --debug for debug log)
    cmd = { "/home/martin/varnishls/target/debug/varnishls", "lsp", "--stdio" },
    filetypes = { "vcl", "vtc" },
    root_dir = lspconfig.util.root_pattern(".varnishls.toml", ".git"),
    settings = {},
  }
}

It is technically possible to use the tree-sitter grammar for syntax highlighting, but this is even more WIP than the lsp.

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
for _, lang in pairs({ "vcl", "vtc" }) do
  parser_config[lang] = {
    install_info = {
      url = "/<path to this repo>/vendor/tree-sitter-" .. lang,
      files = {"src/parser.c"},
    }
  }
end

vim.filetype.add({ extension = { vcl = 'vcl', vtc = 'vtc' } })

Run :TSInstallFromGrammar vcl after adding the nvim-treesitter config.

Inspiration:

About

Varnish VCL language server

Topics

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages