Coder Social home page Coder Social logo

uros-5 / jinja-lsp Goto Github PK

View Code? Open in Web Editor NEW
59.0 2.0 1.0 3.52 MB

Language Server for jinja

Home Page: https://crates.io/crates/jinja-lsp

License: MIT License

TypeScript 1.98% Rust 95.08% JavaScript 1.01% Jinja 1.61% Python 0.33%
helix jinja jinja2 lsp minijinja nvim rust

jinja-lsp's Introduction

banner

jinja-lsp enhances minijinja development experience by providing Helix/Nvim users with advanced features such as autocomplete, syntax highlighting, hover, goto definition, code actions and linting.

crates.io visualstudio.com

Installation

cargo install jinja-lsp

Features

Autocomplete

Intelligent suggestions for variables in current template, as well as variables, templates and filters defined on backend side.

Linting

Highlights errors and potential bugs in your jinja templates.

Hover Preview

See the complete filter or variable description by hovering over it.

Code Actions

It's recommended to reset variables on server in case you rename/delete file.

Goto Definition

Quickly jump to definition. Works for Rust identifiers as well.

jinja-lsp.mp4

Snippets

Document symbols

Configuration

Language server configuration

{ "templates": "./TEMPLATES_DIR", "backend": ["./BACKEND_DIR"], "lang": "rust"}

Helix configuration

[language-server.jinja-lsp]
command = "jinja-lsp"
config = { templates = "./templates", backend = ["./src"], lang = "rust"}
timeout = 5

[[language]]
name = "jinja"
language-servers = ["jinja-lsp"]

Neovim configuration

vim.filetype.add {
  extension = {
    jinja = 'jinja',
    jinja2 = 'jinja',
    j2 = 'jinja',
  },
}

-- if you want to debug
vim.lsp.set_log_level("debug")

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

if not configs.jinja_lsp then
configs.jinja_lsp = {
  default_config = {
    name = "jinja-lsp",
    cmd = { 'path_to_lsp_or_command' },
    filetypes = { 'jinja', 'rust' },
    root_dir = function(fname)
      return "."
      --return nvim_lsp.util.find_git_ancestor(fname)
    end,
    init_options = {
      templates = './templates',
      backend = { './src' },
      lang = "rust"
    },
},
}
end
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
nvim_lsp.jinja_lsp.setup {
  capabilities = capabilities
}
nvim_lsp.jinja_lsp.setup {
}

Supported languages: Python, Rust

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.