Coder Social home page Coder Social logo

varnishls's Introduction

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:

varnishls's People

Contributors

m4r7inp avatar auduny avatar

Stargazers

Isabelle Carlsson avatar Alve Elde avatar Thomas Lekanger avatar  avatar Erik Kristensen avatar Federico G. Schwindt avatar Kyle Simukka avatar Filip Golonka avatar  avatar Daiki Noda avatar Ole-Kenneth avatar Ole Fredrik Skudsvik avatar Mads Erik Forberg avatar Edvard Høiby avatar

Watchers

 avatar

Forkers

auduny olesku

varnishls's Issues

Support multiline strings

VCL supports multiline strings, we should support that as well

""" is allowed wherever VCL_STRING is expected

Syntax error on multi line probes

probe static_probe {
    .request =
        "GET /index.html HTTP/1.1"
        "Host: static.example.no"
        "User-Agent: varnish-probe"
        "Connection: close";

Here varnish-lsp says that there needs to be a "; " at each line. But this is a multiline terminated by a final ;

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.