Refresh generated neovim config
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
#!/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/sh
|
||||
#!/nix/store/4bj2kxdm1462fzcc2i2s4dn33g2angcc-bash-5.2p32/bin/sh
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# This is free and unencumbered software released into the public domain.
|
||||
|
||||
@ -45,6 +45,7 @@ describe('Buffer Manipulation', function()
|
||||
nvim:exec_lua('TSEnsure(...)', {'lua', 'markdown'})
|
||||
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_with_injected_lua, '\n'))
|
||||
nvim:buf_set_option(0, 'filetype', 'markdown')
|
||||
nvim:exec_lua('vim.treesitter.start()', {})
|
||||
assert.nvim(nvim).has_extmarks_at(3, 5, 'lua')
|
||||
|
||||
-- Move Lua line out of code block
|
||||
@ -60,6 +61,7 @@ describe('Buffer Manipulation', function()
|
||||
nvim:exec_lua('TSEnsure(...)', {'lua', 'markdown'})
|
||||
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_without_injected_lua, '\n'))
|
||||
nvim:buf_set_option(0, 'filetype', 'markdown')
|
||||
nvim:exec_lua('vim.treesitter.start()', {})
|
||||
assert.nvim(nvim).Not.has_extmarks_at(4, 5, 'lua')
|
||||
|
||||
-- Move Lua line out of code block
|
||||
|
||||
@ -5,27 +5,50 @@ describe('We can disable rainbow delimiters for certain languages', function()
|
||||
|
||||
before_each(function()
|
||||
nvim = yd.start()
|
||||
nvim:exec_lua('the_strategy = require("rainbow-delimiters.strategy.track")(require("rainbow-delimiters.strategy.no-op"))', {})
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
yd.stop(nvim)
|
||||
end)
|
||||
|
||||
it('Does not run for a blacklisted language', function()
|
||||
nvim:exec_lua('the_strategy = require("rainbow-delimiters.strategy.track")(require("rainbow-delimiters.strategy.no-op"))', {})
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {blacklist = {"lua"}, strategy = {[""] = the_strategy}}', {})
|
||||
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(0, attachments)
|
||||
describe('For the given language', function()
|
||||
before_each(function()
|
||||
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
|
||||
end)
|
||||
|
||||
it('Does not run when blacklisted', function()
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {strategy = {[""] = the_strategy}, blacklist = {"lua"}}', {})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(0, attachments)
|
||||
end)
|
||||
|
||||
it('Runs when whitelisted', function()
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {strategy = {[""] = the_strategy}, whitelist = {"lua"}}', {})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(1, attachments)
|
||||
end)
|
||||
end)
|
||||
|
||||
it('Runs for a whitelisted language', function()
|
||||
nvim:exec_lua('the_strategy = require("rainbow-delimiters.strategy.track")(require("rainbow-delimiters.strategy.no-op"))', {})
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {whitelist = {"lua"}, strategy = {[""] = the_strategy}}', {})
|
||||
nvim:buf_set_lines(0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(1, attachments)
|
||||
describe('For another language', function()
|
||||
before_each(function()
|
||||
nvim:buf_set_lines(0, 0, -1, true, {'echo "Hello world"', '" vim:ft=vim'})
|
||||
end)
|
||||
|
||||
it('Runs when not blacklisted', function()
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {strategy = {[""] = the_strategy}, blacklist = {"lua"}}', {})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(1, attachments)
|
||||
end)
|
||||
|
||||
it('Does not run when not whitelisted', function()
|
||||
nvim:exec_lua('vim.g.rainbow_delimiters = {strategy = {[""] = the_strategy}, whitelist = {"lua"}}', {})
|
||||
nvim:command('filetype detect')
|
||||
local attachments = nvim:exec_lua('return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(0, attachments)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
---
|
||||
// component import
|
||||
import MainLayout from "../../layouts/MainLayout.astro";
|
||||
import PostCard from "../../components/PostCard.astro";
|
||||
|
||||
// utils imports
|
||||
import { formatBlogPosts } from "../../js/utils";
|
||||
|
||||
const allPosts = await Astro.glob("./*.md");
|
||||
const formattedPosts = formatBlogPosts(allPosts, {});
|
||||
---
|
||||
|
||||
<MainLayout title="My Blog">
|
||||
<section class="container" aria-label="New Blog Posts">
|
||||
<h1 class="h1">New Blog Posts</h1>
|
||||
<div class="post-container">
|
||||
{
|
||||
formattedPosts.map((post) => (
|
||||
<PostCard
|
||||
frontmatter={post.frontmatter}
|
||||
url={post.url}
|
||||
tagType="h2"
|
||||
/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
<!-- <PostCard
|
||||
frontmatter={allPosts[0].frontmatter}
|
||||
url={allPosts[0].url}
|
||||
tagType="h2"
|
||||
/> -->
|
||||
</MainLayout>
|
||||
@ -1,30 +0,0 @@
|
||||
#!/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/bash
|
||||
|
||||
# Command substitution
|
||||
echo $(basedir $(pwd))
|
||||
|
||||
# Variable expansion
|
||||
echo ${FOO:-${BAR:-${BAZ}}}
|
||||
|
||||
# Test expression (using the `test` command)
|
||||
if [ -d "herp/derp/" ]; then
|
||||
echo "Yay"
|
||||
fi
|
||||
|
||||
# Test expression (bashism)
|
||||
if [[ -d "herp/derp/" ]]; then
|
||||
echo "Yay"
|
||||
fi
|
||||
|
||||
# Sub-shells
|
||||
(true; false; (true; true; (false; true)))
|
||||
|
||||
person() {
|
||||
array=(
|
||||
[Alice]="$((2 ^ 10))"
|
||||
[Bob]=2048
|
||||
)
|
||||
echo "${array[$1]}"
|
||||
}
|
||||
|
||||
person "Alice"
|
||||
@ -1,82 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define PI 3.14
|
||||
/* These aren't highlight correctly. A problem with the parser? */
|
||||
#define TESTMACRO (-1)
|
||||
#define min(X,Y) ((X) < (Y) ? (X) : (Y))
|
||||
|
||||
|
||||
/* Declaration with parentheses, a function pointer */
|
||||
static void (*callback)(int);
|
||||
int c_init() { return 1; }
|
||||
|
||||
/* Macro type specifier */
|
||||
#define Map int Foo
|
||||
static Map(char *c_str) {return 4;}
|
||||
|
||||
typedef enum {
|
||||
E1,
|
||||
E2,
|
||||
E3
|
||||
// comment
|
||||
} Myenum;
|
||||
|
||||
/* A function declaration */
|
||||
int add(int, int);
|
||||
|
||||
struct Point2D {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
/* Compound literal expression */
|
||||
struct Point2D v = (struct Point2D){ 0, 0 };
|
||||
|
||||
/* A function definition */
|
||||
int add(int x, int y) {
|
||||
if (!y) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (0) {
|
||||
while (0) {
|
||||
while (0) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0; i++) {
|
||||
for (int j = 0; j < 0; j++) {
|
||||
for (int k = 0; k < 0; k++) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return add(x + 1, y - 1);
|
||||
}
|
||||
|
||||
float int2float(int i) {
|
||||
return (float)i;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int a = 10, b = 5;
|
||||
int result = add(a, b);
|
||||
printf("The sum of %d and %d is %d", ((((a)))), b, result);
|
||||
int indices[] = {0, };
|
||||
int i = indices[indices[indices[indices[indices[indices[0]]]]]];
|
||||
#if 0
|
||||
/* A language server may mark this block semantically as a comment */
|
||||
printf("The sum of %d and %d is %d", ((((a)))), b, result);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
// A version of the classic "Hello World" program
|
||||
class Program {
|
||||
static void Main() {
|
||||
Console.WriteLine("Hello, world!");
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
|
||||
// Arrays and nested arrays
|
||||
class Program {
|
||||
static void Main() {
|
||||
int[,,] array3D = new int[,,] {
|
||||
{ {1}, {2} },
|
||||
{ {3}, {4} },
|
||||
{ {5}, {6} },
|
||||
{ {7}, {8} },
|
||||
};
|
||||
int[] indices = new int[] {0};
|
||||
int i = array3D[0, 0, 0];
|
||||
var implicitArray = new[] { "" };
|
||||
int j = indices[indices[indices[indices[0]]]];
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
internal class TestAttribute : Attribute { }
|
||||
|
||||
[Test()]
|
||||
public class Person
|
||||
{
|
||||
[Test()]
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
public class A<T> { }
|
||||
|
||||
public struct B<T> { }
|
||||
|
||||
public interface C<T> : A<IEnumerable<T>> { }
|
||||
|
||||
// Nested generic parameters
|
||||
class Program {
|
||||
static void Main(List<List<List<T>>> l) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
|
||||
|
||||
// Nested loops
|
||||
class Program {
|
||||
static int[] integers = {0, 1, 2, 3};
|
||||
|
||||
static void Main() {
|
||||
foreach (int i in integers) {
|
||||
foreach (int i in integers) {
|
||||
foreach (int i in integers) {
|
||||
foreach (int i in integers) {
|
||||
while (false) {
|
||||
Console.WriteLine("Hello, world!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
public class TestClass
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public int[][]? MultiDimArray { get; set; }
|
||||
|
||||
private string MergeLines(IEnumerable<IEnumerable<string>> sections)
|
||||
{
|
||||
return string.Join(",", sections.SelectMany(t => t));
|
||||
}
|
||||
|
||||
private void LoopTest()
|
||||
{
|
||||
foreach (var item in new string[0]) { }
|
||||
|
||||
for (int i = 0; i < 0; i++) { }
|
||||
|
||||
while (false) { }
|
||||
|
||||
do { } while (false);
|
||||
}
|
||||
|
||||
private void Interpolation()
|
||||
{
|
||||
var passTitle = "123";
|
||||
if (true) {
|
||||
System.Console.WriteLine($"== {passTitle} ==");
|
||||
}
|
||||
}
|
||||
|
||||
private void AnonymousObject()
|
||||
{
|
||||
var a = new { Test = 123, };
|
||||
}
|
||||
|
||||
private (int a, float b, (int c, float d)) TupleExpressions()
|
||||
{
|
||||
return (1, 2, (3, 4));
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
// Nested parenthesized expressions
|
||||
class Program {
|
||||
static void Main() {
|
||||
var i = (((((1 + 2))) + ((((3))))));
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
public static class SwitchTest
|
||||
{
|
||||
private static string GenericFirstCharProcessing(
|
||||
this string input,
|
||||
Func<string, string> firstCharProcessor
|
||||
) =>
|
||||
input switch
|
||||
{
|
||||
null => throw new ArgumentNullException(nameof(input)),
|
||||
"" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
|
||||
_ => firstCharProcessor(input[0].ToString()) + input.Substring(1)
|
||||
};
|
||||
|
||||
private static void T()
|
||||
{
|
||||
var defaultInt = default(int);
|
||||
|
||||
try { }
|
||||
catch (Exception e) when (true) { }
|
||||
finally { }
|
||||
|
||||
using (var stream = new Stream()) { }
|
||||
|
||||
lock (new string()) { }
|
||||
|
||||
var name = "test";
|
||||
switch (name)
|
||||
{
|
||||
case "aab":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case var o when (o?.Trim().Length ?? 0) == 0:
|
||||
case "test":
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int c = (int)b; // explicit conversion from long to int
|
||||
|
||||
Type[] t = { typeof(int), };
|
||||
sizeof(int);
|
||||
int AllBits = unchecked((int)0xFFFFFFFF);
|
||||
int AllBits = checked((int)0xFFFFFFFF);
|
||||
Span<long> span5 = stackalloc[] { 11, 12, 13 };
|
||||
}
|
||||
|
||||
enum Color
|
||||
{
|
||||
Red,
|
||||
Blue,
|
||||
Green
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
(defn fn-name "docs" [a0 a1 & xz]
|
||||
[
|
||||
"some _text_ with parens #() #{} {} [] (#())"
|
||||
'(#(identity ""))
|
||||
[[[], [[]]], #(:k {}), #{{}, ""}, '((())), `({})]
|
||||
]
|
||||
)
|
||||
|
||||
(fn-name 1 2 3 4)
|
||||
@ -1,16 +0,0 @@
|
||||
(defun add (x y)
|
||||
"A silly way to add two numbers recursively."
|
||||
(if (zerop y)
|
||||
x
|
||||
(add (incf x)
|
||||
(decf y))))
|
||||
|
||||
(defmacro foo (a &rest rest)
|
||||
`(format t "~A~%" (list ,a ,@rest)))
|
||||
|
||||
;;; The LOOP macro has its own node type
|
||||
(loop repeat 3
|
||||
do (print "Hello world"))
|
||||
|
||||
'(((a . b)))
|
||||
'((((a b . c))))
|
||||
@ -1,79 +0,0 @@
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
|
||||
namespace herp {
|
||||
const int derpiness = 9000;
|
||||
int get_derpiness() {
|
||||
return derpiness;
|
||||
}
|
||||
}
|
||||
|
||||
/* A function declaration */
|
||||
int add(int, int);
|
||||
|
||||
// Structure and class definitions
|
||||
struct Point2D {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class Point3D {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
};
|
||||
|
||||
/* A function definition */
|
||||
int add(int x, int y) {
|
||||
if (!y) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (0) {
|
||||
while (0) {
|
||||
while (0) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0; i++) {
|
||||
for (int j = 0; j < 0; j++) {
|
||||
for (int k = 0; k < 0; k++) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return add(x + 1, y - 1);
|
||||
}
|
||||
|
||||
template <typename T> T myMax(T x, T y) {
|
||||
return (x > y) ? x : y;
|
||||
}
|
||||
|
||||
float int2float(int i) {
|
||||
return (float)i;
|
||||
}
|
||||
|
||||
void do_nothing_with_vector(std::vector<std::vector<std::vector<int>>> v) {
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto a {10};
|
||||
auto b (5);
|
||||
auto result = add(a, b);
|
||||
printf("The sum of %d and %d is %d", ((((a)))), b, result);
|
||||
int indices[] = {0, };
|
||||
auto i = indices[indices[indices[indices[indices[indices[0]]]]]];
|
||||
return 0;
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
:root {
|
||||
@media (prefers-color-scheme: dark) {
|
||||
--color-bg: #3b4252;
|
||||
--color-fg: #eceff4;
|
||||
--color-gray: #434c5e;
|
||||
--color-blue: #81a1c1;
|
||||
}
|
||||
}
|
||||
|
||||
li:has(input[type="checkbox"]) {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.foo {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
@media (not (color)) {
|
||||
.foo {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
@ -1,87 +0,0 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
/* A function declaration */
|
||||
int add(int, int);
|
||||
|
||||
// Structure and class definitions
|
||||
struct Point2D {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class Point3D {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
};
|
||||
|
||||
/* A function definition */
|
||||
int add(int x, int y) {
|
||||
if (!y) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
if (1) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (0) {
|
||||
while (0) {
|
||||
while (0) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0; i++) {
|
||||
for (int j = 0; j < 0; j++) {
|
||||
for (int k = 0; k < 0; k++) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return add(x + 1, y - 1);
|
||||
}
|
||||
|
||||
template <typename T> T myMax(T x, T y) {
|
||||
return (x > y) ? x : y;
|
||||
}
|
||||
|
||||
float int2float(int i) {
|
||||
return (float)i;
|
||||
}
|
||||
|
||||
void do_nothing_with_vector(std::vector<std::vector<std::vector<int>>> v) {
|
||||
return;
|
||||
}
|
||||
|
||||
__global__ void add_array(int *a, int size) {
|
||||
int i = threadIdx.x + blockIdx.x * blockDim.x;
|
||||
if (i < size) {
|
||||
a[i] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void call_device() {
|
||||
int *dev_a;
|
||||
cudaMalloc(&dev_a, 10 * sizeof(int));
|
||||
add_array<<<1, 10, 1>>>(dev_a, 10);
|
||||
cudaFree(dev_a);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto a {10};
|
||||
auto b (5);
|
||||
auto result = add(a, b);
|
||||
printf("The sum of %d and %d is %d", ((((a)))), b, result);
|
||||
int indices[] = {0, };
|
||||
auto i = indices[indices[indices[indices[indices[indices[0]]]]]];
|
||||
return 0;
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
HumanA: {
|
||||
name: "Bob"
|
||||
description: "A human named \(strings.ToUpper(name))"
|
||||
}
|
||||
|
||||
_#ComplexType: (int | string) | bool
|
||||
|
||||
ok: _#ComplexType & 13
|
||||
|
||||
numList: [...int] & [ 1, 2, 3, 4 ]
|
||||
|
||||
elems: [Name=_]: {name: Name}
|
||||
elems: {
|
||||
one: {}
|
||||
two: {}
|
||||
}
|
||||
|
||||
_env: string | *"dev" @tag(env,type=string)
|
||||
host: "\(_env).example.com"
|
||||
|
||||
environments: (_env): "\(numList[1])"
|
||||
@ -1,55 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExampleWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String image;
|
||||
final String id;
|
||||
|
||||
const WidgetItem({
|
||||
super.key,
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final data = {['field'] = "<value>"};
|
||||
final theme = Theme.of(context);
|
||||
return GestureDetector(
|
||||
onTap: () => context.go('/example/$id'),
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Image(
|
||||
image: AssetImage('assets/image.jpg'),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(subtitle),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
defmodule Regular do
|
||||
@moduledoc """
|
||||
A dummy test module.
|
||||
"""
|
||||
|
||||
def first_plus_five([head | tail]) do
|
||||
IO.puts "The first value is #{head}"
|
||||
head + (((1 + (2 + 3))))
|
||||
end
|
||||
|
||||
def first_plus_five({a, b}) do
|
||||
IO.puts "The first value is #{a}"
|
||||
a + (((1 + (2 + 3))))
|
||||
end
|
||||
|
||||
def first_plus_five(<<r, g, b>>) do
|
||||
IO.puts "The first value is #{r}"
|
||||
r + (((1 + (2 + 3))))
|
||||
end
|
||||
|
||||
def first_plus_five(%{head => _}) do
|
||||
IO.puts "The first value is #{head}"
|
||||
head + (((1 + (2 + 3))))
|
||||
end
|
||||
|
||||
defp accessLookup(map, x) do
|
||||
map[map[map[map[x]]]]
|
||||
end
|
||||
end
|
||||
|
||||
# Keyword list syntactic sugar
|
||||
IO.puts inspect([a: 1, b: [c: 3, d: [e: 5, f: []]]])
|
||||
|
||||
# Map syntactic sugar
|
||||
IO.puts inspect(%{a => 1, b => %{c => 3, d => %{e => 5, f => %{}}}})
|
||||
@ -1,51 +0,0 @@
|
||||
module Regular exposing (CustomType(..))
|
||||
|
||||
import Browser exposing (UrlRequest(..))
|
||||
import Url.Parser exposing ((</>), (<?>))
|
||||
|
||||
|
||||
type CustomType a
|
||||
= CustomType a
|
||||
|
||||
|
||||
type alias NestedRecordOfCustomType a =
|
||||
{ a : ( Int, List (Maybe ( Int, CustomType a )) )
|
||||
, b : ( Int, { c : CustomType a } )
|
||||
, d : { f : { g : String } }
|
||||
}
|
||||
|
||||
|
||||
nestedTypeExpr : Int -> (Int -> Int) -> (Int -> (Int -> Int))
|
||||
nestedTypeExpr x y =
|
||||
\z -> y
|
||||
|
||||
|
||||
nestedListPatternFunction : List (List ( Int, List ( Int, String ) )) -> List ( String, Int )
|
||||
nestedListPatternFunction list =
|
||||
List.concatMap (\( _, strings ) -> List.map (\( a, b ) -> ( b, a )) strings) (List.concat list)
|
||||
|
||||
|
||||
unwrapCustomType : { b | c : Int } -> CustomType (CustomType { a : Int }) -> Int
|
||||
unwrapCustomType { c } (CustomType (CustomType ({ a } as b))) =
|
||||
(a + (c * 1)) * (a - (a + (b.a * 1)))
|
||||
|
||||
|
||||
patternMatchNestedListOfRecords : List (List (NestedRecordOfCustomType Int)) -> Maybe (List (List (NestedRecordOfCustomType Int)))
|
||||
patternMatchNestedListOfRecords list =
|
||||
case [ list ] of
|
||||
[ [ [ { a, b } ] ] ] ->
|
||||
case ( a, b ) of
|
||||
( ( 1, [ Just ( 1, ct ) ] ), ( 2, { c } ) ) ->
|
||||
Just
|
||||
[ [ { a = ( 1, [ Just ( 1, c ) ] )
|
||||
, b = ( 2, { c = ct } )
|
||||
, d = { f = { g = "test" } }
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
@ -1,96 +0,0 @@
|
||||
(print (.. "foo" "bar"))
|
||||
|
||||
(local abcd { :a { :b { :c { :d {}}}}})
|
||||
|
||||
(let [one 1 two 2 tbl { : one : two}]
|
||||
tbl)
|
||||
|
||||
;;; Destructuring a table binding
|
||||
(let [{:a {:b {:c {:d d}}}} abcd]
|
||||
(print d))
|
||||
|
||||
[0 [1 [2 [3 []]]]]
|
||||
|
||||
;; NOTE: the single ":" on the second line could also be a delimiter
|
||||
{:a :b
|
||||
: abcd}
|
||||
|
||||
;;; Get AST root
|
||||
(fn get-root [bufnr]
|
||||
;;; Get current buffer
|
||||
(local bufnr (or bufnr
|
||||
(vim.api.nvim_get_current_buf)))
|
||||
|
||||
;;; Early return if not in a Nix file
|
||||
(when (not= (. vim :bo bufnr :filetype)
|
||||
:nix)
|
||||
(vim.notify_once "This is meant to be used with Nix files")
|
||||
(lua "return nil"))
|
||||
|
||||
(let [parser (vim.treesitter.get_parser bufnr :nix {})
|
||||
[tree] (parser:parse)]
|
||||
(tree:root)))
|
||||
|
||||
(macro -m?> [val ...]
|
||||
"Thread (maybe) a value through a list of method calls"
|
||||
(assert-compile
|
||||
val
|
||||
"There should be an input value to the pipeline")
|
||||
(var res# (gensym))
|
||||
(var res `(do (var ,res# ,val)))
|
||||
(each [_ [f & args] (ipairs [...])]
|
||||
(table.insert
|
||||
res
|
||||
`(when (and (not= nil ,res#)
|
||||
(not= nil (. ,res# ,f)))
|
||||
(set ,res# (: ,res# ,f ,(unpack args))))))
|
||||
res)
|
||||
|
||||
(fn add-partial [x]
|
||||
(fn [y]
|
||||
(fn [z] (+ x y z))))
|
||||
|
||||
(λ sub-partial [x]
|
||||
(λ [y]
|
||||
(λ [z] (- x y z))))
|
||||
|
||||
(let [a 1]
|
||||
(let [b 2]
|
||||
(let [c 3]
|
||||
(+ a b c))))
|
||||
|
||||
(let [t {:a 4 :b 8}]
|
||||
(set t.a 2) t)
|
||||
|
||||
(let [(a b c) (values 1 2 3)]
|
||||
(+ a b c))
|
||||
|
||||
(match (add-partial 5 6 7)
|
||||
[1 [2] 3] (print "osuhow")
|
||||
12 :dont
|
||||
x x)
|
||||
|
||||
(each [key value (pairs {"a" 1 "b" 2})]
|
||||
(print key value))
|
||||
|
||||
(for [i 1 10]
|
||||
(print i))
|
||||
|
||||
(var numbers [1 2 3 4 5 6])
|
||||
|
||||
(collect [_ x (ipairs numbers)]
|
||||
(values x true))
|
||||
|
||||
(icollect [_ x (ipairs numbers)]
|
||||
(+ x 1))
|
||||
|
||||
(fcollect [i 0 10 2]
|
||||
(if (> i 2) (* i i)))
|
||||
|
||||
(accumulate [acc 0 _ x (ipairs numbers)]
|
||||
(+ acc x))
|
||||
|
||||
(faccumulate [n 0 i 1 5] (+ n i)) ; => 15
|
||||
|
||||
(#(faccumulate [n 1 i 1 $] (* n i)) 5) ; => 120 (factorial!)
|
||||
((hashfn (faccumulate [n 1 i 1 $] (* n i))) 5) ; => 120 (factorial!)
|
||||
@ -1,7 +0,0 @@
|
||||
set -l shells "$SHELL" /bin/{zsh,bash,sh} (which nu) /usr/bin/xonsh
|
||||
|
||||
echo "Your first few shells is $shells[1..3]"
|
||||
|
||||
if set -q shells[10]
|
||||
echo "You defined at least 10 shells"
|
||||
end
|
||||
@ -1,108 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
const (
|
||||
TOOEXPENSIVE = 200
|
||||
)
|
||||
|
||||
type Wine struct {
|
||||
Name string
|
||||
Produced int
|
||||
Price float32
|
||||
InStock bool
|
||||
}
|
||||
|
||||
func (w Wine) String() string {
|
||||
return fmt.Sprintf("Name: %s, Produced: %d, Cost: %0.2f", w.Name, w.Produced, w.Price)
|
||||
}
|
||||
|
||||
type ByProduced []Wine
|
||||
|
||||
func (a ByProduced) Len() int { return len(a) }
|
||||
func (a ByProduced) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByProduced) Less(i, j int) bool { return a[i].Produced < a[j].Produced }
|
||||
|
||||
func isFloat32(i interface{}) bool {
|
||||
switch v := i.(type) {
|
||||
case float32:
|
||||
fmt.Printf("%v is a float32", i.(float32))
|
||||
return true
|
||||
default:
|
||||
fmt.Printf("%v is not a float32", v)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func SumUp[K comparable, V float32](v1 V, v2 V) V {
|
||||
return v1 + (((v2)))
|
||||
}
|
||||
|
||||
func main() {
|
||||
var re = regexp.MustCompile(`x`)
|
||||
|
||||
wines := []Wine{
|
||||
{"Cabernet Sauvignon", 1991, 200.0, true},
|
||||
{"Merlot", 1939, 500.0, true},
|
||||
{"Zinfandel", 1982, 120.0, false},
|
||||
}
|
||||
|
||||
fmt.Println(len(wines[:2]))
|
||||
stringArr := [4]string{"a", "b", "c", "d"}
|
||||
|
||||
addons := map[string]struct {
|
||||
Item string
|
||||
Price float32
|
||||
}{
|
||||
"Zinfandel": {Item: "chocolate", Price: 10.0},
|
||||
"Cabernet Sauvignon": {Item: "cake", Price: 12.0},
|
||||
}
|
||||
|
||||
var (
|
||||
nonexpensive []Wine
|
||||
)
|
||||
|
||||
LABEL:
|
||||
for {
|
||||
for {
|
||||
for {
|
||||
for {
|
||||
for {
|
||||
sort.Sort(ByProduced(wines))
|
||||
for _, wine := range wines {
|
||||
switch wprice := wine.Price; {
|
||||
case wprice > TOOEXPENSIVE:
|
||||
// Too expensive
|
||||
default:
|
||||
nonexpensive = append(nonexpensive, wine)
|
||||
}
|
||||
}
|
||||
|
||||
break LABEL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, wine := range nonexpensive {
|
||||
if wine.InStock {
|
||||
if wine.InStock {
|
||||
if wine.InStock {
|
||||
if wine.InStock {
|
||||
if isFloat32(wine.Price) {
|
||||
fmt.Println("I can sell you", wine)
|
||||
if val, ok := addons[wine.Name]; ok {
|
||||
fmt.Println("And I have a bundle with ", val.Item, " if you would like ? you can get it for ", SumUp[float32](wine.Price, val.Price))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
|
||||
module ExampleModule
|
||||
( ExampleRecord (..)
|
||||
, someRecord
|
||||
, mkRec
|
||||
, mkRec2
|
||||
, mkRec3
|
||||
, mkRec4
|
||||
) where
|
||||
|
||||
import Data.Maybe hiding (fromJust)
|
||||
import Data.Functor ((<$>))
|
||||
|
||||
data ExampleRecord
|
||||
= ExampleRecord
|
||||
{ name :: String
|
||||
, mmUnit :: Maybe (Maybe ())
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
getName :: ExampleRecord -> String
|
||||
getName ExampleRecord {..} = name
|
||||
|
||||
someRecord :: ExampleRecord
|
||||
someRecord = anotherRecord { name = "xyz" }
|
||||
where anotherRecord = mkRec "" Nothing
|
||||
|
||||
mkRec :: String -> Maybe (Maybe a) -> ExampleRecord
|
||||
mkRec name (Just (Just _)) = ExampleRecord {..}
|
||||
where mmUnit = Just $ Just ()
|
||||
mkRec name (Just _) = ExampleRecord {..}
|
||||
where mmUnit = Just Nothing
|
||||
mkRec name _ = ExampleRecord {..}
|
||||
where mmUnit = Nothing
|
||||
|
||||
mkRec2 :: String -> String -> ExampleRecord
|
||||
mkRec2 first last = mkRec (first <> " " <> last) Nothing
|
||||
|
||||
mkRec3 :: [Char] -> ExampleRecord
|
||||
mkRec3 (a:b:c:_) = mkRec [a, b, c] Nothing
|
||||
mkRec3 _ = mkRec "" Nothing
|
||||
|
||||
mkRec4 :: (String, String) -> ExampleRecord
|
||||
mkRec4 (a, b) = mkRec (a <> b) Nothing
|
||||
@ -1,72 +0,0 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
provider1 = {
|
||||
source = "provider1"
|
||||
version = "0.1.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "terraform_remote_state" "test_remotestate" {
|
||||
backend = "test"
|
||||
|
||||
config = {
|
||||
storage_account_name = "abc"
|
||||
container_name = "terraform-state"
|
||||
key = "prod.terraform.tfstate"
|
||||
}
|
||||
}
|
||||
|
||||
resource "provider_role_grants" "admins_role_grants" {
|
||||
provider = provider.security_admin
|
||||
role_name = provider_role.admins_role.name
|
||||
users = [provider_user.user1.name]
|
||||
roles = [provider_role.role2.name]
|
||||
}
|
||||
|
||||
resource "provider_grant" "usage_grants" {
|
||||
for_each = toset(["USAGE", "TEST"])
|
||||
privilege = each.key
|
||||
roles = [provider_role.role2.name]
|
||||
}
|
||||
|
||||
resource "example" "binary_expressions" {
|
||||
cond1 = (0*1) ? 1 : "foobar"
|
||||
bin1 = ((!(1)+2)%3)*4
|
||||
}
|
||||
|
||||
resource "example" "for_expressions" {
|
||||
for1 = { for i, v in ["a", "a", "b"] : v => i... }
|
||||
for2 = [ for k, v in x : "${k}-${v}" ]
|
||||
}
|
||||
|
||||
variable "timestamp" {
|
||||
type = string
|
||||
|
||||
validation {
|
||||
# formatdate fails if the second argument is not a valid timestamp
|
||||
condition = can(formatdate("", var.timestamp))
|
||||
error_message = "Hello, %{ if var.name != "" }${var.name}%{ else }unnamed%{ endif }!"
|
||||
}
|
||||
}
|
||||
|
||||
block {
|
||||
sample = <<-EOT
|
||||
%{ for ip in aws_instance.example[*].private_ip }
|
||||
server ${ip}
|
||||
%{ endfor }
|
||||
EOT
|
||||
}
|
||||
|
||||
resource "terraform_data" "cluster" {
|
||||
# Replacement of any instance of the cluster requires re-provisioning
|
||||
triggers_replace = aws_instance.cluster.[*].id
|
||||
|
||||
# Bootstrap script can run on any instance of the cluster
|
||||
# So we just choose the first in this case
|
||||
connection {
|
||||
host = aws_instance.cluster.[0].public_ip
|
||||
}
|
||||
}
|
||||
|
||||
# vim:ft=hcl
|
||||
@ -1,264 +0,0 @@
|
||||
---@class ExpectedRainbowHighlight
|
||||
---@field line number 0-based index of the line to be highlighted
|
||||
---@field column number 0-based index of the character to be highlighted
|
||||
---@field rainbow_level string The expected level of the rainbow to use in the highlight
|
||||
|
||||
---@param source_code_lines string[]
|
||||
---@return ExpectedRainbowHighlight[]
|
||||
local function get_expected_highlights(source_code_lines)
|
||||
---@type ExpectedRainbowHighlight[]
|
||||
local expected_highlights = {}
|
||||
|
||||
for line_index, line in ipairs(source_code_lines) do
|
||||
local matches = string.find(line, "hl[%s%d]*")
|
||||
if matches ~= nil then
|
||||
for char_index = 1, #line do
|
||||
local char = line:sub(char_index, char_index)
|
||||
if string.match(char, "%d") then
|
||||
table.insert(expected_highlights, {
|
||||
-- NOTE: subtract 1 to get the index to be 0-based,
|
||||
-- and another 1 because the hl-line describes the
|
||||
-- expected highlights for the line above the hl-line
|
||||
line = line_index - 2,
|
||||
column = char_index - 1,
|
||||
rainbow_level = char,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return expected_highlights
|
||||
end
|
||||
|
||||
---Returns the name of the rainbow highlight group for a given level
|
||||
---@param level string
|
||||
---@return string
|
||||
local function get_rainbow_highlight_group_name(level)
|
||||
return "rainbowcol" .. level
|
||||
end
|
||||
|
||||
---Prepares a line with the invalid column marked by ^.
|
||||
---Used in error reporting.
|
||||
---@param invalid_column number 0-based
|
||||
---@return string
|
||||
local function get_error_marker_line(invalid_column)
|
||||
return string.rep(" ", invalid_column) .. "^"
|
||||
end
|
||||
|
||||
---Prints the line with an error marker line that points to some character.
|
||||
---@param line string The line to print
|
||||
---@param line_number number The line number to be printed
|
||||
---@param error_marker_column number 0-based column number to place the error marker
|
||||
local function print_line_with_error_marker(line, line_number, error_marker_column)
|
||||
local line_number_width = 3
|
||||
|
||||
print(string.format("%" .. line_number_width .. "d: %s", line_number, line))
|
||||
print(
|
||||
string.format(
|
||||
"%" .. line_number_width .. "s %s\n",
|
||||
"",
|
||||
get_error_marker_line(error_marker_column)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
---@class HighlightedSymbol
|
||||
---@field line number 0-based
|
||||
---@field column number 0-based
|
||||
---@field hl_group string
|
||||
|
||||
---@param extmarks table[] Extmark returned from nvim_buf_get_extmarks
|
||||
---@return HighlightedSymbol[]
|
||||
local function get_highlighted_symbols_from_extmarks(extmarks)
|
||||
---@type HighlightedSymbol[]
|
||||
local highlighted_symbols = {}
|
||||
|
||||
for _, extmark in ipairs(extmarks) do
|
||||
-- TODO: support multi-line extmarks
|
||||
local line = extmark[2]
|
||||
local start_col = extmark[3]
|
||||
local details = extmark[4]
|
||||
---Extmark is end_col-exclusive
|
||||
local end_col = details.end_col
|
||||
|
||||
for col = start_col, end_col - 1 do
|
||||
table.insert(highlighted_symbols, {
|
||||
line = line,
|
||||
column = col,
|
||||
hl_group = details.hl_group,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return highlighted_symbols
|
||||
end
|
||||
|
||||
---Prunes duplicate highlighted symbols ensuring that each symbol is highlighted
|
||||
---with a single highlight group.
|
||||
---nvim-ts-rainbow sometimes sets duplicated extmarks to highlight symbols.
|
||||
---Not pruning duplicates would mean errors would be reported multiple times
|
||||
--(once for each duplicate extmark).
|
||||
---@param highlighted_symbols HighlightedSymbol[] The table of highlighted symbols. it will be modified in place.
|
||||
---@param source_code_lines string[] Source code lines used for error reporting
|
||||
local function remove_duplicate_highlighted_symbols(highlighted_symbols, source_code_lines)
|
||||
local multiple_highlights_for_symbols = false
|
||||
|
||||
-- NOTE: manual index tracking because one loop iteration can remove
|
||||
-- multiple elements. Using iterators could iterate over removed indices
|
||||
local index = 1
|
||||
while index <= #highlighted_symbols do
|
||||
local symbol = highlighted_symbols[index]
|
||||
|
||||
-- The body of the loop tries to prune duplicates in the range of
|
||||
-- index+1..#highlighted_symbols
|
||||
|
||||
-- NOTE: loop from the end to allow removing elements in the loop while
|
||||
-- preserving indices that will be looped over in the future
|
||||
for other_symbol_index = #highlighted_symbols, index + 1, -1 do
|
||||
local other_symbol = highlighted_symbols[other_symbol_index]
|
||||
if symbol.line == other_symbol.line and symbol.column == other_symbol.column then
|
||||
if symbol.hl_group == other_symbol.hl_group then
|
||||
table.remove(highlighted_symbols, other_symbol_index)
|
||||
else
|
||||
print("Symbol has multiple different highlight groups assigned to it.")
|
||||
print(
|
||||
string.format(
|
||||
"Found highlight groups: %s %s",
|
||||
symbol.hl_group,
|
||||
other_symbol.hl_group
|
||||
)
|
||||
)
|
||||
|
||||
print_line_with_error_marker(
|
||||
source_code_lines[symbol.line + 1],
|
||||
symbol.line + 1,
|
||||
symbol.column
|
||||
)
|
||||
multiple_highlights_for_symbols = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
assert(not multiple_highlights_for_symbols, "There are multiple highlights for some symbols")
|
||||
end
|
||||
|
||||
local function verify_highlights_in_file(filename)
|
||||
local extended_mode = string.find(filename, "extended") ~= nil
|
||||
local rainbow_module = require("nvim-treesitter.configs").get_module("rainbow")
|
||||
rainbow_module.extended_mode = extended_mode
|
||||
|
||||
vim.cmd.edit(filename)
|
||||
|
||||
local source_code_lines = vim.api.nvim_buf_get_lines(0, 0, -1, 1)
|
||||
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, true, source_code_lines)
|
||||
|
||||
local rainbow_ns_id = vim.api.nvim_get_namespaces().rainbow_ns
|
||||
assert.not_equal(nil, rainbow_ns_id, "rainbow namespace not found")
|
||||
|
||||
local parser = require("nvim-treesitter.parsers").get_parser(0)
|
||||
assert.truthy(parser, "Parser not found")
|
||||
parser:parse()
|
||||
|
||||
-- NOTE: nvim_buf_get_extmarks does not return extmarks that contain
|
||||
-- some range. It only returns extmarks within the given range.
|
||||
-- We cannot use it to look for extmarks for a given symbol, because sometimes
|
||||
-- the extmarks are for a range (e.g. when highlighting a JSX tag, the
|
||||
-- whole range "div" is a single extmark and asking for an extmark for
|
||||
-- the position of "i" returns nothing).
|
||||
-- Thus, we must filter through all extmarks set on the buffer and
|
||||
-- check each symbol.
|
||||
local extmarks = vim.api.nvim_buf_get_extmarks(0, rainbow_ns_id, 0, -1, { details = true })
|
||||
local highlighted_symbols = get_highlighted_symbols_from_extmarks(extmarks)
|
||||
|
||||
remove_duplicate_highlighted_symbols(highlighted_symbols, source_code_lines)
|
||||
|
||||
local some_symbol_not_highlighted = false
|
||||
local invalid_highlight = false
|
||||
for _, expected_highlight in ipairs(get_expected_highlights(source_code_lines)) do
|
||||
local symbol_highlighted = false
|
||||
|
||||
-- NOTE: loop from the end to allow removing elements inside of the loop
|
||||
-- without changing the indices that will be looped over
|
||||
for i = #highlighted_symbols, 1, -1 do
|
||||
local highlighted_symbol = highlighted_symbols[i]
|
||||
if
|
||||
highlighted_symbol.line == expected_highlight.line
|
||||
and highlighted_symbol.column == expected_highlight.column
|
||||
then
|
||||
symbol_highlighted = true
|
||||
|
||||
local expected_highlight_group =
|
||||
get_rainbow_highlight_group_name(expected_highlight.rainbow_level)
|
||||
if expected_highlight_group ~= highlighted_symbol.hl_group then
|
||||
invalid_highlight = true
|
||||
print(
|
||||
string.format(
|
||||
'Invalid rainbow highlight group. Expected "%s", found "%s"',
|
||||
expected_highlight_group,
|
||||
highlighted_symbol.hl_group
|
||||
)
|
||||
)
|
||||
print_line_with_error_marker(
|
||||
source_code_lines[expected_highlight.line + 1],
|
||||
expected_highlight.line + 1,
|
||||
expected_highlight.column
|
||||
)
|
||||
end
|
||||
|
||||
-- NOTE: remove the matched highlighted symbol to later
|
||||
-- check that all highlighted symbols matched some expected
|
||||
-- highlight
|
||||
table.remove(highlighted_symbols, i)
|
||||
end
|
||||
end
|
||||
|
||||
if not symbol_highlighted then
|
||||
print(
|
||||
string.format(
|
||||
'No highlight groups detected. Expected "%s".',
|
||||
get_rainbow_highlight_group_name(expected_highlight.rainbow_level)
|
||||
)
|
||||
)
|
||||
print_line_with_error_marker(
|
||||
source_code_lines[expected_highlight.line + 1],
|
||||
expected_highlight.line + 1,
|
||||
expected_highlight.column
|
||||
)
|
||||
some_symbol_not_highlighted = true
|
||||
end
|
||||
end
|
||||
|
||||
for _, symbol in ipairs(highlighted_symbols) do
|
||||
print(
|
||||
string.format(
|
||||
'Symbol was extraneously highlighted with highlight group "%s"',
|
||||
symbol.hl_group
|
||||
)
|
||||
)
|
||||
print_line_with_error_marker(
|
||||
source_code_lines[symbol.line + 1],
|
||||
symbol.line + 1,
|
||||
symbol.column
|
||||
)
|
||||
end
|
||||
assert(not invalid_highlight, "Some symbol was incorrectly highlighted")
|
||||
assert(not some_symbol_not_highlighted, "Some symbol was not highlighted")
|
||||
assert(#highlighted_symbols == 0, "Extraneous highlights")
|
||||
end
|
||||
|
||||
describe("Highlighting integration tests", function()
|
||||
local files = vim.fn.glob("test/highlight/**/*.*", nil, true)
|
||||
|
||||
for _, filename in ipairs(files) do
|
||||
if not string.match(filename, "highlight_spec.lua") then
|
||||
it(filename, function()
|
||||
verify_highlights_in_file(filename)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@ -1,31 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- This is a comment -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" href="style.css" type="text/css" media="all">
|
||||
<title>Test page</title>
|
||||
<style type="text/css" media="all">
|
||||
body {
|
||||
font-family: "sans-serif";
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
console.log('Hello, world!');
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example link</a>.
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example<br/>link</a> with<br> line <br/>break.
|
||||
</p>
|
||||
<hr>
|
||||
<div>
|
||||
<p>Good<span>bye</span>.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,251 +0,0 @@
|
||||
@(:ant :bee
|
||||
:cat :dog
|
||||
:elephant :fox
|
||||
:giraffe :heron
|
||||
:iguana :janet)
|
||||
|
||||
@["Archimedes" "Bohm"
|
||||
"Cantor" "Deming"
|
||||
"Erdos" "Feynman"
|
||||
"Gauss" "Houdini"
|
||||
"Ishikawa" "Janet"]
|
||||
|
||||
{"Ada"
|
||||
{:file-extensions [".adb" ".ads"]
|
||||
:people ["Jean Ichbiah"]
|
||||
:year 1983}
|
||||
|
||||
"Bash"
|
||||
{:file-extensions [".sh"]
|
||||
:people ["Brian Fox"
|
||||
"Chet Ramey"]
|
||||
:year 1989}
|
||||
|
||||
"C"
|
||||
{:file-extensions [".c" ".h"]
|
||||
:people ["Dennis Ritchie"]
|
||||
:year 1972}
|
||||
|
||||
"Dart"
|
||||
{:file-extensions [".dart"]
|
||||
:people ["Lars Bak"
|
||||
"Kasper Lund"]
|
||||
:year 2011}
|
||||
|
||||
"Emacs Lisp"
|
||||
{:file-extensions [".el" ".elc" ".eln"]
|
||||
:people ["Richard Stallman"
|
||||
"Guy L. Steele, Jr."]
|
||||
:year 1985}
|
||||
|
||||
"Forth"
|
||||
{:file-extensions [".fs" ".fth" ".4th" ".f" ".forth"]
|
||||
:people ["Charles H. Moore"]
|
||||
:year 1970}
|
||||
|
||||
"Go"
|
||||
{:file-extensions [".go"]
|
||||
:people ["Robert Griesemer"
|
||||
"Rob Pike"
|
||||
"Ken Thompson"]
|
||||
:year 2009}
|
||||
|
||||
"Haskell"
|
||||
{:file-extensions [".hs" ".lhs"]
|
||||
:people ["Lennart Augustsson"
|
||||
"Dave Barton"
|
||||
"Brian Boutel"
|
||||
"Warren Burton"
|
||||
"Joseph Fasel"
|
||||
"Kevin Hammond"
|
||||
"Ralf Hinze"
|
||||
"Paul Hudak"
|
||||
"John Hughes"
|
||||
"Thomas Johnsson"
|
||||
"Mark Jones"
|
||||
"Simon Peyton Jones"
|
||||
"John Launchbury"
|
||||
"Erik Meijer"
|
||||
"John Peterson"
|
||||
"Alastair Reid"
|
||||
"Colin Runciman"
|
||||
"Philip Wadler"]
|
||||
:year 1990}
|
||||
|
||||
"Idris"
|
||||
{:file-extensions [".idr" ".lidr"]
|
||||
:people ["Edwin Brady"]
|
||||
:year 2007}
|
||||
|
||||
"Janet"
|
||||
{:file-extensions [".cgen" ".janet" ".jdn"]
|
||||
:people ["Calvin Rose"]
|
||||
:year 2017}}
|
||||
|
||||
~@{:main
|
||||
(some :input)
|
||||
#
|
||||
:input
|
||||
(choice :non-form
|
||||
:form)
|
||||
#
|
||||
:non-form
|
||||
(choice :whitespace
|
||||
:comment)
|
||||
#
|
||||
:whitespace
|
||||
(choice (some (set " \0\f\t\v"))
|
||||
(choice "\r\n"
|
||||
"\r"
|
||||
"\n"))
|
||||
#
|
||||
:comment
|
||||
(sequence "#"
|
||||
(any (if-not (set "\r\n") 1)))
|
||||
#
|
||||
:form
|
||||
(choice :reader-macro
|
||||
:collection
|
||||
:literal)
|
||||
#
|
||||
:reader-macro
|
||||
(choice :fn
|
||||
:quasiquote
|
||||
:quote
|
||||
:splice
|
||||
:unquote)
|
||||
#
|
||||
:fn
|
||||
(sequence "|"
|
||||
(any :non-form)
|
||||
:form)
|
||||
#
|
||||
:quasiquote
|
||||
(sequence "~"
|
||||
(any :non-form)
|
||||
:form)
|
||||
#
|
||||
:quote
|
||||
(sequence "'"
|
||||
(any :non-form)
|
||||
:form)
|
||||
#
|
||||
:splice
|
||||
(sequence ";"
|
||||
(any :non-form)
|
||||
:form)
|
||||
#
|
||||
:unquote
|
||||
(sequence ","
|
||||
(any :non-form)
|
||||
:form)
|
||||
#
|
||||
:literal
|
||||
(choice :number
|
||||
:constant
|
||||
:buffer
|
||||
:string
|
||||
:long-buffer
|
||||
:long-string
|
||||
:keyword
|
||||
:symbol)
|
||||
#
|
||||
:collection
|
||||
(choice :array
|
||||
:bracket-array
|
||||
:tuple
|
||||
:bracket-tuple
|
||||
:table
|
||||
:struct)
|
||||
#
|
||||
:number
|
||||
(drop (cmt
|
||||
(capture (some :name-char))
|
||||
,scan-number))
|
||||
#
|
||||
:name-char
|
||||
(choice (range "09" "AZ" "az" "\x80\xFF")
|
||||
(set "!$%&*+-./:<?=>@^_"))
|
||||
#
|
||||
:constant
|
||||
(sequence (choice "false" "nil" "true")
|
||||
(not :name-char))
|
||||
#
|
||||
:buffer
|
||||
(sequence "@\""
|
||||
(any (choice :escape
|
||||
(if-not "\"" 1)))
|
||||
"\"")
|
||||
#
|
||||
:escape
|
||||
(sequence "\\"
|
||||
(choice (set `"'0?\abefnrtvz`)
|
||||
(sequence "x" [2 :h])
|
||||
(sequence "u" [4 :h])
|
||||
(sequence "U" [6 :h])
|
||||
(error (constant "bad escape"))))
|
||||
#
|
||||
:string
|
||||
(sequence "\""
|
||||
(any (choice :escape
|
||||
(if-not "\"" 1)))
|
||||
"\"")
|
||||
#
|
||||
:long-string :long-bytes
|
||||
#
|
||||
:long-bytes
|
||||
{:main (drop (sequence :open
|
||||
(any (if-not :close 1))
|
||||
:close))
|
||||
:open (capture :delim :n)
|
||||
:delim (some "`")
|
||||
:close (cmt (sequence (not (look -1 "`"))
|
||||
(backref :n)
|
||||
(capture (backmatch :n)))
|
||||
,=)}
|
||||
#
|
||||
:long-buffer
|
||||
(sequence "@"
|
||||
:long-bytes)
|
||||
#
|
||||
:keyword
|
||||
(sequence ":"
|
||||
(any :name-char))
|
||||
#
|
||||
:symbol (some :name-char)
|
||||
#
|
||||
:array
|
||||
(sequence "@("
|
||||
(any :input)
|
||||
(choice ")"
|
||||
(error (constant "missing )"))))
|
||||
#
|
||||
:tuple
|
||||
(sequence "("
|
||||
(any :input)
|
||||
(choice ")"
|
||||
(error (constant "missing )"))))
|
||||
#
|
||||
:bracket-array
|
||||
(sequence "@["
|
||||
(any :input)
|
||||
(choice "]"
|
||||
(error (constant "missing ]"))))
|
||||
#
|
||||
:bracket-tuple
|
||||
(sequence "["
|
||||
(any :input)
|
||||
(choice "]"
|
||||
(error (constant "missing ]"))))
|
||||
:table
|
||||
(sequence "@{"
|
||||
(any :input)
|
||||
(choice "}"
|
||||
(error (constant "missing }"))))
|
||||
#
|
||||
:struct
|
||||
(sequence "{"
|
||||
(any :input)
|
||||
(choice "}"
|
||||
(error (constant "missing }"))))
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
@Author(name = "John Doe")
|
||||
public class HelloWorld {
|
||||
// Constructor body
|
||||
public HelloWorld() {
|
||||
}
|
||||
|
||||
// Method with formal parameters
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world!");
|
||||
System.out.println(args[0]);
|
||||
}
|
||||
|
||||
public static void printList(List<List<List<T>>> l) {
|
||||
// Array initializer
|
||||
String[] names = {"Alice", "Bob", "Carol", "Dan"};
|
||||
// Multi-dimensional dimensions and a dimensions expression
|
||||
Integer[][] inputArrays = new Integer[3][];
|
||||
|
||||
// Enhanced for statement (for-each)
|
||||
for (var name: names) {
|
||||
var msg = String.format("Hello, %s.", name);
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
// Regular for-statement
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
System.out.print(i);
|
||||
}
|
||||
|
||||
// Parentheses around condition
|
||||
if (false) {
|
||||
System.err.println("This will never print");
|
||||
}
|
||||
|
||||
// Parentheses around catch clause
|
||||
try {
|
||||
// A parenthesized expression
|
||||
System.out.print(((3/0)));
|
||||
} catch(ArithmeticException e) {
|
||||
System.err.print(e);
|
||||
}
|
||||
|
||||
|
||||
// Nested bodies
|
||||
for (var item1: l) {
|
||||
for (var item2: item1) {
|
||||
for (var item3: item2) {
|
||||
System.out.format("%d", item3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try resource specification
|
||||
try (FileWriter fw = new FileWriter("test");
|
||||
BufferedWriter bw = new BufferedWriter(fw)) {
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
double d = 13.37;
|
||||
int i = (int) d; // cast expression
|
||||
}
|
||||
}
|
||||
|
||||
// vim:noexpandtab
|
||||
@ -1,9 +0,0 @@
|
||||
class LambdaTest {
|
||||
void singleton() {
|
||||
version -> create;
|
||||
// Inferred parameters
|
||||
(record, b) -> record + b;
|
||||
}
|
||||
}
|
||||
|
||||
// vim:noexpandtab
|
||||
@ -1,67 +0,0 @@
|
||||
// Named imports
|
||||
import { useState } from 'react'
|
||||
|
||||
// Template strings
|
||||
const who = 'world';
|
||||
console.log(`Hello, ${who}`);
|
||||
|
||||
// Function with nested function
|
||||
function add(x, y) {
|
||||
function iter(i, acc) {
|
||||
if (i == 0) {
|
||||
return acc;
|
||||
}
|
||||
return iter(i - 1, acc + 1);
|
||||
}
|
||||
return iter(y, x)
|
||||
}
|
||||
|
||||
// Loops
|
||||
function iterate() {
|
||||
for (let i = 0; i <= 2; i++) {
|
||||
break;
|
||||
}
|
||||
|
||||
let list = []
|
||||
for (let element of list) {
|
||||
console.log(element);
|
||||
}
|
||||
}
|
||||
|
||||
// Arrow function definition
|
||||
const multiply = (x, y) => x * y;
|
||||
|
||||
// Nested object and array
|
||||
let some_object = {
|
||||
a: {
|
||||
b: {
|
||||
c: {},
|
||||
},
|
||||
d: [[1, 2, 3]]
|
||||
}
|
||||
};
|
||||
|
||||
// object pattern
|
||||
const destructuredFunction = ({ value }) => {
|
||||
return {}
|
||||
}
|
||||
|
||||
// Subscript expressions
|
||||
const zeroes = [0];
|
||||
console.log(zeroes[zeroes[zeroes[0]]])
|
||||
|
||||
// Destructuring assignment
|
||||
const [x, y] = array;
|
||||
|
||||
// Parenthesized expressions
|
||||
console.log(1 + (2 + (3 + 4)))
|
||||
|
||||
let a = 1
|
||||
|
||||
switch(a) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
|
||||
// export clause
|
||||
export { zeroes }
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"foo": "bar",
|
||||
"bar": {
|
||||
"baz": [
|
||||
[
|
||||
[]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
// comments
|
||||
unquoted: 'and you can quote me on that',
|
||||
singleQuotes: 'I can use "double quotes" here',
|
||||
lineBreaks: "Look, Mom!
|
||||
No \\n's!",
|
||||
hexadecimal: 0xdecaf,
|
||||
object: {a: {b: {c: {}}}},
|
||||
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
||||
positiveSign: +1,
|
||||
trailingComma: 'in objects', andIn: [[['arrays',]]],
|
||||
"backwardsCompatible": "with JSON",
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
// This is a comment
|
||||
{
|
||||
"foo": "bar",
|
||||
/* This is a multi-line comment
|
||||
*/
|
||||
"bar": {
|
||||
"baz": [
|
||||
[
|
||||
[]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
{
|
||||
concat_array: [1, 2, 3] + [4],
|
||||
concat_string: '123' + 4,
|
||||
equality1: 1 == '1',
|
||||
equality2: [{}, { x: 3 - 1 }]
|
||||
== [{}, { x: 2 }],
|
||||
ex1: 1 + 2 * 3 / (4 + 5),
|
||||
// Bitwise operations first cast to int.
|
||||
ex2: self.ex1 | 3,
|
||||
// Modulo operator.
|
||||
ex3: self.ex1 % 2,
|
||||
// Boolean logic
|
||||
ex4: (4 > 3) && (1 <= 3) || false,
|
||||
// Mixing objects together
|
||||
obj: { a: 1, b: 2 } + { b: 3, c: 4 },
|
||||
// Test if a field is in an object
|
||||
obj_member: 'foo' in { foo: 1 },
|
||||
// String formatting
|
||||
str1: 'The value of self.ex2 is '
|
||||
+ self.ex2 + '.',
|
||||
str2: 'The value of self.ex2 is %g.'
|
||||
% self.ex2,
|
||||
str3: 'ex1=%0.2f, ex2=%0.2f'
|
||||
% [self.ex1, self.ex2],
|
||||
// By passing self, we allow ex1 and ex2 to
|
||||
// be extracted internally.
|
||||
str4: 'ex1=%(ex1)0.2f, ex2=%(ex2)0.2f'
|
||||
% self,
|
||||
// Do textual templating of entire files:
|
||||
str5: |||
|
||||
ex1=%(ex1)0.2f
|
||||
ex2=%(ex2)0.2f
|
||||
||| % self,
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
{
|
||||
cocktails: {
|
||||
"Bee's Knees": {
|
||||
// Construct the ingredients by using
|
||||
// 4/3 oz of each element in the given
|
||||
// list.
|
||||
ingredients: [ // Array comprehension.
|
||||
{ kind: kind, qty: 4 / 3 }
|
||||
for kind in [
|
||||
'Honey Syrup',
|
||||
'Lemon Juice',
|
||||
'Farmers Gin',
|
||||
]
|
||||
],
|
||||
garnish: 'Lemon Twist',
|
||||
served: 'Straight Up',
|
||||
},
|
||||
} + { // Object comprehension.
|
||||
[sd.name + 'Screwdriver']: {
|
||||
ingredients: [
|
||||
{ kind: 'Vodka', qty: 1.5 },
|
||||
{ kind: sd.fruit, qty: 3 },
|
||||
],
|
||||
served: 'On The Rocks',
|
||||
}
|
||||
for sd in [
|
||||
{ name: 'Yellow ', fruit: 'Lemonade' },
|
||||
{ name: '', fruit: 'Orange Juice' },
|
||||
]
|
||||
},
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
local Margarita(salted) = {
|
||||
ingredients: [
|
||||
{ kind: 'Tequila Blanco', qty: 2 },
|
||||
{ kind: 'Lime', qty: 1 },
|
||||
{ kind: 'Cointreau', qty: 1 },
|
||||
],
|
||||
[if salted then 'garnish']: 'Salt',
|
||||
};
|
||||
{
|
||||
Margarita: Margarita(true),
|
||||
'Margarita Unsalted': Margarita(false),
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
// Define a local function.
|
||||
// Default arguments are like Python:
|
||||
local my_function(x, y=10) = x + y;
|
||||
|
||||
// Define a local multiline function.
|
||||
local multiline_function(x) =
|
||||
// One can nest locals.
|
||||
local temp = x * 2;
|
||||
// Every local ends with a semi-colon.
|
||||
[temp, temp + 1];
|
||||
|
||||
local object = {
|
||||
// A method
|
||||
my_method(x): x * x,
|
||||
};
|
||||
|
||||
{
|
||||
// Functions are first class citizens.
|
||||
call_inline_function:
|
||||
(function(x) x * x)(5),
|
||||
|
||||
call_multiline_function: multiline_function(4),
|
||||
|
||||
// Using the variable fetches the function,
|
||||
// the parens call the function.
|
||||
call: my_function(2),
|
||||
|
||||
// Like python, parameters can be named at
|
||||
// call time.
|
||||
named_params: my_function(x=2),
|
||||
// This allows changing their order
|
||||
named_params2: my_function(y=3, x=2),
|
||||
|
||||
// object.my_method returns the function,
|
||||
// which is then called like any other.
|
||||
call_method1: object.my_method(3),
|
||||
|
||||
standard_lib:
|
||||
std.join(' ', std.split('foo/bar', '/')),
|
||||
len: [
|
||||
std.length('hello'),
|
||||
std.length([1, 2, 3]),
|
||||
],
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
// Template strings
|
||||
const who = 'world';
|
||||
console.log(`Hello, ${who}`);
|
||||
|
||||
// Nested object
|
||||
let some_object = {
|
||||
a: {
|
||||
b: {
|
||||
c: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Subscript expressions
|
||||
const zeroes = [0];
|
||||
console.log(zeroes[zeroes[zeroes[0]]])
|
||||
|
||||
// Parenthesized expressions
|
||||
console.log(1 + (2 + (3 + 4)))
|
||||
|
||||
function hello() {
|
||||
console.log('Hello, world!');
|
||||
}
|
||||
|
||||
function app() {
|
||||
const [x, y] = array;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example link</a>.
|
||||
</p>
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example<br/>link</a> with<br/> line <br/>break.
|
||||
</p>
|
||||
<ComponentWithChildren>
|
||||
{someFunction().map((x) => <div></div>)}
|
||||
</ComponentWithChildren>
|
||||
<ComponentWith.property>
|
||||
{someFunction().map((x) => <div></div>)}
|
||||
</ComponentWith.property>
|
||||
<ComponentWith.property bool={true} arr={[1, 2, 3]} />
|
||||
<button onClick={hello}>Click me!</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
a = Vector{Int}([1, 2, 3, 4, 5, 6]);
|
||||
A = [
|
||||
28 32
|
||||
11 70
|
||||
];
|
||||
|
||||
f(x) = abs((x-4)*(x+2))
|
||||
b = [f(x) for x ∈ A]
|
||||
x = (1, 2)
|
||||
@ -1,113 +0,0 @@
|
||||
// Define a simple class with a primary constructor
|
||||
class Person<T>(private val name: String, private val age: Int, private val t: T) {
|
||||
// Secondary constructor
|
||||
constructor(name: String) : this(name, 0)
|
||||
|
||||
class Hello {
|
||||
class Goodbye {
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
println("New person created with name $name")
|
||||
}
|
||||
|
||||
// Member function
|
||||
fun greet() {
|
||||
println("Hello, my name is $name and I am $age years old.")
|
||||
}
|
||||
}
|
||||
|
||||
// Extension function
|
||||
fun String.exclaim() = "$this!"
|
||||
|
||||
// Top-level function
|
||||
fun calculateFactorial(n: Int): Int {
|
||||
return if (n == 1) n else n * calculateFactorial(n - 1)
|
||||
}
|
||||
|
||||
// Main function - entry point of the program
|
||||
fun main() {
|
||||
val person = Person<Map<String, String>>("Alice", 30, emptyMap())
|
||||
person.greet()
|
||||
|
||||
// Using the extension function
|
||||
println("Wow".exclaim())
|
||||
|
||||
// Conditional
|
||||
val number = 5
|
||||
if (number % 2 == 0) {
|
||||
println("$number is even")
|
||||
} else {
|
||||
println("$number is odd")
|
||||
}
|
||||
|
||||
// Loop
|
||||
for (i in 1..5) {
|
||||
println("Factorial of $i is: ${calculateFactorial(i)}")
|
||||
}
|
||||
|
||||
// Using a map
|
||||
val map = mapOf("a" to 1, "b" to 2, "c" to 3)
|
||||
for ((key, value) in map) {
|
||||
println("Key: $key, Value: $value")
|
||||
}
|
||||
|
||||
// Lambda expression
|
||||
val numbers = listOf(1, 2, 3, 4, 5)
|
||||
val doubled = numbers.map { it * 2 }
|
||||
println("Doubled numbers: $doubled")
|
||||
}
|
||||
|
||||
val list = listOf(1, 2, 3)
|
||||
list.forEach { item ->
|
||||
println(item)
|
||||
}
|
||||
|
||||
fun operateOnNumbers(a: Int, b: Int, operation: (Int, Int) -> Int): Int {
|
||||
return operation(a, b)
|
||||
}
|
||||
|
||||
val sum = operateOnNumbers(2, 3) { x, y -> x + y }
|
||||
println("Sum: $sum")
|
||||
|
||||
|
||||
val multiply = fun(x: Int, y: Int): Int {
|
||||
return x * y
|
||||
}
|
||||
|
||||
println("Product: ${multiply(2, 3)}")
|
||||
|
||||
val x = 2
|
||||
when (x) {
|
||||
1 -> println("x == 1")
|
||||
2 -> println("x == 2")
|
||||
else -> println("x is neither 1 nor 2")
|
||||
}
|
||||
|
||||
when {
|
||||
1 == 1 -> print("1")
|
||||
else -> print("not")
|
||||
}
|
||||
|
||||
|
||||
val rows = 2
|
||||
val cols = 3
|
||||
val matrix = Array(rows) { IntArray(cols) }
|
||||
|
||||
// Fill the array
|
||||
for (i in matrix.indices) {
|
||||
for (j in matrix[i].indices) {
|
||||
matrix[i][j] = i + j
|
||||
}
|
||||
matrix[matrix[i][i]]
|
||||
}
|
||||
|
||||
// Print the 2D array
|
||||
for (row in matrix) {
|
||||
for (col in row) {
|
||||
print("$col ")
|
||||
}
|
||||
println()
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
\documentclass{article} % Starts an article
|
||||
\usepackage{amsmath} % Imports amsmath
|
||||
|
||||
\title{\LaTeX} % Title
|
||||
|
||||
\begin{document} % Begins a document
|
||||
\maketitle
|
||||
\LaTeX{} is a document preparation system for
|
||||
the \TeX{} typesetting program. It offers
|
||||
programmable desktop publishing features and
|
||||
extensive facilities for automating most
|
||||
aspects of typesetting and desktop publishing,
|
||||
including numbering and cross-referencing,
|
||||
tables and figures, page layout,
|
||||
bibliographies, and much more. \LaTeX{} was
|
||||
originally written in 1984 by Leslie Lamport
|
||||
and has become the dominant method for using
|
||||
\TeX; few people write in plain \TeX{} anymore.
|
||||
The current version is \LaTeXe.
|
||||
|
||||
% This is a comment, not shown in final output.
|
||||
% The following shows typesetting power of LaTeX:
|
||||
\begin{align}
|
||||
E_0 &= mc^2 \\
|
||||
E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}
|
||||
\end{align}
|
||||
|
||||
This is testing {nesting {of {text} with a reference\ref{section:some_sec}}}.
|
||||
\end{document}
|
||||
|
||||
% vim:ft=latex
|
||||
@ -1,66 +0,0 @@
|
||||
-- This is a comment
|
||||
|
||||
local function f1(a, b)
|
||||
local function f2(a2, b2)
|
||||
return a2, b2
|
||||
end
|
||||
return f2(a, b)
|
||||
end
|
||||
|
||||
function GlobalFunction()
|
||||
print 'This is a global function'
|
||||
end
|
||||
|
||||
if true then
|
||||
print 'True condition'
|
||||
elseif false then
|
||||
print 'Alternative condition'
|
||||
elseif false then
|
||||
print 'Alternative condition'
|
||||
else
|
||||
print 'Alternative'
|
||||
end
|
||||
|
||||
while false do
|
||||
print 'A while-loop'
|
||||
end
|
||||
|
||||
repeat
|
||||
print 'This will repeat only once'
|
||||
until true
|
||||
|
||||
do
|
||||
print 'A block'
|
||||
end
|
||||
|
||||
for i, v in ipairs({'a', 'b', 'c'}) do
|
||||
print(string.format("%d = %s", i, v))
|
||||
end
|
||||
|
||||
for i = 1, 5, 1 do
|
||||
print(string.format("Number %d", i))
|
||||
end
|
||||
|
||||
print(f1('a', 'b'))
|
||||
print((((('Hello, world!')))))
|
||||
|
||||
print {
|
||||
{
|
||||
{
|
||||
'Hello, world!'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local one = {1}
|
||||
|
||||
print(one[one[one[1]]])
|
||||
|
||||
-- Embedded Vim script
|
||||
vim.cmd [[
|
||||
echo a(b(c(d(e(f())))))
|
||||
]]
|
||||
|
||||
local tbl = {
|
||||
["highlight me"] = {}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
---@type fun(x: (fun(): integer), y: fun(z: fun()))
|
||||
|
||||
---@type { key1: { key2: { [string]: table<number, number | integer> }, [integer]: integer } }
|
||||
|
||||
---@type table<integer | number, table<string, table<number, boolean>>>
|
||||
|
||||
---@class test
|
||||
---@field a boolean
|
||||
---@field b (((boolean)))
|
||||
---@field x number | string | { key: number | string | boolean } | boolean
|
||||
---@field [string] boolean
|
||||
|
||||
---@type string[]
|
||||
local _str_tbl = { 'a', 'b', 'c' }
|
||||
|
||||
---@param f fun(i: integer): (integer, integer)
|
||||
---@return integer, integer
|
||||
local function _test_fun(f)
|
||||
return f(1)
|
||||
end
|
||||
|
||||
-- Note: The parser nests union types, which can mess
|
||||
-- with rainbow-delimiters highlighting, so we don't
|
||||
-- highlight the '|' here:
|
||||
---@type number | integer[] | string | number[] | string[] | boolean | boolean[]
|
||||
local _x = 1
|
||||
---@type boolean[] | integer[]
|
||||
local _t = { true, false } or { 0, 1 }
|
||||
---@type (boolean | integer)[]
|
||||
local _arr = { true, 0 }
|
||||
@ -1,23 +0,0 @@
|
||||
.PHONY: all
|
||||
|
||||
all: herp derp
|
||||
|
||||
herp: a.txt
|
||||
# Command substitution
|
||||
echo $(basedir $(pwd))
|
||||
|
||||
# Variable expansion
|
||||
echo ${FOO${BAR${BAZ}}}
|
||||
|
||||
# Test expression (using the `test` command)
|
||||
if [ -d "herp/derp/" ]; then
|
||||
echo "Yay"
|
||||
fi
|
||||
|
||||
# Test expression (bashism)
|
||||
if [[ -d "herp/derp/" ]]; then
|
||||
echo "Yay"
|
||||
fi
|
||||
|
||||
# Sub-shells
|
||||
(true; false; (true; true; (false; true)))
|
||||
@ -1,9 +0,0 @@
|
||||
Some markdown.
|
||||
```markdown
|
||||
~~~lua
|
||||
print({{{{}}}})
|
||||
print({{{{}}}})
|
||||
vim.cmd[[echo str([])]]
|
||||
~~~
|
||||
```
|
||||
More markdown
|
||||
@ -1,72 +0,0 @@
|
||||
# A Markdown example
|
||||
|
||||
## Some nonsense text
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
||||
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
||||
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
||||
culpa qui officia deserunt mollit anim id est laborum.
|
||||
|
||||
## Injected languages
|
||||
|
||||
Here we test highlighting of an injected
|
||||
|
||||
|
||||
### Lua
|
||||
|
||||
Lua is a good candidate
|
||||
|
||||
```lua
|
||||
-- This is a comment
|
||||
|
||||
local function f1(a, b)
|
||||
local function f2(a2, b2)
|
||||
return a2, b2
|
||||
end
|
||||
return f2(a, b)
|
||||
end
|
||||
|
||||
print(f1('a', 'b'))
|
||||
print((((('Hello, world!')))))
|
||||
|
||||
print {
|
||||
{
|
||||
{
|
||||
'Hello, wold!'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local one = {1}
|
||||
|
||||
print(one[one[one[1]]])
|
||||
|
||||
-- Embedded Vim script
|
||||
vim.cmd [[
|
||||
echo a(b(c(d(e(f())))))
|
||||
]]
|
||||
-- Embedded Vim script on one line
|
||||
vim.cmd[[echo a(b(c(d())))]]
|
||||
```
|
||||
|
||||
### Vim script
|
||||
|
||||
Let's try another embedded language
|
||||
|
||||
```vim
|
||||
let g:my_list = [[[1]]]
|
||||
let g:my_dict = {
|
||||
\'a': {
|
||||
\'b': {
|
||||
\'c': {},
|
||||
\}
|
||||
\}
|
||||
\ }
|
||||
|
||||
echo string(1 + (2 + (3 + 4)))
|
||||
echo string(-(3))
|
||||
echo string((5)-(3))
|
||||
echo string((1) ? (2) : (3))
|
||||
echo ((('Hello, world!')))
|
||||
````
|
||||
@ -1,26 +0,0 @@
|
||||
# parameter_declaration_list and generic_parameter_list
|
||||
proc p[T: seq[int]](a: seq[seq[int]]): int =
|
||||
result = 1
|
||||
|
||||
let
|
||||
# array
|
||||
a = [[[1], [1]], [[1], [1]]]
|
||||
# tuple and tuple_deconstruct_declaration
|
||||
(((q), (_)), ((p), (_))) = (((1, ), (1, )), ((1, ), (1, )))
|
||||
# set
|
||||
c = {'a'}
|
||||
# table
|
||||
d = {1: {1: {: }, 2: {: }}, 2: {1: {: }, 2: {: }}}
|
||||
# parenthesized
|
||||
e = (((
|
||||
discard;
|
||||
discard;
|
||||
1)))
|
||||
# call and bracket_expression
|
||||
f = p[seq[int]](@[@[p[seq[int]](@[@[1]])]])
|
||||
|
||||
# cast and field_declaration_list
|
||||
cast[tuple[a: seq[int], ]](p[seq[int]](@[@[1]]))
|
||||
|
||||
# term_rewriting_pattern and curly_expression
|
||||
template t{(0|1|2){x}}(x: untyped): untyped = x + 1
|
||||
@ -1,56 +0,0 @@
|
||||
{
|
||||
description = "Test flake for rainbow-delimiters.nvim";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
pre-commit-hooks,
|
||||
...
|
||||
}: let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
];
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system: let
|
||||
inherit (nixpkgs) lib;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
formatting = pre-commit-hooks.lib.${system}.run {
|
||||
src = lib.cleanSource self;
|
||||
hooks = {
|
||||
alejandra.enable = true;
|
||||
markdownlint.enable = true;
|
||||
};
|
||||
settings = {
|
||||
markdownlint.config = {
|
||||
MD004 = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
apps = rec {
|
||||
hi = with pkgs; flake-utils.lib.mkApp {
|
||||
drv = writeShellScriptBin "hi" ''
|
||||
echo "Hello, world"
|
||||
'';
|
||||
};
|
||||
default = hi;
|
||||
};
|
||||
packages = {
|
||||
};
|
||||
checks = {
|
||||
inherit formatting;
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
use v5.20;
|
||||
use feature qw(signatures);
|
||||
no warnings qw(experimental::signatures);
|
||||
|
||||
sub foobar($foo, $bar) {
|
||||
my %h = (
|
||||
foo => +{ foo => 'bar' },
|
||||
($foo ? (
|
||||
bar => hoge(foo => $bar)->id,
|
||||
) : ()),
|
||||
);
|
||||
say $h{foo}{foo};
|
||||
my $h_ref = \%h;
|
||||
say $h_ref->{foo}{foo};
|
||||
}
|
||||
|
||||
sub barfoo {
|
||||
my ($foo, $bar) = @_;
|
||||
say $_[0];
|
||||
foobar([ $foo, $bar ]);
|
||||
my ($ary) = ([ ($foo, $bar) ]);
|
||||
$ary = [ $foo, $bar ];
|
||||
my $result = ($foo ? $bar : $foo);
|
||||
{
|
||||
say @$ary[0];
|
||||
say @{$ary}[0];
|
||||
say $ary->[1];
|
||||
}
|
||||
if ($foo) {
|
||||
# TODO: tree-sitter-perl cannot detect string interpolation yet.
|
||||
# say "${foo} $bar";
|
||||
}
|
||||
my $sub = sub {
|
||||
say $foo;
|
||||
};
|
||||
map { +{} } @ary;
|
||||
qw(a b c d e);
|
||||
qr(a b c d e);
|
||||
qx(a b c d e);
|
||||
qq(a b c d e);
|
||||
q(a b c d e);
|
||||
m(a b c d e);
|
||||
s(a b c)(d e);
|
||||
tr(a b c)(d e);
|
||||
y(a b c)(d e);
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
// parenthesized expression
|
||||
$var = ((3 + (18 - 5)) * 8);
|
||||
|
||||
// arguments
|
||||
var_dump(max($var, 12));
|
||||
|
||||
// declaration list
|
||||
class AddOp {
|
||||
|
||||
// encapsed string
|
||||
private $innerValue = "var = {$var} - var value";
|
||||
|
||||
// formal parameters
|
||||
public function concatStr($x, $y) {
|
||||
// array creation expression
|
||||
$arr = [1, 2, [3, [4, 5, 6]]];
|
||||
$idx = [0, 1, 2];
|
||||
|
||||
// subscript expression
|
||||
echo $arr[$idx[1]];
|
||||
|
||||
// compound statement
|
||||
if ($x == $y) {
|
||||
if ($x != $y) {
|
||||
return $x . $y;
|
||||
}
|
||||
}
|
||||
return $this->innerValue;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
# NOTE: When updating this file update the Starlark test file as well if
|
||||
# applicable.
|
||||
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
)
|
||||
|
||||
|
||||
def sum_list(lst: List[Dict[int, int]]) -> int:
|
||||
result = 0
|
||||
for inner in lst:
|
||||
for i in inner:
|
||||
result += i
|
||||
return result
|
||||
|
||||
|
||||
my_list = [[['Hello, world!']]]
|
||||
my_dict = {'x': {'x': {'x': 'Hello, wold!'}}}
|
||||
my_set = {{{{'Hello, wold!'}}}}
|
||||
my_tuple = (((('Hello, wold!'),),),)
|
||||
|
||||
list_comp = [i for i in [j for j in range(5)] if i % 2 == 0]
|
||||
dict_comp = {k: v for k, v in {k: v for k, v in {'k': 'v'}.items()}
|
||||
if k == 'k'}
|
||||
set_comp = {i for i in {j for j in range(5)} if i % 2 == 0}
|
||||
gen_comp = (i for i in (j for j in range(5)) if i % 2 == 0)
|
||||
|
||||
match my_dict:
|
||||
case {'x': {'x': {'x': message}}}:
|
||||
print(message)
|
||||
case [[[message]]]:
|
||||
print(message)
|
||||
case (((message))):
|
||||
print(message)
|
||||
|
||||
zero = [0]
|
||||
|
||||
(a,b) = (1,2)
|
||||
[c,d] = [3,4]
|
||||
|
||||
print(zero[zero[zero[0]]])
|
||||
|
||||
|
||||
print(2 + ((((3)))))
|
||||
print(len(my_list))
|
||||
|
||||
# Format-string with embedded delimiters
|
||||
print(f'The sum of 2 and 3 is {2 + (1 + 2)}')
|
||||
@ -1,7 +0,0 @@
|
||||
(foo (bar (baz)) @bar) @foo
|
||||
|
||||
[foo [bar [baz]] @bar] @foo
|
||||
|
||||
(foo [bar (baz)] @bar) @foo
|
||||
|
||||
;;; vim:ft=query
|
||||
@ -1,35 +0,0 @@
|
||||
# call
|
||||
suppressWarnings(library(datasets))
|
||||
|
||||
# outer subset, inner subset2
|
||||
mtcars[mtcars[[1, 2]], ]
|
||||
|
||||
# if ladder, inner brace_list
|
||||
var <- 10
|
||||
if (var > 5) {
|
||||
print(paste(var, "is greater than 5"))
|
||||
if (var < 10) {
|
||||
print(paste(var, "is less than 10"))
|
||||
}
|
||||
}
|
||||
|
||||
foobar <- function(num) {
|
||||
for (i in 1:5) {
|
||||
print(i)
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
break
|
||||
}
|
||||
|
||||
x <- "a"
|
||||
v <- switch(x, "a"="apple", "b"="banana", "c"="cherry")
|
||||
|
||||
if (num > 0) {
|
||||
return("Positive")
|
||||
} else if (num < 0) {
|
||||
return("Negative")
|
||||
} else {
|
||||
return("Zero")
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
#lang racket
|
||||
|
||||
(define [add x y]
|
||||
"A silly way to add two numbers recursively."
|
||||
(if (zero? y)
|
||||
x
|
||||
(add (add1 x)
|
||||
(sub1 x))))
|
||||
|
||||
(define-syntax foo
|
||||
(syntax-rules ()
|
||||
((_ a ...)
|
||||
(printf "~a\n" (list a ...)))))
|
||||
|
||||
{+ 2 {+ 3 {+ 4 5}}}
|
||||
|
||||
'(((a . b)))
|
||||
'((((a b . c))))
|
||||
|
||||
'[[[a . b]]]
|
||||
'[[[a b . c]]]
|
||||
|
||||
'{{{a . b}}}
|
||||
'
|
||||
'([{a . b}])
|
||||
'([{a b . c}])
|
||||
|
||||
;;; Vector literals
|
||||
#(#(#(a)))
|
||||
#[#[#[a]]]
|
||||
#{#{#{a}}}
|
||||
|
||||
|
||||
;;; Inexact number vector literals
|
||||
#fl(#fl(#fl(a)))
|
||||
#fl[#fl[#fl[a]]]
|
||||
#fl{#fl{#fl{a}}}
|
||||
|
||||
#Fl(#Fl(#Fl(a)))
|
||||
#Fl[#Fl[#Fl[a]]]
|
||||
#Fl{#Fl{#Fl{a}}}
|
||||
|
||||
|
||||
;;; Fixnum vector literals
|
||||
#fx(#fx(#fx(a)))
|
||||
#fx[#fx[#fx[a]]]
|
||||
#fx{#fx{#fx{a}}}
|
||||
|
||||
#Fx(#Fx(#Fx(a)))
|
||||
#Fx[#Fx[#Fx[a]]]
|
||||
#Fx{#Fx{#Fx{a}}}
|
||||
|
||||
|
||||
;;; Structures
|
||||
(struct prefab-point (x y) #:prefab)
|
||||
'#s(prefab-point 1 2)
|
||||
@ -1,20 +0,0 @@
|
||||
// Ref: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown
|
||||
|
||||
* {
|
||||
background-image: url("a.jpg", width);
|
||||
background-color: env(ROFI_BACKGROUND_COLOR, transparent);
|
||||
text-color: rgba(256, 256, 256, 0.9);
|
||||
text-color-2: var(text-color, hsl(20, 1, 1));
|
||||
text-color-3: hwb(20, 1, 10);
|
||||
text-color-4: cmyk(20, 15, 10, 5);
|
||||
width: 1024px
|
||||
}
|
||||
|
||||
@media (monitor-id: ${ROFI_MAIN_MONITOR}) {
|
||||
width: calc(120% * 1024px);
|
||||
}
|
||||
|
||||
mainbox {
|
||||
background-image: linear-gradient(to bottom, darkgreen/50%, black/70%);
|
||||
children: [inputbar, listview];
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
a(b(c(d)))
|
||||
a(b(c(d)?))
|
||||
a(b(c[def]))
|
||||
a(b(c[^def]))
|
||||
a(b(c{1}))
|
||||
a(b(c{1,4}))
|
||||
a(b(c(?=d)))
|
||||
|
||||
vim:ft=regex
|
||||
@ -1,74 +0,0 @@
|
||||
.. default-role:: code
|
||||
|
||||
############################
|
||||
A reStructuredText example
|
||||
############################
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
||||
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
||||
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
||||
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
||||
culpa qui officia deserunt mollit anim id est laborum.
|
||||
|
||||
|
||||
Injected languages
|
||||
##################
|
||||
|
||||
Here we test highlighting of an injected
|
||||
|
||||
|
||||
Lua
|
||||
===
|
||||
|
||||
Lua is a good candidate
|
||||
|
||||
.. code:: lua
|
||||
|
||||
-- This is a comment
|
||||
|
||||
local function f1(a, b)
|
||||
local function f2(a2, b2)
|
||||
return a2, b2
|
||||
end
|
||||
return f2(a, b)
|
||||
end
|
||||
|
||||
print(f1('a', 'b'))
|
||||
print((((('Hello, world!')))))
|
||||
|
||||
print {
|
||||
{
|
||||
{
|
||||
'Hello, world!'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local one = {1}
|
||||
|
||||
print(one[one[one[1]]])
|
||||
|
||||
-- Embedded Vim script
|
||||
vim.cmd [[
|
||||
echo a(b(c(d(e(f())))))
|
||||
]]
|
||||
|
||||
Let's try another embedded language
|
||||
|
||||
.. code:: vim
|
||||
|
||||
let g:my_list = [[[1]]]
|
||||
let g:my_dict = {
|
||||
\'a': {
|
||||
\'b': {
|
||||
\'c': {},
|
||||
\}
|
||||
\}
|
||||
\ }
|
||||
|
||||
echo string(1 + (2 + (3 + 4)))
|
||||
echo string(-(3))
|
||||
echo string((5)-(3))
|
||||
echo string((1) ? (2) : (3))
|
||||
echo ((('Hello, world!')))
|
||||
@ -1,14 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
an_array = [[['Hello', 'world!']]] # rubocop:disable Lint/UselessAssignment
|
||||
a_hash = { 'x' => { 'x' => { 'x' => 'Hello, world!' } } } # rubocop:disable Lint/UselessAssignment
|
||||
|
||||
def greeting(name, age)
|
||||
age_in_seconds = (((((age * 365))) * 24) * 60) * 60
|
||||
|
||||
puts "Hello, #{name}! You are #{age} years old, which is #{age_in_seconds} in seconds!"
|
||||
end
|
||||
|
||||
puts greeting('Fry', 25)
|
||||
|
||||
[[1], [2], [3]].each { |nums| nums.each { |num| puts num } }
|
||||
@ -1,173 +0,0 @@
|
||||
#![crate_type = "lib"]
|
||||
struct NestedStruct {
|
||||
value: u32,
|
||||
inner: Inner,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
value: u32,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn extern_block();
|
||||
}
|
||||
|
||||
union TestUnion {
|
||||
val_1: f32,
|
||||
val_2: u32,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct TupleStruct(u32);
|
||||
|
||||
#[cfg_attr(all(target_os = "linux", feature = "multithreaded"), derive(Default))]
|
||||
enum EnumTest {
|
||||
TupleVariant(u32),
|
||||
TupleVariantTupleStruct(TupleStruct),
|
||||
StructVariant { value: u32 },
|
||||
NestedStructVariant { inner: Inner },
|
||||
}
|
||||
|
||||
fn test_type_param<A: Default>() -> usize {
|
||||
std::mem::size_of::<A>()
|
||||
}
|
||||
|
||||
fn test_param(a: u32, b: u32) -> u32 {
|
||||
a * b
|
||||
}
|
||||
|
||||
fn tuple_param(a: (u32, u32)) -> u32 {
|
||||
let (a, b) = a;
|
||||
|
||||
a * a
|
||||
}
|
||||
|
||||
macro_rules! inefficient_vec {
|
||||
( $( $x:expr ),* ) => {
|
||||
{
|
||||
let mut temp_vec = Vec::new();
|
||||
$(
|
||||
temp_vec.push($x);
|
||||
)*
|
||||
temp_vec
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) struct VisibilityModifier;
|
||||
|
||||
|
||||
pub const NAMES: &'static [(&'static str, u32)] = &[
|
||||
("TEST NAME 1", 1),
|
||||
("TEST NAME 2", 2),
|
||||
];
|
||||
|
||||
fn main() {
|
||||
let nested_vec: Vec<Vec<Vec<Vec<Vec<Vec<()>>>>>> = Vec::<_>::new();
|
||||
let arr_arr_arr = [[[0; 4]; 4]; 4];
|
||||
let constructed_struct = Inner { value: 0 };
|
||||
|
||||
let nested_constructed = NestedStruct {
|
||||
value: 0,
|
||||
inner: Inner { value: 0 },
|
||||
};
|
||||
|
||||
let tuple_struct = TupleStruct(0);
|
||||
let nested_tuple = (
|
||||
((1, 2, 3, 4), (5, 6, 7, 8)),
|
||||
((9, 10, 11, 12), (13, 14, 15, 16)),
|
||||
);
|
||||
|
||||
let enums = vec![
|
||||
EnumTest::TupleVariant(0),
|
||||
EnumTest::TupleVariantTupleStruct(TupleStruct(0)),
|
||||
EnumTest::StructVariant { value: 0 },
|
||||
EnumTest::NestedStructVariant {
|
||||
inner: Inner { value: 0 },
|
||||
},
|
||||
];
|
||||
|
||||
let closure = |long_parameter_name: u8,
|
||||
long_parameter_name_two: u8,
|
||||
very_long_parameter_name: u8,
|
||||
extra_long_name: u8| {
|
||||
let nested_closure = || {};
|
||||
nested_closure();
|
||||
};
|
||||
|
||||
let async_block = async { 0 };
|
||||
|
||||
let labelled_block = 'a: { 0 };
|
||||
|
||||
let boolean_expr = (((3 * 4) + 5) > 1 || false) && (true || true);
|
||||
|
||||
let num = 5;
|
||||
|
||||
let match_expr = match num {
|
||||
_ => match boolean_expr {
|
||||
_ => {}
|
||||
},
|
||||
};
|
||||
|
||||
let fancy_match_expr = match enums[0] {
|
||||
EnumTest::TupleVariant(v) => {}
|
||||
EnumTest::TupleVariantTupleStruct(TupleStruct(v)) => {}
|
||||
EnumTest::StructVariant { value } => {}
|
||||
EnumTest::NestedStructVariant {
|
||||
inner: Inner { value },
|
||||
} => {}
|
||||
};
|
||||
|
||||
let array = [1, 2, 3, 4];
|
||||
|
||||
let array_match = match array {
|
||||
[a, b, c, d] => {}
|
||||
};
|
||||
|
||||
let nested_macro = vec![vec![vec![vec![vec![0]]]]];
|
||||
|
||||
test_param(3, 4);
|
||||
|
||||
let test_tuple: (u32, u32) = (0, 1);
|
||||
tuple_param(test_tuple);
|
||||
|
||||
let a = <u32 as From<u8>>::from(1u8);
|
||||
}
|
||||
|
||||
use level_1::{
|
||||
level_2::{
|
||||
level_3::{
|
||||
level_4::{
|
||||
level_5::{A, B},
|
||||
C, D,
|
||||
},
|
||||
E, F,
|
||||
},
|
||||
G, H,
|
||||
},
|
||||
I, J,
|
||||
};
|
||||
|
||||
mod level_1 {
|
||||
pub mod level_2 {
|
||||
pub mod level_3 {
|
||||
pub mod level_4 {
|
||||
pub mod level_5 {
|
||||
pub struct A;
|
||||
pub struct B;
|
||||
}
|
||||
pub struct C;
|
||||
pub struct D;
|
||||
}
|
||||
|
||||
pub struct E;
|
||||
pub struct F;
|
||||
}
|
||||
|
||||
pub struct G;
|
||||
pub struct H;
|
||||
}
|
||||
|
||||
pub struct I;
|
||||
pub struct J;
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
(define (add x y)
|
||||
"A silly way to add two numbers recursively."
|
||||
(if (zero? y)
|
||||
x
|
||||
(add (add1 x)
|
||||
(sub1 y))))
|
||||
|
||||
;; R6RS allows square brackets as well
|
||||
(define [mult x y]
|
||||
"A silly way of multiplying to numbers recursively"
|
||||
(if [= 1 y]
|
||||
x
|
||||
(add (add x x)
|
||||
(sub1 y))))
|
||||
|
||||
(define-syntax foo
|
||||
(syntax-rules ()
|
||||
((_ a ...)
|
||||
(printf "~a\n" (list a ...)))))
|
||||
|
||||
'(((a . b)))
|
||||
'((((a b . c))))
|
||||
@ -1,19 +0,0 @@
|
||||
@mixin admon($fg, $sign, $title) {
|
||||
border-top: 2.25rem solid $fg;
|
||||
background: color-mix(in srgb, $fg 50%, var(--color-bg));
|
||||
|
||||
&::before {
|
||||
position: absolute;
|
||||
content: $sign;
|
||||
top: 0.4rem;
|
||||
left: 0.75rem;
|
||||
}
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
content: $title;
|
||||
font-weight: bold;
|
||||
top: 0.5rem;
|
||||
left: 2.25rem;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
SELECT (1 + (2 + (3 + (4 + (5 + (6 + (7 + (8 + ((9) + (0))))))))));
|
||||
|
||||
SELECT
|
||||
(1 + ((2)((())) - 3)) AS "expression",
|
||||
(()) AS "list",
|
||||
-- ((((())))) AS "list" -- this will cause problems with the highlighting!
|
||||
"users"."id" AS "user_id",
|
||||
SUM("orders"."sum_prices") AS "user_orders_amount"
|
||||
FROM "users"
|
||||
JOIN (
|
||||
SELECT
|
||||
"orders"."id",
|
||||
"orders"."user_id",
|
||||
SUM("orders"."amount") AS "sum_prices"
|
||||
FROM "orders"
|
||||
GROUP BY
|
||||
"orders"."id",
|
||||
"orders"."user_id"
|
||||
) AS "orders" ON "orders"."user_id" = "users"."id"
|
||||
WHERE "users"."age" = (2 + (3 * 4)) AND (4 - (5 * 0)) = (1 * (2 + 2 + (5)))
|
||||
AND "users"."id" IN (1, 2, 3, 4)
|
||||
GROUP BY
|
||||
"users"."id";
|
||||
|
||||
SELECT *
|
||||
FROM products
|
||||
where (
|
||||
Product_Category = 'Fit'
|
||||
AND Product_number IN (1234, 1235, 1236, 1237, 1238)
|
||||
)
|
||||
or
|
||||
(Product_Category IN ('Tight', 'Wide') AND Product_number = 1324);
|
||||
|
||||
SELECT 10 FROM generate_series(1, 10) WHERE (TRUE);
|
||||
@ -1,43 +0,0 @@
|
||||
# This is mostly identical to Python, without the generator comprehension
|
||||
# NOTE: if you update queries for Python, please consider adding the changes
|
||||
# to this file as well
|
||||
|
||||
def sum_list(lst: List[Dict[int, int]]) -> int:
|
||||
result = 0
|
||||
for inner in lst:
|
||||
for i in inner:
|
||||
result += i
|
||||
return result
|
||||
|
||||
|
||||
my_list = [[['Hello, world!']]]
|
||||
my_dict = {'x': {'x': {'x': 'Hello, wold!'}}}
|
||||
my_set = {{{{'Hello, wold!'}}}}
|
||||
my_tuple = (((('Hello, wold!'),),),)
|
||||
(a,b) = (1,2)
|
||||
|
||||
list_comp = [i for i in [j for j in range(5)] if i % 2 == 0]
|
||||
dict_comp = {k: v for k, v in {k: v for k, v in {'k': 'v'}.items()}
|
||||
if k == 'k'}
|
||||
set_comp = {i for i in {j for j in range(5)} if i % 2 == 0}
|
||||
gen_comp = (i for i in (j for j in range(5)) if i % 2 == 0)
|
||||
|
||||
match my_dict:
|
||||
case {'x': {'x': {'x': message}}}:
|
||||
print(message)
|
||||
case [[[message]]]:
|
||||
print(message)
|
||||
case (((message))):
|
||||
print(message)
|
||||
|
||||
|
||||
zero = [0]
|
||||
|
||||
(a,b) = (1,2)
|
||||
[c,d] = [3,4]
|
||||
|
||||
print(zero[zero[zero[0]]])
|
||||
|
||||
|
||||
print(2 + ((((3)))))
|
||||
print(len(my_list))
|
||||
@ -1,31 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { baz } from 'foo/bar';
|
||||
|
||||
baz({a: {b: {c: 'd'}}});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
p {
|
||||
font-size: 2em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>Test page</title>
|
||||
<meta name="description" content="A test page" />
|
||||
</svelte:head>
|
||||
|
||||
<h1>A test page for Svelte</h1>
|
||||
|
||||
<form action="?/herp/derp" method="post">
|
||||
<p>This is a paragraph</p>
|
||||
<hr/>
|
||||
<ul>
|
||||
{#each ["foo", "bar", "baz"] as x}
|
||||
<li class="some-class">{ x }</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{# if True}
|
||||
<p>Some text </p>
|
||||
{/if}
|
||||
</form>
|
||||
@ -1,62 +0,0 @@
|
||||
-- This is a comment
|
||||
|
||||
local function add(x: integer, y: integer): integer
|
||||
if y == 0 then
|
||||
return x
|
||||
end
|
||||
return add((x + (1)), (y - (1)))
|
||||
end
|
||||
|
||||
if true then
|
||||
print 'True condition'
|
||||
elseif false then
|
||||
print 'Alternative condition'
|
||||
elseif false then
|
||||
print 'Alternative condition'
|
||||
else
|
||||
print 'Alternative'
|
||||
end
|
||||
|
||||
while false do
|
||||
print 'A while-loop'
|
||||
end
|
||||
|
||||
repeat
|
||||
print 'This will repeat only once'
|
||||
until true
|
||||
|
||||
do
|
||||
print 'A block'
|
||||
end
|
||||
|
||||
for i, v in ipairs({'a', 'b', 'c'}) do
|
||||
print(string.format("%d = %s", i, v))
|
||||
end
|
||||
|
||||
for i = 1, 5, 1 do
|
||||
print(string.format("Number %d", i))
|
||||
end
|
||||
|
||||
print(f1('a', 'b'))
|
||||
print((((('Hello, world!')))))
|
||||
|
||||
print {
|
||||
{
|
||||
{
|
||||
'Hello, world!'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local one = {1}
|
||||
|
||||
print(one[one[one[1]]])
|
||||
|
||||
-- Embedded Vim script
|
||||
vim.cmd [[
|
||||
echo a(b(c(d(e(f())))))
|
||||
]]
|
||||
|
||||
local tbl = {
|
||||
["highlight me"] = {}
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "time"
|
||||
|
||||
templ headerTemplate(name string) {
|
||||
<header data-testid="headerTemplate">
|
||||
switch name {
|
||||
case "Alice", "Bob":
|
||||
<h1>{ name }</h1>
|
||||
default:
|
||||
<h1>{ "Unknown" }</h1>
|
||||
}
|
||||
<script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<style type="text/css">
|
||||
p {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
</style>
|
||||
</header>
|
||||
}
|
||||
|
||||
templ footerTemplate() {
|
||||
<footer data-testid="footerTemplate">
|
||||
<div>© { fmt.Sprintf("%d", time.Now().Year()) }</div>
|
||||
</footer>
|
||||
}
|
||||
|
||||
templ layout(name string) {
|
||||
<html>
|
||||
<head><title>{ name }</title></head>
|
||||
<body>
|
||||
@headerTemplate(name)
|
||||
@navTemplate()
|
||||
<main>
|
||||
{ children... }
|
||||
<p>
|
||||
Hello<br/>world!
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
@footerTemplate()
|
||||
</html>
|
||||
}
|
||||
|
||||
templ navTemplate() {
|
||||
<nav data-testid="navTemplate">
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/posts">Posts</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
|
||||
templ posts(posts []Post) {
|
||||
@layout("Posts") {
|
||||
@postsTemplate(posts)
|
||||
if len(posts) > 0 {
|
||||
<div>{ "Not empty" }</div>
|
||||
} else {
|
||||
<div>{ "Empty" }</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ postsTemplate(posts []Post) {
|
||||
<div data-testid="postsTemplate">
|
||||
for _, p := range posts {
|
||||
<div data-testid="postsTemplatePost">
|
||||
<div data-testid="postsTemplatePostName">{ p.Name }</div>
|
||||
<div data-testid="postsTemplatePostAuthor">{ p.Author }</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
script withParameters(a string, b string, c int) {
|
||||
console.log(a, b, c);
|
||||
}
|
||||
|
||||
css red() {
|
||||
background-color: #ff0000;
|
||||
font-family: "Iosevka";
|
||||
}
|
||||
|
||||
// vim:ft=templ
|
||||
@ -1,20 +0,0 @@
|
||||
[table]
|
||||
[table.sub]
|
||||
people.names = [ "John", "Joe" ]
|
||||
|
||||
inline-table = { x = 0.1, y = 2 }
|
||||
|
||||
array-of-table = [
|
||||
{ name = "Alice", level = 2 },
|
||||
{ name = "Bob", level = 1 },
|
||||
]
|
||||
|
||||
[[array-of-table2]]
|
||||
z = 3
|
||||
|
||||
[[array-of-table2.t]]
|
||||
desc = "Index 1"
|
||||
|
||||
[[array-of-table2]]
|
||||
z = 30
|
||||
t.desc = "Index 2"
|
||||
@ -1,79 +0,0 @@
|
||||
// Function with nested function
|
||||
function add(x: number, y: number): number {
|
||||
function iter(i: number, acc: number) {
|
||||
if (i == 0) {
|
||||
return acc;
|
||||
}
|
||||
return iter(i - 1, acc + 1);
|
||||
}
|
||||
return iter(y, x)
|
||||
}
|
||||
|
||||
// Function with generic type parameter
|
||||
function id<T>(x: T): T {
|
||||
return x;
|
||||
}
|
||||
|
||||
// Class with members
|
||||
class Person {
|
||||
private name: string;
|
||||
private age: number;
|
||||
private salary: number;
|
||||
|
||||
constructor(name: string, age: number, salary: number) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `${this.name} (${this.age}) (${this.salary})`; // As of version 1.4
|
||||
}
|
||||
}
|
||||
|
||||
// Template strings
|
||||
const who = 'world';
|
||||
console.log(`Hello, ${who}`);
|
||||
|
||||
// Nested object
|
||||
let some_object = {
|
||||
a: {
|
||||
b: {
|
||||
c: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Subscript expressions
|
||||
const zeroes = [0];
|
||||
console.log(zeroes[zeroes[zeroes[0]]])
|
||||
|
||||
// Parenthesized expressions
|
||||
console.log(1 + (2 + (3 + (4 + (5 + 6)))))
|
||||
|
||||
|
||||
function hello() {
|
||||
console.log('Hello, world!');
|
||||
}
|
||||
|
||||
function app() {
|
||||
return (
|
||||
<div style={{ display: 'flex' }}>
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example link</a>.
|
||||
</p>
|
||||
<p>
|
||||
This is an <a href="https://example.com">Example<br/>link</a> with<br/> line <br/>break.
|
||||
</p>
|
||||
<button onClick={hello}>Click me!</button>
|
||||
<ComponentWithChildren>
|
||||
{someFunction().map((x) => <div></div>)}
|
||||
</ComponentWithChildren>
|
||||
<ComponentWith.property>
|
||||
{someFunction().map((x) => <div></div>)}
|
||||
</ComponentWith.property>
|
||||
<ComponentWith.property bool={true} arr={[1, 2, 3]} />
|
||||
<CustomComponent bool={true} arr={[1, 2, 3]} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
// Declarations
|
||||
declare namespace arithmetics {
|
||||
add(x: number, y: number): number;
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
// Function with nested function
|
||||
function add(x: number, y: number): number {
|
||||
function iter(i: number, acc: number) {
|
||||
if (i == 0) {
|
||||
return accu;
|
||||
}
|
||||
return iter(i - 1, acc + 1);
|
||||
}
|
||||
return iter(y, x)
|
||||
}
|
||||
|
||||
// Function with generic type parameter
|
||||
function id<T>(x: T): T {
|
||||
return x;
|
||||
}
|
||||
|
||||
// Class with members
|
||||
class Person {
|
||||
private name: string;
|
||||
private age: number;
|
||||
private salary: number;
|
||||
|
||||
constructor(name: string, age: number, salary: number) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `${this.name} (${this.age}) (${this.salary})`; // As of version 1.4
|
||||
}
|
||||
|
||||
async method(): Promise<Array<Record<string, number>>> {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
interface Request {
|
||||
body: RequestProp['body'];
|
||||
}
|
||||
|
||||
enum A {
|
||||
Foo = "Bar",
|
||||
}
|
||||
|
||||
// Template strings
|
||||
const who = 'world';
|
||||
console.log(`Hello, ${who}`);
|
||||
|
||||
// Nested object
|
||||
let some_object = {
|
||||
a: {
|
||||
b: {
|
||||
c: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Subscript expressions
|
||||
const zeroes = [0];
|
||||
console.log(zeroes[zeroes[zeroes[0]]])
|
||||
|
||||
let a = 1
|
||||
|
||||
switch(a) {
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
|
||||
// Parenthesized expressions
|
||||
console.log(1 + (2 + (3 + (4 + (5 + 6)))))
|
||||
@ -1,29 +0,0 @@
|
||||
#let template(doc) = {
|
||||
set page(paper: "a4", margin: (x: 2cm, y: 3cm))
|
||||
set heading(numbering: "1.1")
|
||||
set par(justify: true, leading: 0.55em)
|
||||
|
||||
show heading: it => {
|
||||
set block(above: 1.6em, below: 1em)
|
||||
it
|
||||
}
|
||||
|
||||
doc
|
||||
}
|
||||
|
||||
#show: template
|
||||
|
||||
= Typst
|
||||
|
||||
Typst is a markup language for typesetting documents. It is designed to be an
|
||||
alternative to LaTeX and other document processing tools.
|
||||
|
||||
This is a #[nested section #[of text with #[multiple layers of nesting.]]]
|
||||
|
||||
Maths can either be typeset inline: $A = pi r^2$; or as a separate block:
|
||||
$ frac(a^(2x), (5x + (3))) $
|
||||
|
||||
We can also put #[maths inside other content blocks: $V = 4/3 (pi r^3)$].
|
||||
|
||||
|
||||
// vim:ft=typst
|
||||
@ -1,140 +0,0 @@
|
||||
// Comment
|
||||
`timescale 1ns/1ns
|
||||
`default_nettype none
|
||||
`include "filename.svh"
|
||||
|
||||
typedef enum {
|
||||
A,
|
||||
B,
|
||||
C
|
||||
} Enum_t;
|
||||
|
||||
module test #(
|
||||
parameter int PARAM = 1
|
||||
) (
|
||||
input logic[15:0] a,
|
||||
input logic[15:0] b,
|
||||
|
||||
output logic[15:0] c
|
||||
);
|
||||
logic[15:0][8:0] packed_data;
|
||||
logic[8:0] to_be_casted;
|
||||
|
||||
divu #(
|
||||
.WIDTH(24),
|
||||
.FBITS(15)
|
||||
) divider (
|
||||
.clk(i_clk),
|
||||
.rst(div_rst_actual),
|
||||
.start(div_start),
|
||||
.valid(o_avg_rdy),
|
||||
.done(),
|
||||
.dbz(),
|
||||
.ovf(),
|
||||
.busy(div_busy),
|
||||
.a(div_dividend),
|
||||
.b(div_divisor),
|
||||
.val(div_result_q15_9)
|
||||
);
|
||||
|
||||
always_comb begin
|
||||
if (a > b) begin
|
||||
c = 15'd1;
|
||||
end else if ((a == b) || (a == c)) begin
|
||||
c = 15'd2;
|
||||
to_be_casted = 32'(c);
|
||||
|
||||
if (c == 15'd2) begin
|
||||
c = 15'd3;
|
||||
packed_data[2][3] = 8'd4;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
always_ff @(posedge a) begin
|
||||
c <= ((a + b) + b);
|
||||
end
|
||||
endmodule
|
||||
|
||||
// This module implements an unsigned fixed point divider.
|
||||
// Source: https://projectf.io/posts/division-in-verilog/
|
||||
module divu #(
|
||||
parameter WIDTH=32, // width of numbers in bits (integer and fractional)
|
||||
parameter FBITS=16 // fractional bits within WIDTH
|
||||
) (
|
||||
input wire logic clk, // clock
|
||||
input wire logic rst, // reset
|
||||
input wire logic start, // start calculation
|
||||
output logic busy, // calculation in progress
|
||||
output logic done, // calculation is complete (high for one tick)
|
||||
output logic valid, // result is valid
|
||||
output logic dbz, // divide by zero
|
||||
output logic ovf, // overflow
|
||||
input wire logic [WIDTH-1:0] a, // dividend (numerator)
|
||||
input wire logic [WIDTH-1:0] b, // divisor (denominator)
|
||||
output logic [WIDTH-1:0] val // result value: quotient
|
||||
);
|
||||
|
||||
localparam FBITSW = (FBITS == 0) ? 1 : FBITS; // avoid negative vector width when FBITS=0
|
||||
|
||||
logic [WIDTH-1:0] b1; // copy of divisor
|
||||
logic [WIDTH-1:0] quo, quo_next; // intermediate quotient
|
||||
logic [WIDTH:0] acc, acc_next; // accumulator (1 bit wider)
|
||||
|
||||
localparam ITER = WIDTH + FBITS; // iteration count: unsigned input width + fractional bits
|
||||
logic [$clog2(ITER)-1:0] i; // iteration counter
|
||||
|
||||
// division algorithm iteration
|
||||
always_comb begin
|
||||
if (acc >= {1'b0, b1}) begin
|
||||
acc_next = acc - b1;
|
||||
{acc_next, quo_next} = {acc_next[WIDTH-1:0], quo, 1'b1};
|
||||
end else begin
|
||||
{acc_next, quo_next} = {acc, quo} << 1;
|
||||
end
|
||||
end
|
||||
|
||||
// calculation control
|
||||
always_ff @(posedge clk) begin
|
||||
done <= 0;
|
||||
if (start) begin
|
||||
valid <= 0;
|
||||
ovf <= 0;
|
||||
i <= 0;
|
||||
if (b == 0) begin // catch divide by zero
|
||||
busy <= 0;
|
||||
done <= 1;
|
||||
dbz <= 1;
|
||||
end else begin
|
||||
busy <= 1;
|
||||
dbz <= 0;
|
||||
b1 <= b;
|
||||
{acc, quo} <= {{WIDTH{1'b0}}, a, 1'b0}; // initialize calculation
|
||||
end
|
||||
end else if (busy) begin
|
||||
if (i == ITER-1) begin // done
|
||||
busy <= 0;
|
||||
done <= 1;
|
||||
valid <= 1;
|
||||
val <= quo_next;
|
||||
end else if (i == WIDTH-1 && quo_next[WIDTH-1:WIDTH-FBITSW] != 0) begin // overflow?
|
||||
busy <= 0;
|
||||
done <= 1;
|
||||
ovf <= 1;
|
||||
val <= 0;
|
||||
end else begin // next iteration
|
||||
i <= i + 1;
|
||||
acc <= acc_next;
|
||||
quo <= quo_next;
|
||||
end
|
||||
end
|
||||
if (rst) begin
|
||||
busy <= 0;
|
||||
done <= 0;
|
||||
valid <= 0;
|
||||
dbz <= 0;
|
||||
ovf <= 0;
|
||||
val <= 0;
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
@ -1,52 +0,0 @@
|
||||
// Comment
|
||||
`timescale 1ns/1ns
|
||||
`default_nettype none
|
||||
`include "filename.vh"
|
||||
|
||||
module test #(
|
||||
parameter PARAM = 1
|
||||
) (
|
||||
input reg[15:0] a,
|
||||
input reg[15:0] b,
|
||||
|
||||
output reg[15:0] c
|
||||
);
|
||||
logic[15:0][8:0] packed_data;
|
||||
|
||||
always @* begin
|
||||
if (a > b) begin
|
||||
c = 15'd1;
|
||||
end else if ((a == b) || (a == c)) begin
|
||||
c = 15'd2;
|
||||
|
||||
if (c == 15'd2) begin
|
||||
c = 15'd3;
|
||||
packed_data[2][3] = 8'd4;
|
||||
end
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
||||
module test2 #(
|
||||
parameter PARAM = 1
|
||||
) (
|
||||
input reg[15:0] a,
|
||||
input reg[15:0] b,
|
||||
|
||||
output reg[15:0] c
|
||||
);
|
||||
logic[15:0][8:0] packed_data;
|
||||
|
||||
always @* begin
|
||||
if (a > b) begin
|
||||
c = 15'd1;
|
||||
end else if ((a == b) || (a == c)) begin
|
||||
c = 15'd2;
|
||||
|
||||
if (c == 15'd2) begin
|
||||
c = 15'd3;
|
||||
packed_data[2][3] = 8'd4;
|
||||
end
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
@ -1,14 +0,0 @@
|
||||
let g:my_list = [[[1]]]
|
||||
let g:my_dict = {
|
||||
\'a': {
|
||||
\'b': {
|
||||
\'c': {},
|
||||
\}
|
||||
\}
|
||||
\ }
|
||||
|
||||
echo string(1 + (2 + (3 + 4)))
|
||||
echo string(-(3))
|
||||
echo string((5)-(3))
|
||||
echo string((1) ? (2) : (3))
|
||||
echo ((('Hello, world!')))
|
||||
@ -1,10 +0,0 @@
|
||||
<!-- A template element written in Pug -->
|
||||
|
||||
<template lang="pug">
|
||||
| ErrorLayout
|
||||
| {{ errCode }}
|
||||
| {{ $t(errMsg) }}
|
||||
a-button(type="primary" @click="goToHome") Go to home
|
||||
template#footer
|
||||
a-button(type="primary" @click="goToHome") {{ $t(errMsg) }}
|
||||
</template>
|
||||
@ -1,39 +0,0 @@
|
||||
<!-- A plain default Vue.js program using the default languages -->
|
||||
|
||||
<template>
|
||||
{{ errCode }}
|
||||
{{ $t(errMsg) }}
|
||||
<a-button type="primary" @click="goToHome">goToHome</a-button>
|
||||
<template #footer>
|
||||
<a-button type="primary" @click="goToHome">{{ $t(errMsg) }}</a-button>
|
||||
<div>
|
||||
<p>Hello<br/>world</p>
|
||||
<hr/>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// Template strings
|
||||
let who = 'world';
|
||||
console.log(`Hello, ${who}`);
|
||||
// Nested object
|
||||
let some_object = {
|
||||
a: {
|
||||
b: {
|
||||
c: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.foo {
|
||||
color: #ffffff;
|
||||
}
|
||||
@media (not (color)) {
|
||||
.foo {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,18 +0,0 @@
|
||||
<!-- A style elemet written in SCSS -->
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.foo {
|
||||
color: red;
|
||||
background: #000;
|
||||
.bar {
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
@media (not (color)) {
|
||||
.foo {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,14 +0,0 @@
|
||||
<!-- A script element in Typescript -->
|
||||
|
||||
<script setup lang="ts">
|
||||
// Function with nested function
|
||||
function add(x: number, y: number): number {
|
||||
function iter(i: number, acc: number) {
|
||||
if (i == 0) {
|
||||
return accu;
|
||||
}
|
||||
return iter(i - 1, acc + 1);
|
||||
}
|
||||
return iter(y, x)
|
||||
}
|
||||
</script>
|
||||
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
|
||||
"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Example of MathML embedded in an XHTML file</title>
|
||||
<meta name="description" content="Example of MathML embedded in an XHTML file"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Example of MathML embedded in an XHTML file</h1>
|
||||
<p>
|
||||
The area of a circle is
|
||||
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
||||
<mi>π<!-- π --></mi>
|
||||
<mo>⁢<!-- ⁢ --></mo>
|
||||
<msup>
|
||||
<mi>r</mi>
|
||||
<mn>2</mn>
|
||||
</msup>
|
||||
</math>
|
||||
.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,25 +0,0 @@
|
||||
json_compatibility:
|
||||
{
|
||||
"foo": "bar",
|
||||
"bar": {
|
||||
"baz": [
|
||||
[
|
||||
[[['Hello, world!']]]
|
||||
]
|
||||
]
|
||||
},
|
||||
"key": {
|
||||
"key": {
|
||||
"key": {
|
||||
"key": {
|
||||
"key": "value"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_of_objects:
|
||||
- { key1: value, key2: value, key3: value }
|
||||
- { key1: value, key2: value, key3: value } # A comment
|
||||
- { key1: { key2: { key3: value, key4: value, key5: value } } } # Nested map
|
||||
@ -1,86 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
const Void = struct {};
|
||||
|
||||
const MyBool = enum {
|
||||
my_true,
|
||||
my_false,
|
||||
};
|
||||
|
||||
const SomeUnion = union(enum) {
|
||||
top: u0,
|
||||
kek: u1,
|
||||
};
|
||||
|
||||
comptime {
|
||||
const a: anyerror!SomeUnion = SomeUnion{.top = 0};
|
||||
|
||||
const b = switch (a catch |err| err) {
|
||||
SomeUnion.top => |val| val,
|
||||
SomeUnion.kek => |val| val,
|
||||
else => undefined,
|
||||
};
|
||||
|
||||
_ = b;
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
const some_type: type = *[][:8][*][*:.{ .mqu = false }]u123;
|
||||
_ = some_type;
|
||||
|
||||
const stoqn = [_]u8{ 'k', 'o', 'l', 'e', 'v' };
|
||||
|
||||
std.debug.print("My last {s} is {s} and it's first letter is {s}\n", .{ "name", stoqn, [_]u8{ stoqn[0] } });
|
||||
|
||||
// stdout is for the actual output of your application, for example if you
|
||||
// are implementing gzip, then only the compressed bytes should be sent to
|
||||
// stdout, not any debugging messages.
|
||||
const stdout_file = blk: {
|
||||
break :blk std.io.getStdOut().writer();
|
||||
};
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
const stdout = bw.writer();
|
||||
|
||||
switch (6) {
|
||||
5 => undefined,
|
||||
_ => {
|
||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
||||
},
|
||||
}
|
||||
|
||||
if (false) {
|
||||
const k = undefined;
|
||||
const a = undefined;
|
||||
{
|
||||
asm volatile (""
|
||||
: [_] "=r,m" (k)
|
||||
: [_] "r,m" (a)
|
||||
: ""
|
||||
);
|
||||
}
|
||||
} else if (true) {
|
||||
for ("proba", 0..) |c, i| {
|
||||
_ = c;
|
||||
_ = i;
|
||||
}
|
||||
} else {
|
||||
while (false) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
try bw.flush(); // don't forget to flush!
|
||||
}
|
||||
|
||||
const truth linksection("lambda") = "calculus";
|
||||
|
||||
fn foo(a: *opaque {}) callconv(.C) void {
|
||||
_ = a;
|
||||
}
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
#!/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/sh
|
||||
#!/nix/store/4bj2kxdm1462fzcc2i2s4dn33g2angcc-bash-5.2p32/bin/sh
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# This is free and unencumbered software released into the public domain.
|
||||
@ -43,29 +43,13 @@ while getopts 'ilEve:' opt; do
|
||||
done
|
||||
|
||||
|
||||
# We need to add this plugin to the custom configuration. The easiest way is
|
||||
# to create a symlink. Why not always have a symlink in the project? The Lua
|
||||
# language server will search for Lua files in every directory, so if it enters
|
||||
# the symlink it will be trapped in a cycle. What we do instead is create the
|
||||
# symlink only for the duration of a test session and remove it again
|
||||
# afterwards.
|
||||
|
||||
# We need separate symlinks if we want to run different tasks in parallel.
|
||||
# Otherwise the one the finishes first would delete the symlink from underneath
|
||||
# the one that is still running.
|
||||
uuid=$(uuidgen)
|
||||
mkdir -p ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/start/
|
||||
ln -fs $(pwd) ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/start/
|
||||
|
||||
if [ -n "$lua_expr" ]; then
|
||||
nvim --headless -c "lua $lua_expr" -c 'quitall!'
|
||||
else
|
||||
# We have to explicitly enable plugins, see ':h -l'
|
||||
nvim --cmd 'set loadplugins' -l $@
|
||||
# We have to explicitly enable plugins and user configuration, see ':h -l'
|
||||
nvim --cmd 'set loadplugins' -u "${XDG_CONFIG_HOME}/nvim/init.lua" -l $@
|
||||
fi
|
||||
|
||||
exit_code=$?
|
||||
|
||||
rm -rf ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/
|
||||
|
||||
exit $exit_code
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
-- Add the plugin itself to the runtime path so we can use it in our tests.
|
||||
vim.opt.runtimepath:append(vim.fn.getcwd())
|
||||
|
||||
-- Tree-sitter highlighting needs to be running, otherwise rainbow highlighting
|
||||
-- won't get updated on tree changes. The following autocommand enables it on
|
||||
-- every file type change.
|
||||
|
||||
|
||||
local function on_file_type(_args)
|
||||
vim.treesitter.start()
|
||||
local function on_buf_win_enter(_args)
|
||||
if vim.bo.filetype ~= '' then
|
||||
vim.treesitter.start()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {pattern = '*', callback = on_file_type})
|
||||
vim.api.nvim_create_autocmd('BufWinEnter', {pattern = '*', callback = on_buf_win_enter})
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
-- Custom configuration for Busted
|
||||
|
||||
local say = require 'say'
|
||||
-- If busted is not available this configuration is not running as part of a
|
||||
-- test, so there is nothing to do.
|
||||
local success, say = pcall(require, 'say')
|
||||
if not success then
|
||||
return
|
||||
end
|
||||
local assert = require 'luassert'
|
||||
|
||||
|
||||
|
||||
@ -11,10 +11,10 @@ body:
|
||||
- I have updated my neovim version to latest _master_.
|
||||
- I have updated my plugin to the latest version.
|
||||
- I have run `:TSUpdate`.
|
||||
- I have inspected the syntax tree using https://github.com/nvim-treesitter/playground and made sure
|
||||
- I have inspected the syntax tree using `:InspectTree` and made sure
|
||||
that no `ERROR` nodes are in the syntax tree. nvim-treesitter can not guarantee correct highlighting in the
|
||||
presence of `ERROR`s -- in this case, please report the bug directly at corresponding parser's repository. (You can find all repository URLs in [README.md](https://github.com/nvim-treesitter/nvim-treesitter#supported-languages).)
|
||||
- I have used `:TSHighlightCapturesUnderCursor` from https://github.com/nvim-treesitter/playground to inspect which highlight groups Neovim is using and that legacy syntax highlighting is not interfering (i.e., what you are observing is actual tree-sitter highlighting).
|
||||
- I have used `:Inspect` to inspect which highlight groups Neovim is using and that legacy syntax highlighting is not interfering (i.e., what you are observing is actual tree-sitter highlighting).
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
@ -34,8 +34,8 @@ body:
|
||||
attributes:
|
||||
label: Tree-sitter parsing result
|
||||
description: |
|
||||
Please provide the output of `:TSPlaygroundToggle` from https://github.com/nvim-treesitter/playground
|
||||
(screenshot or plain text) with the following options enabled (pressing the key):
|
||||
Please provide the output of `:InspectTree` (screenshot or plain text)
|
||||
with the following options enabled (pressing the key):
|
||||
- `I` (name of the parsed language)
|
||||
- `t` (toggle injected languages)
|
||||
- `a` (show anonymous nodes)
|
||||
@ -66,7 +66,7 @@ body:
|
||||
description: |
|
||||
Please provide a screenshot of the current highlighting. Please also tell us the `:h colorscheme` you are using
|
||||
and how to install it. If applicable, you can also upload a screenshot with the contents of
|
||||
`:TSHighlightCapturesUnderCursor`.
|
||||
`:Inspect`.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
pull_request_rules:
|
||||
- name: Merge lockfile updates
|
||||
conditions:
|
||||
- "title=Update lockfile.json"
|
||||
actions:
|
||||
review:
|
||||
type: APPROVE
|
||||
message: Automatically approving lockfile updates
|
||||
merge:
|
||||
method: merge
|
||||
|
||||
- name: Prepare for merge
|
||||
conditions:
|
||||
- and:
|
||||
- "-draft"
|
||||
- "#approved-reviews-by=1"
|
||||
- "#review-requested=0"
|
||||
actions:
|
||||
comment:
|
||||
message: |
|
||||
This PR is ready to be merged, and will be in 1 day if nothing happens before.
|
||||
If you want other people to review your PR, request their reviews.
|
||||
If you don't want this PR to be merged now, mark it as a Draft.
|
||||
|
||||
- name: Merge on approval
|
||||
conditions:
|
||||
- and:
|
||||
- or:
|
||||
- "#approved-reviews-by>=2"
|
||||
- and:
|
||||
- "#approved-reviews-by=1"
|
||||
- "updated-at>=1 day ago"
|
||||
- "-draft"
|
||||
- "#review-requested=0"
|
||||
actions:
|
||||
merge:
|
||||
method: rebase
|
||||
@ -1,8 +1,9 @@
|
||||
name: Linting and style checking
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
luacheck:
|
||||
@ -31,3 +32,20 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: latest
|
||||
args: --check .
|
||||
|
||||
format-queries:
|
||||
name: Lint queries
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
NVIM_TAG: stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Prepare
|
||||
run: |
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Lint
|
||||
run: |
|
||||
nvim --headless -c "TSInstallSync query" -c "q"
|
||||
nvim -l scripts/format-queries.lua
|
||||
git diff --exit-code
|
||||
|
||||
@ -22,7 +22,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-2022, macos-latest]
|
||||
os: [ubuntu-latest, windows-latest, macos-14]
|
||||
cc: [gcc, clang]
|
||||
nvim_tag: [stable]
|
||||
exclude:
|
||||
@ -30,18 +30,18 @@ jobs:
|
||||
cc: clang
|
||||
nvim_tag: stable
|
||||
|
||||
- os: macos-latest
|
||||
- os: macos-14
|
||||
cc: gcc
|
||||
nvim_tag: stable
|
||||
|
||||
- os: windows-2022
|
||||
- os: windows-latest
|
||||
cc: clang
|
||||
nvim_tag: stable
|
||||
|
||||
include:
|
||||
- os: windows-2022
|
||||
- os: windows-latest
|
||||
cc: cl
|
||||
nvim_tag: stable
|
||||
nvim_tag: nightly
|
||||
|
||||
- os: ubuntu-latest
|
||||
cc: gcc
|
||||
@ -51,36 +51,37 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
NVIM: ${{ matrix.os == 'windows-2022' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }}
|
||||
ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-2022' && 'rnoweb' }}
|
||||
NVIM: ${{ matrix.os == 'windows-latest' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }}
|
||||
ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-latest' && 'rnoweb' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tree-sitter/setup-action/cli@v1
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Install tree-sitter CLI
|
||||
run: npm i -g tree-sitter-cli
|
||||
|
||||
- name: Install and prepare Neovim
|
||||
env:
|
||||
NVIM_TAG: ${{ matrix.nvim_tag }}
|
||||
run: |
|
||||
bash ./scripts/ci-install-${{ matrix.os }}.sh
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Setup Parsers Cache
|
||||
id: parsers-cache
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./parser/
|
||||
~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/
|
||||
key: ${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.nvim_tag }}-parsers-v1-${{ hashFiles('./lockfile.json', './lua/nvim-treesitter/parsers.lua', './lua/nvim-treesitter/install.lua', './lua/nvim-treesitter/shell_command_selectors.lua') }}
|
||||
key: parsers-${{ join(matrix.*, '-') }}-${{ hashFiles(
|
||||
'./lockfile.json',
|
||||
'./lua/nvim-treesitter/install.lua',
|
||||
'./lua/nvim-treesitter/parsers.lua',
|
||||
'./lua/nvim-treesitter/shell_command_selectors.lua') }}
|
||||
|
||||
- name: Compile parsers
|
||||
run: $NVIM --headless -c "lua require'nvim-treesitter.install'.prefer_git=false" -c "TSInstallSync all" -c "q"
|
||||
|
||||
- name: Post compile Windows
|
||||
if: matrix.os == 'windows-2022'
|
||||
if: runner.os == 'Windows'
|
||||
run: cp -r ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/* parser
|
||||
|
||||
- name: Check query files
|
||||
|
||||
@ -27,10 +27,7 @@ jobs:
|
||||
CC: ${{ matrix.cc }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Install tree-sitter CLI
|
||||
run: npm i -g tree-sitter-cli
|
||||
- uses: tree-sitter/setup-action/cli@v1
|
||||
|
||||
- name: Test Dependencies
|
||||
run: |
|
||||
@ -43,21 +40,23 @@ jobs:
|
||||
- name: Install and prepare Neovim
|
||||
env:
|
||||
NVIM_TAG: stable
|
||||
TREE_SITTER_CLI_TAG: v0.20.8
|
||||
run: |
|
||||
bash ./scripts/ci-install-${{ matrix.os }}.sh
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Setup Parsers Cache
|
||||
id: parsers-cache
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./parser/
|
||||
~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/
|
||||
key: ${{ matrix.os }}-${{ matrix.cc }}-parsers-v1-${{ hashFiles('./lockfile.json', './lua/nvim-treesitter/parsers.lua', './lua/nvim-treesitter/install.lua', './lua/nvim-treesitter/shell_selectors.lua') }}
|
||||
key: parsers-${{ join(matrix.*, '-') }}-${{ hashFiles(
|
||||
'./lockfile.json',
|
||||
'./lua/nvim-treesitter/install.lua',
|
||||
'./lua/nvim-treesitter/parsers.lua',
|
||||
'./lua/nvim-treesitter/shell_selectors.lua') }}
|
||||
|
||||
- name: Compile parsers Unix like
|
||||
if: ${{ matrix.os != 'windows-latest' && steps.parsers-cache.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
nvim --headless -c "TSInstallSync all" -c "q"
|
||||
|
||||
|
||||
@ -14,6 +14,12 @@ jobs:
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.TOKEN_ID }}
|
||||
private-key: ${{ secrets.TOKEN_PRIVATE_KEY }}
|
||||
|
||||
- name: Prepare
|
||||
env:
|
||||
NVIM_TAG: stable
|
||||
@ -21,7 +27,7 @@ jobs:
|
||||
wget https://github.com/josephburnett/jd/releases/download/v1.7.1/jd-amd64-linux
|
||||
mv jd-amd64-linux /tmp/jd
|
||||
chmod +x /tmp/jd
|
||||
bash scripts/ci-install-ubuntu-latest.sh
|
||||
bash scripts/ci-install.sh
|
||||
|
||||
- name: Update parsers
|
||||
env:
|
||||
@ -32,21 +38,21 @@ jobs:
|
||||
# Pretty print
|
||||
cp lockfile.json /tmp/lockfile.json
|
||||
cat /tmp/lockfile.json | jq --sort-keys > lockfile.json
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config user.name 'GitHub'
|
||||
git config user.email 'noreply@github.com'
|
||||
git add lockfile.json
|
||||
UPDATED_PARSERS=$(/tmp/jd -f merge /tmp/old_lockfile.json lockfile.json | jq -r 'keys | join(", ")')
|
||||
echo "UPDATED_PARSERS=$UPDATED_PARSERS" >> $GITHUB_ENV
|
||||
git commit -m "Update parsers: $UPDATED_PARSERS" || echo 'No commit necessary!'
|
||||
git clean -xf
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
author: "nvim-treesitter-bot[bot] <157957100+nvim-treesitter-bot[bot]@users.noreply.github.com>"
|
||||
commit-message: "bot(lockfile): update ${{ env.UPDATED_PARSERS }}"
|
||||
title: "Update lockfile.json: ${{ env.UPDATED_PARSERS }}"
|
||||
body: "[beep boop](https://github.com/peter-evans/create-pull-request)"
|
||||
branch: update-lockfile-pr
|
||||
base: ${{ github.head_ref }}
|
||||
draft: true
|
||||
|
||||
- name: Enable Pull Request Automerge
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
run: gh pr merge --rebase --auto update-lockfile-pr
|
||||
|
||||
@ -13,26 +13,34 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.TOKEN_ID }}
|
||||
private-key: ${{ secrets.TOKEN_PRIVATE_KEY }}
|
||||
|
||||
- name: Prepare
|
||||
env:
|
||||
NVIM_TAG: stable
|
||||
run: |
|
||||
bash ./scripts/ci-install-ubuntu-latest.sh
|
||||
bash ./scripts/ci-install.sh
|
||||
|
||||
- name: Check README
|
||||
run: |
|
||||
git config user.email 'actions@github'
|
||||
git config user.name 'Github Actions'
|
||||
nvim -l scripts/update-readme.lua || echo 'Needs update'
|
||||
git add README.md
|
||||
git commit -m 'Update README' || echo 'No commit necessary!'
|
||||
git clean -xf
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
commit-message: Update README
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
author: "nvim-treesitter-bot[bot] <157957100+nvim-treesitter-bot[bot]@users.noreply.github.com>"
|
||||
commit-message: "bot(readme): update"
|
||||
title: Update README
|
||||
body: "[beep boop](https://github.com/peter-evans/create-pull-request)"
|
||||
branch: update-readme-pr
|
||||
base: ${{ github.head_ref }}
|
||||
draft: true
|
||||
|
||||
- name: Enable Pull Request Automerge
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
run: gh pr merge --rebase --auto update-readme-pr
|
||||
|
||||
@ -8,7 +8,7 @@ If you haven't already, you should really come and reach out to us on our
|
||||
As you know, `nvim-treesitter` is roughly split in two parts:
|
||||
|
||||
- Parser configurations : for various things like `locals`, `highlights`
|
||||
- What we like to call _modules_ : tiny lua modules that provide a given feature, based on parser configurations
|
||||
- What we like to call _modules_ : tiny Lua modules that provide a given feature, based on parser configurations
|
||||
|
||||
Depending on which part of the plugin you want to contribute to, please read the appropriate section.
|
||||
|
||||
@ -63,12 +63,14 @@ Here are some global advices:
|
||||
you can install the [playground plugin](https://github.com/nvim-treesitter/playground).
|
||||
- If your language is listed [here](https://github.com/nvim-treesitter/nvim-treesitter#supported-languages),
|
||||
you can debug and experiment with your queries there.
|
||||
- If not, you should consider installing the [tree-sitter cli](https://github.com/tree-sitter/tree-sitter/tree/master/cli),
|
||||
- If not, you should consider installing the [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter/tree/master/cli),
|
||||
you should then be able to open a local playground using `tree-sitter build-wasm && tree-sitter web-ui` within the
|
||||
parsers repo.
|
||||
- Examples of queries can be found in [queries/](queries/)
|
||||
- Matches in the bottom will override queries that are above of them.
|
||||
|
||||
#### Inheriting languages
|
||||
|
||||
If your language is an extension of a language (TypeScript is an extension of JavaScript for
|
||||
example), you can include the queries from your base language by adding the following _as the first
|
||||
line of your file_.
|
||||
@ -80,161 +82,181 @@ line of your file_.
|
||||
If you want to inherit a language, but don't want the languages inheriting from yours to inherit it,
|
||||
you can mark the language as optional (by putting it between parenthesis).
|
||||
|
||||
#### Formatting
|
||||
|
||||
All queries are expected to follow a standard format, with every node on a single line and indented by two spaces for each level of nesting. You can automatically format the bundled queries by running the provided formatter `./scripts/format-queries.lua` on a single file (ending in `.scm`) or directory to format.
|
||||
|
||||
Should you need to preserve a specific format for a node, you can exempt it (and all contained nodes) by placing before it
|
||||
```query
|
||||
; format-ignore
|
||||
```
|
||||
|
||||
### Highlights
|
||||
|
||||
As languages differ quite a lot, here is a set of captures available to you when building a `highlights.scm` query. Note that your colorscheme needs to define (or link) these captures as highlight groups.
|
||||
As languages differ quite a lot, here is a set of captures available to you when building a `highlights.scm` query. Note that your color scheme needs to define (or link) these captures as highlight groups.
|
||||
|
||||
#### Misc
|
||||
#### Identifiers
|
||||
|
||||
```scheme
|
||||
@comment ; line and block comments
|
||||
@comment.documentation ; comments documenting code
|
||||
@error ; syntax/parser errors
|
||||
@none ; completely disable the highlight
|
||||
@preproc ; various preprocessor directives & shebangs
|
||||
@define ; preprocessor definition directives
|
||||
@operator ; symbolic operators (e.g. `+` / `*`)
|
||||
```query
|
||||
@variable ; various variable names
|
||||
@variable.builtin ; built-in variable names (e.g. `this`)
|
||||
@variable.parameter ; parameters of a function
|
||||
@variable.parameter.builtin ; special parameters (e.g. `_`, `it`)
|
||||
@variable.member ; object and struct fields
|
||||
|
||||
@constant ; constant identifiers
|
||||
@constant.builtin ; built-in constant values
|
||||
@constant.macro ; constants defined by the preprocessor
|
||||
|
||||
@module ; modules or namespaces
|
||||
@module.builtin ; built-in modules or namespaces
|
||||
@label ; GOTO and other labels (e.g. `label:` in C), including heredoc labels
|
||||
```
|
||||
|
||||
#### Literals
|
||||
|
||||
```query
|
||||
@string ; string literals
|
||||
@string.documentation ; string documenting code (e.g. Python docstrings)
|
||||
@string.regexp ; regular expressions
|
||||
@string.escape ; escape sequences
|
||||
@string.special ; other special strings (e.g. dates)
|
||||
@string.special.symbol ; symbols or atoms
|
||||
@string.special.url ; URIs (e.g. hyperlinks)
|
||||
@string.special.path ; filenames
|
||||
|
||||
@character ; character literals
|
||||
@character.special ; special characters (e.g. wildcards)
|
||||
|
||||
@boolean ; boolean literals
|
||||
@number ; numeric literals
|
||||
@number.float ; floating-point number literals
|
||||
```
|
||||
|
||||
#### Types
|
||||
|
||||
```query
|
||||
@type ; type or class definitions and annotations
|
||||
@type.builtin ; built-in types
|
||||
@type.definition ; identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
|
||||
|
||||
@attribute ; attribute annotations (e.g. Python decorators, Rust lifetimes)
|
||||
@attribute.builtin ; builtin annotations (e.g. `@property` in Python)
|
||||
@property ; the key in key/value pairs
|
||||
```
|
||||
|
||||
#### Functions
|
||||
|
||||
```query
|
||||
@function ; function definitions
|
||||
@function.builtin ; built-in functions
|
||||
@function.call ; function calls
|
||||
@function.macro ; preprocessor macros
|
||||
|
||||
@function.method ; method definitions
|
||||
@function.method.call ; method calls
|
||||
|
||||
@constructor ; constructor calls and definitions
|
||||
@operator ; symbolic operators (e.g. `+` / `*`)
|
||||
```
|
||||
|
||||
#### Keywords
|
||||
|
||||
```query
|
||||
@keyword ; keywords not fitting into specific categories
|
||||
@keyword.coroutine ; keywords related to coroutines (e.g. `go` in Go, `async/await` in Python)
|
||||
@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python)
|
||||
@keyword.operator ; operators that are English words (e.g. `and` / `or`)
|
||||
@keyword.import ; keywords for including or exporting modules (e.g. `import` / `from` in Python)
|
||||
@keyword.type ; keywords describing namespaces and composite types (e.g. `struct`, `enum`)
|
||||
@keyword.modifier ; keywords modifying other constructs (e.g. `const`, `static`, `public`)
|
||||
@keyword.repeat ; keywords related to loops (e.g. `for` / `while`)
|
||||
@keyword.return ; keywords like `return` and `yield`
|
||||
@keyword.debug ; keywords related to debugging
|
||||
@keyword.exception ; keywords related to exceptions (e.g. `throw` / `catch`)
|
||||
|
||||
@keyword.conditional ; keywords related to conditionals (e.g. `if` / `else`)
|
||||
@keyword.conditional.ternary ; ternary operator (e.g. `?` / `:`)
|
||||
|
||||
@keyword.directive ; various preprocessor directives & shebangs
|
||||
@keyword.directive.define ; preprocessor definition directives
|
||||
```
|
||||
|
||||
#### Punctuation
|
||||
|
||||
```scheme
|
||||
```query
|
||||
@punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`)
|
||||
@punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`)
|
||||
@punctuation.special ; special symbols (e.g. `{}` in string interpolation)
|
||||
```
|
||||
|
||||
#### Literals
|
||||
#### Comments
|
||||
|
||||
```scheme
|
||||
@string ; string literals
|
||||
@string.documentation ; string documenting code (e.g. Python docstrings)
|
||||
@string.regex ; regular expressions
|
||||
@string.escape ; escape sequences
|
||||
@string.special ; other special strings (e.g. dates)
|
||||
```query
|
||||
@comment ; line and block comments
|
||||
@comment.documentation ; comments documenting code
|
||||
|
||||
@character ; character literals
|
||||
@character.special ; special characters (e.g. wildcards)
|
||||
|
||||
@boolean ; boolean literals
|
||||
@number ; numeric literals
|
||||
@float ; floating-point number literals
|
||||
@comment.error ; error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED`)
|
||||
@comment.warning ; warning-type comments (e.g. `WARNING`, `FIX`, `HACK`)
|
||||
@comment.todo ; todo-type comments (e.g. `TODO`, `WIP`)
|
||||
@comment.note ; note-type comments (e.g. `NOTE`, `INFO`, `XXX`)
|
||||
```
|
||||
|
||||
#### Functions
|
||||
|
||||
```scheme
|
||||
@function ; function definitions
|
||||
@function.builtin ; built-in functions
|
||||
@function.call ; function calls
|
||||
@function.macro ; preprocessor macros
|
||||
|
||||
@method ; method definitions
|
||||
@method.call ; method calls
|
||||
|
||||
@constructor ; constructor calls and definitions
|
||||
@parameter ; parameters of a function
|
||||
```
|
||||
|
||||
#### Keywords
|
||||
|
||||
```scheme
|
||||
@keyword ; various keywords
|
||||
@keyword.coroutine ; keywords related to coroutines (e.g. `go` in Go, `async/await` in Python)
|
||||
@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python)
|
||||
@keyword.operator ; operators that are English words (e.g. `and` / `or`)
|
||||
@keyword.return ; keywords like `return` and `yield`
|
||||
|
||||
@conditional ; keywords related to conditionals (e.g. `if` / `else`)
|
||||
@conditional.ternary ; ternary operator (e.g. `?` / `:`)
|
||||
|
||||
@repeat ; keywords related to loops (e.g. `for` / `while`)
|
||||
@debug ; keywords related to debugging
|
||||
@label ; GOTO and other labels (e.g. `label:` in C)
|
||||
@include ; keywords for including modules (e.g. `import` / `from` in Python)
|
||||
@exception ; keywords related to exceptions (e.g. `throw` / `catch`)
|
||||
```
|
||||
|
||||
#### Types
|
||||
|
||||
```scheme
|
||||
@type ; type or class definitions and annotations
|
||||
@type.builtin ; built-in types
|
||||
@type.definition ; identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
|
||||
@type.qualifier ; type qualifiers (e.g. `const`)
|
||||
|
||||
@storageclass ; modifiers that affect storage in memory or life-time
|
||||
@attribute ; attribute annotations (e.g. Python decorators)
|
||||
@field ; object and struct fields
|
||||
@property ; similar to `@field`
|
||||
```
|
||||
|
||||
#### Identifiers
|
||||
|
||||
```scheme
|
||||
@variable ; various variable names
|
||||
@variable.builtin ; built-in variable names (e.g. `this`)
|
||||
|
||||
@constant ; constant identifiers
|
||||
@constant.builtin ; built-in constant values
|
||||
@constant.macro ; constants defined by the preprocessor
|
||||
|
||||
@namespace ; modules or namespaces
|
||||
@symbol ; symbols or atoms
|
||||
```
|
||||
|
||||
#### Text
|
||||
#### Markup
|
||||
|
||||
Mainly for markup languages.
|
||||
|
||||
```scheme
|
||||
@text ; non-structured text
|
||||
@text.strong ; bold text
|
||||
@text.emphasis ; text with emphasis
|
||||
@text.underline ; underlined text
|
||||
@text.strike ; strikethrough text
|
||||
@text.title ; text that is part of a title
|
||||
@text.quote ; text quotations
|
||||
@text.uri ; URIs (e.g. hyperlinks)
|
||||
@text.math ; math environments (e.g. `$ ... $` in LaTeX)
|
||||
@text.environment ; text environments of markup languages
|
||||
@text.environment.name ; text indicating the type of an environment
|
||||
@text.reference ; text references, footnotes, citations, etc.
|
||||
```query
|
||||
@markup.strong ; bold text
|
||||
@markup.italic ; italic text
|
||||
@markup.strikethrough ; struck-through text
|
||||
@markup.underline ; underlined text (only for literal underline markup!)
|
||||
|
||||
@text.literal ; literal or verbatim text (e.g., inline code)
|
||||
@text.literal.block ; literal or verbatim text as a stand-alone block
|
||||
@markup.heading ; headings, titles (including markers)
|
||||
@markup.heading.1 ; top-level heading
|
||||
@markup.heading.2 ; section heading
|
||||
@markup.heading.3 ; subsection heading
|
||||
@markup.heading.4 ; and so on
|
||||
@markup.heading.5 ; and so forth
|
||||
@markup.heading.6 ; six levels ought to be enough for anybody
|
||||
|
||||
@markup.quote ; block quotes
|
||||
@markup.math ; math environments (e.g. `$ ... $` in LaTeX)
|
||||
|
||||
@markup.link ; text references, footnotes, citations, etc.
|
||||
@markup.link.label ; link, reference descriptions
|
||||
@markup.link.url ; URL-style links
|
||||
|
||||
@markup.raw ; literal or verbatim text (e.g. inline code)
|
||||
@markup.raw.block ; literal or verbatim text as a stand-alone block
|
||||
; (use priority 90 for blocks with injections)
|
||||
|
||||
@text.todo ; todo notes
|
||||
@text.note ; info notes
|
||||
@text.warning ; warning notes
|
||||
@text.danger ; danger/error notes
|
||||
|
||||
@text.diff.add ; added text (for diff files)
|
||||
@text.diff.delete ; deleted text (for diff files)
|
||||
@markup.list ; list markers
|
||||
@markup.list.checked ; checked todo-style list markers
|
||||
@markup.list.unchecked ; unchecked todo-style list markers
|
||||
```
|
||||
|
||||
#### Tags
|
||||
|
||||
Used for XML-like tags.
|
||||
|
||||
```scheme
|
||||
@tag ; XML tag names
|
||||
@tag.attribute ; XML tag attributes
|
||||
@tag.delimiter ; XML tag delimiters
|
||||
```query
|
||||
@diff.plus ; added text (for diff files)
|
||||
@diff.minus ; deleted text (for diff files)
|
||||
@diff.delta ; changed text (for diff files)
|
||||
```
|
||||
|
||||
#### Conceal
|
||||
|
||||
```scheme
|
||||
@conceal ; for captures that are only used for concealing
|
||||
```query
|
||||
@tag ; XML-style tag names (and similar)
|
||||
@tag.builtin ; builtin tag names (e.g. HTML5 tags)
|
||||
@tag.attribute ; XML-style tag attributes
|
||||
@tag.delimiter ; XML-style tag delimiters
|
||||
```
|
||||
|
||||
`@conceal` must be followed by `(#set! conceal "")`.
|
||||
#### Non-highlighting captures
|
||||
|
||||
#### Spell
|
||||
```query
|
||||
@none ; completely disable the highlight
|
||||
@conceal ; captures that are only meant to be concealed
|
||||
```
|
||||
|
||||
```scheme
|
||||
```query
|
||||
@spell ; for defining regions to be spellchecked
|
||||
@nospell ; for defining regions that should NOT be spellchecked
|
||||
```
|
||||
@ -243,6 +265,25 @@ The main types of nodes which are spell checked are:
|
||||
- Comments
|
||||
- Strings; where it makes sense. Strings that have interpolation or are typically used for non text purposes are not spell checked (e.g. bash).
|
||||
|
||||
#### Predicates
|
||||
|
||||
Captures can be restricted according to node contents using [predicates](https://neovim.io/doc/user/treesitter.html#treesitter-predicates). For performance reasons, prefer earlier predicates in this list:
|
||||
|
||||
1. `#eq?` (literal match)
|
||||
2. `#any-of?` (one of several literal matches)
|
||||
3. `#lua-match?` (match against a [Lua pattern](https://neovim.io/doc/user/luaref.html#lua-pattern))
|
||||
4. `#match?`/`#vim-match?` (match against a [Vim regular expression](https://neovim.io/doc/user/pattern.html#regexp)
|
||||
|
||||
#### Conceal
|
||||
|
||||
Captures can be concealed by setting the [`conceal` metadata](https://neovim.io/doc/user/treesitter.html#treesitter-highlight-conceal), e.g..,
|
||||
```query
|
||||
(fenced_code_block_delimiter @markup.raw.block (#set! conceal ""))
|
||||
```
|
||||
The capture should be meaningful to allow proper highlighting when `set conceallevel=0`. If the unconcealed capture should not be highlighted (e.g., because an earlier pattern handles this), you can use `@conceal`.
|
||||
|
||||
A conceal can be restricted to part of the capture via the [`#offset!` directive](https://neovim.io/doc/user/treesitter.html#treesitter-directive-offset%21).
|
||||
|
||||
#### Priority
|
||||
|
||||
Captures can be assigned a priority to control precedence of highlights via the
|
||||
@ -253,29 +294,29 @@ highlighting (such as diagnostics or LSP semantic tokens).
|
||||
|
||||
### Locals
|
||||
|
||||
Note: pay specific attention to the captures here as they are a bit different to
|
||||
those listed in the upstream [Local Variables
|
||||
docs](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables).
|
||||
Some of these docs didn't exist when `nvim-treesitter` was created and the
|
||||
upstream captures are more limiting than what we have here.
|
||||
Locals are used to keep track of definitions and references in local or global
|
||||
scopes, see [upstream
|
||||
documentation](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables).
|
||||
Note that nvim-treesitter uses more specific subcaptures for definitions and
|
||||
**does not use locals for highlighting**.
|
||||
|
||||
```scheme
|
||||
@definition ; various definitions
|
||||
@definition.constant ; constants
|
||||
@definition.function ; functions
|
||||
@definition.method ; methods
|
||||
@definition.var ; variables
|
||||
@definition.parameter ; parameters
|
||||
@definition.macro ; preprocessor macros
|
||||
@definition.type ; types or classes
|
||||
@definition.field ; fields or properties
|
||||
@definition.enum ; enumerations
|
||||
@definition.namespace ; modules or namespaces
|
||||
@definition.import ; imported names
|
||||
@definition.associated ; the associated type of a variable
|
||||
```query
|
||||
@local.definition ; various definitions
|
||||
@local.definition.constant ; constants
|
||||
@local.definition.function ; functions
|
||||
@local.definition.method ; methods
|
||||
@local.definition.var ; variables
|
||||
@local.definition.parameter ; parameters
|
||||
@local.definition.macro ; preprocessor macros
|
||||
@local.definition.type ; types or classes
|
||||
@local.definition.field ; fields or properties
|
||||
@local.definition.enum ; enumerations
|
||||
@local.definition.namespace ; modules or namespaces
|
||||
@local.definition.import ; imported names
|
||||
@local.definition.associated ; the associated type of a variable
|
||||
|
||||
@scope ; scope block
|
||||
@reference ; identifier reference
|
||||
@local.scope ; scope block
|
||||
@local.reference ; identifier reference
|
||||
```
|
||||
|
||||
#### Definition Scope
|
||||
@ -294,7 +335,7 @@ doSomething(); // Should point to the declaration as the definition
|
||||
|
||||
```query
|
||||
(function_declaration
|
||||
((identifier) @definition.var)
|
||||
((identifier) @local.definition.var)
|
||||
(#set! "definition.var.scope" "parent"))
|
||||
```
|
||||
|
||||
@ -308,11 +349,11 @@ Possible scope values are:
|
||||
|
||||
You can define folds for a given language by adding a `folds.scm` query :
|
||||
|
||||
```scheme
|
||||
```query
|
||||
@fold ; fold this node
|
||||
```
|
||||
|
||||
If the `folds.scm` query is not present, this will fall back to the `@scope` captures in the `locals`
|
||||
If the `folds.scm` query is not present, this will fall back to the `@local.scope` captures in the `locals`
|
||||
query.
|
||||
|
||||
### Injections
|
||||
@ -322,7 +363,7 @@ Some captures are related to language injection (like markdown code blocks). The
|
||||
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@injection.language` to capture
|
||||
the node describing the language and `@injection.content` to describe the injection region.
|
||||
|
||||
```scheme
|
||||
```query
|
||||
@injection.language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language)
|
||||
@injection.content ; region for the dynamically detected language
|
||||
```
|
||||
@ -346,7 +387,7 @@ To combine all matches of a pattern as one single block of content, add `(#set!
|
||||
|
||||
### Indents
|
||||
|
||||
```scheme
|
||||
```query
|
||||
@indent.begin ; indent children when matching this node
|
||||
@indent.end ; marks the end of indented block
|
||||
@indent.align ; behaves like python aligned/hanging indent
|
||||
|
||||
@ -39,7 +39,7 @@ More examples can be found in [our gallery](https://github.com/nvim-treesitter/n
|
||||
**Warning: Treesitter and nvim-treesitter highlighting are an experimental feature of Neovim.
|
||||
Please consider the experience with this plug-in as experimental until Tree-Sitter support in Neovim is stable!
|
||||
We recommend using the nightly builds of Neovim if possible.
|
||||
You can find the current roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/projects/1).
|
||||
You can find the current roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/issues/4767).
|
||||
The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated!**
|
||||
|
||||
Nvim-treesitter is based on three interlocking features: [**language parsers**](#language-parsers), [**queries**](#adding-queries), and [**modules**](#available-modules), where _modules_ provide features – e.g., highlighting – based on _queries_ for syntax objects extracted from a given buffer by _language parsers_.
|
||||
@ -63,7 +63,7 @@ For more detailed information on setting these up, see ["Advanced setup"](#advan
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Neovim 0.9.1** or later ([nightly](https://github.com/neovim/neovim#install-from-source) recommended)
|
||||
- **Neovim 0.9.2** or later ([nightly](https://github.com/neovim/neovim#install-from-source) recommended)
|
||||
- `tar` and `curl` in your path (or alternatively `git`)
|
||||
- A C compiler in your path and libstdc++ installed ([Windows users please read this!](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support)).
|
||||
|
||||
@ -105,8 +105,8 @@ All modules are disabled by default and need to be activated explicitly in your
|
||||
|
||||
```lua
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
|
||||
-- A list of parser names, or "all" (the listed parsers MUST always be installed)
|
||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
@ -175,21 +175,23 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
<!--parserinfo-->
|
||||
- [x] [ada](https://github.com/briot/tree-sitter-ada) (maintained by @briot)
|
||||
- [x] [agda](https://github.com/tree-sitter/tree-sitter-agda) (maintained by @Decodetalkers)
|
||||
- [ ] [angular](https://github.com/steelsojka/tree-sitter-angular) (experimental)
|
||||
- [x] [angular](https://github.com/dlvandenberg/tree-sitter-angular) (experimental, maintained by @dlvandenberg)
|
||||
- [x] [apex](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber)
|
||||
- [x] [arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) (maintained by @ObserverOfTime)
|
||||
- [x] [asm](https://github.com/RubixDev/tree-sitter-asm) (maintained by @RubixDev)
|
||||
- [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13)
|
||||
- [x] [authzed](https://github.com/mleonidas/tree-sitter-authzed) (maintained by @mattpolzin)
|
||||
- [ ] [awk](https://github.com/Beaglefoot/tree-sitter-awk)
|
||||
- [x] [bash](https://github.com/tree-sitter/tree-sitter-bash) (maintained by @TravonteD)
|
||||
- [x] [bass](https://github.com/amaanq/tree-sitter-bass) (maintained by @amaanq)
|
||||
- [x] [bass](https://github.com/vito/tree-sitter-bass) (maintained by @amaanq)
|
||||
- [x] [beancount](https://github.com/polarmutex/tree-sitter-beancount) (maintained by @polarmutex)
|
||||
- [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason)
|
||||
- [x] [bicep](https://github.com/amaanq/tree-sitter-bicep) (maintained by @amaanq)
|
||||
- [x] [bitbake](https://github.com/amaanq/tree-sitter-bitbake) (maintained by @amaanq)
|
||||
- [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus)
|
||||
- [x] [bp](https://github.com/ambroisie/tree-sitter-bp) (maintained by @ambroisie)
|
||||
- [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @amaanq)
|
||||
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed)
|
||||
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @amaanq)
|
||||
- [x] [cairo](https://github.com/amaanq/tree-sitter-cairo) (maintained by @amaanq)
|
||||
- [x] [capnp](https://github.com/amaanq/tree-sitter-capnp) (maintained by @amaanq)
|
||||
- [x] [chatito](https://github.com/ObserverOfTime/tree-sitter-chatito) (maintained by @ObserverOfTime)
|
||||
@ -205,16 +207,20 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [csv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq)
|
||||
- [x] [cuda](https://github.com/theHamsta/tree-sitter-cuda) (maintained by @theHamsta)
|
||||
- [x] [cue](https://github.com/eonpatapon/tree-sitter-cue) (maintained by @amaanq)
|
||||
- [x] [d](https://github.com/CyberShadow/tree-sitter-d) (experimental, maintained by @nawordar)
|
||||
- [x] [d](https://github.com/gdamore/tree-sitter-d) (maintained by @amaanq)
|
||||
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @akinsho)
|
||||
- [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar)
|
||||
- [x] [dhall](https://github.com/jbellerb/tree-sitter-dhall) (maintained by @amaanq)
|
||||
- [x] [diff](https://github.com/the-mikedavis/tree-sitter-diff) (maintained by @gbprod)
|
||||
- [x] [disassembly](https://github.com/ColinKennedy/tree-sitter-disassembly) (maintained by @ColinKennedy)
|
||||
- [x] [djot](https://github.com/treeman/tree-sitter-djot) (maintained by @NoahTheDuke)
|
||||
- [x] [dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) (maintained by @camdencheek)
|
||||
- [x] [dot](https://github.com/rydesun/tree-sitter-dot) (maintained by @rydesun)
|
||||
- [x] [doxygen](https://github.com/amaanq/tree-sitter-doxygen) (maintained by @amaanq)
|
||||
- [x] [dtd](https://github.com/ObserverOfTime/tree-sitter-xml) (maintained by @ObserverOfTime)
|
||||
- [x] [dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) (maintained by @ObserverOfTime)
|
||||
- [x] [earthfile](https://github.com/glehmann/tree-sitter-earthfile) (maintained by @glehmann)
|
||||
- [x] [ebnf](https://github.com/RubixDev/ebnf) (experimental, maintained by @RubixDev)
|
||||
- [x] [editorconfig](https://github.com/ValdezFOmar/tree-sitter-editorconfig) (maintained by @ValdezFOmar)
|
||||
- [x] [eds](https://github.com/uyha/tree-sitter-eds) (maintained by @uyha)
|
||||
- [x] [eex](https://github.com/connorlay/tree-sitter-eex) (maintained by @connorlay)
|
||||
- [x] [elixir](https://github.com/elixir-lang/tree-sitter-elixir) (maintained by @connorlay)
|
||||
@ -224,7 +230,9 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [ ] [embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template)
|
||||
- [x] [erlang](https://github.com/WhatsApp/tree-sitter-erlang) (maintained by @filmor)
|
||||
- [x] [facility](https://github.com/FacilityApi/tree-sitter-facility) (maintained by @bryankenote)
|
||||
- [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD)
|
||||
- [x] [faust](https://github.com/khiner/tree-sitter-faust) (maintained by @khiner)
|
||||
- [x] [fennel](https://github.com/alexmozaidze/tree-sitter-fennel) (maintained by @alexmozaidze)
|
||||
- [x] [fidl](https://github.com/google/tree-sitter-fidl) (maintained by @chaopeng)
|
||||
- [x] [firrtl](https://github.com/amaanq/tree-sitter-firrtl) (maintained by @amaanq)
|
||||
- [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z)
|
||||
- [x] [foam](https://github.com/FoamScience/tree-sitter-foam) (experimental, maintained by @FoamScience)
|
||||
@ -234,6 +242,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq)
|
||||
- [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn)
|
||||
- [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @PrestonKnopp)
|
||||
- [x] [gdshader](https://github.com/GodOfAvacyn/tree-sitter-gdshader) (maintained by @godofavacyn)
|
||||
- [x] [git_config](https://github.com/the-mikedavis/tree-sitter-git-config) (maintained by @amaanq)
|
||||
- [x] [git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) (maintained by @gbprod)
|
||||
- [x] [gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) (maintained by @ObserverOfTime)
|
||||
@ -243,14 +252,17 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [Glimmer and Ember](https://github.com/alexlafroscia/tree-sitter-glimmer) (maintained by @NullVoxPopuli)
|
||||
- [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta)
|
||||
- [x] [GN (Generate Ninja)](https://github.com/amaanq/tree-sitter-gn) (maintained by @amaanq)
|
||||
- [x] [gnuplot](https://github.com/dpezto/tree-sitter-gnuplot) (maintained by @dpezto)
|
||||
- [x] [go](https://github.com/tree-sitter/tree-sitter-go) (maintained by @theHamsta, @WinWisely268)
|
||||
- [x] [goctl](https://github.com/chaozwn/tree-sitter-goctl) (maintained by @chaozwn)
|
||||
- [x] [Godot Resources (gdresource)](https://github.com/PrestonKnopp/tree-sitter-godot-resource) (maintained by @pierpo)
|
||||
- [x] [gomod](https://github.com/camdencheek/tree-sitter-go-mod) (maintained by @camdencheek)
|
||||
- [x] [gosum](https://github.com/amaanq/tree-sitter-go-sum) (maintained by @amaanq)
|
||||
- [x] [gotmpl](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin)
|
||||
- [x] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc)
|
||||
- [x] [gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) (maintained by @ObserverOfTime)
|
||||
- [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley)
|
||||
- [x] [groovy](https://github.com/Decodetalkers/tree-sitter-groovy) (maintained by @Decodetalkers)
|
||||
- [x] [groovy](https://github.com/murtaza64/tree-sitter-groovy) (maintained by @murtaza64)
|
||||
- [x] [gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) (maintained by @theHamsta)
|
||||
- [ ] [hack](https://github.com/slackhq/tree-sitter-hack)
|
||||
- [x] [hare](https://github.com/amaanq/tree-sitter-hare) (maintained by @amaanq)
|
||||
@ -258,15 +270,20 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) (maintained by @lykahb)
|
||||
- [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
|
||||
- [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay)
|
||||
- [x] [helm](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin)
|
||||
- [x] [hjson](https://github.com/winston0410/tree-sitter-hjson) (maintained by @winston0410)
|
||||
- [x] [hlsl](https://github.com/theHamsta/tree-sitter-hlsl) (maintained by @theHamsta)
|
||||
- [x] [hlsplaylist](https://github.com/Freed-Wu/tree-sitter-hlsplaylist) (maintained by @Freed-Wu)
|
||||
- [x] [hocon](https://github.com/antosha417/tree-sitter-hocon) (maintained by @antosha417)
|
||||
- [x] [hoon](https://github.com/urbit-pilled/tree-sitter-hoon) (experimental, maintained by @urbit-pilled)
|
||||
- [x] [html](https://github.com/tree-sitter/tree-sitter-html) (maintained by @TravonteD)
|
||||
- [x] [htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) (experimental, maintained by @ObserverOfTime)
|
||||
- [x] [http](https://github.com/rest-nvim/tree-sitter-http) (maintained by @amaanq)
|
||||
- [x] [http](https://github.com/rest-nvim/tree-sitter-http) (maintained by @amaanq, @NTBBloodbath)
|
||||
- [x] [hurl](https://github.com/pfeiferj/tree-sitter-hurl) (maintained by @pfeiferj)
|
||||
- [x] [hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) (maintained by @luckasRanarison)
|
||||
- [x] [idl](https://github.com/cathaysia/tree-sitter-idl) (maintained by @cathaysia)
|
||||
- [x] [ini](https://github.com/justinmk/tree-sitter-ini) (experimental, maintained by @theHamsta)
|
||||
- [x] [inko](https://github.com/inko-lang/tree-sitter-inko) (maintained by @yorickpeterse)
|
||||
- [x] [ispc](https://github.com/fab4100/tree-sitter-ispc) (maintained by @fab4100)
|
||||
- [x] [janet_simple](https://github.com/sogaiu/tree-sitter-janet-simple) (maintained by @sogaiu)
|
||||
- [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f)
|
||||
@ -278,15 +295,18 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo)
|
||||
- [x] [jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) (maintained by @nawordar)
|
||||
- [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @theHamsta)
|
||||
- [x] [just](https://github.com/IndianBoy42/tree-sitter-just) (maintained by @Hubro)
|
||||
- [x] [kconfig](https://github.com/amaanq/tree-sitter-kconfig) (maintained by @amaanq)
|
||||
- [x] [kdl](https://github.com/amaanq/tree-sitter-kdl) (maintained by @amaanq)
|
||||
- [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa)
|
||||
- [x] [koto](https://github.com/koto-lang/tree-sitter-koto) (maintained by @irh)
|
||||
- [x] [kusto](https://github.com/Willem-J-an/tree-sitter-kusto) (maintained by @Willem-J-an)
|
||||
- [x] [lalrpop](https://github.com/traxys/tree-sitter-lalrpop) (maintained by @traxys)
|
||||
- [x] [latex](https://github.com/latex-lsp/tree-sitter-latex) (maintained by @theHamsta, @clason)
|
||||
- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete)
|
||||
- [x] [leo](https://github.com/r001/tree-sitter-leo) (maintained by @r001)
|
||||
- [x] [linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) (maintained by @amaanq)
|
||||
- [x] [liquid](https://github.com/hankthetank27/tree-sitter-liquid) (maintained by @hankthetank27)
|
||||
- [x] [liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) (maintained by @toots)
|
||||
- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham)
|
||||
- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim)
|
||||
@ -302,7 +322,9 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [ ] [mermaid](https://github.com/monaqa/tree-sitter-mermaid) (experimental)
|
||||
- [x] [meson](https://github.com/Decodetalkers/tree-sitter-meson) (maintained by @Decodetalkers)
|
||||
- [x] [mlir](https://github.com/artagnon/tree-sitter-mlir) (experimental, maintained by @artagnon)
|
||||
- [x] [muttrc](https://github.com/neomutt/tree-sitter-muttrc) (maintained by @Freed-Wu)
|
||||
- [x] [nasm](https://github.com/naclsn/tree-sitter-nasm) (maintained by @ObserverOfTime)
|
||||
- [x] [nginx](https://github.com/opa-oz/tree-sitter-nginx) (maintained by @opa-oz)
|
||||
- [ ] [nickel](https://github.com/nickel-lang/tree-sitter-nickel)
|
||||
- [x] [nim](https://github.com/alaviss/tree-sitter-nim) (maintained by @aMOPel)
|
||||
- [x] [nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) (maintained by @aMOPel)
|
||||
@ -317,20 +339,24 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu)
|
||||
- [x] [odin](https://github.com/amaanq/tree-sitter-odin) (maintained by @amaanq)
|
||||
- [ ] [org](https://github.com/milisims/tree-sitter-org)
|
||||
- [x] [pascal](https://github.com/Isopod/tree-sitter-pascal.git) (maintained by @Isopod)
|
||||
- [x] [pascal](https://github.com/Isopod/tree-sitter-pascal) (maintained by @Isopod)
|
||||
- [x] [passwd](https://github.com/ath3/tree-sitter-passwd) (maintained by @amaanq)
|
||||
- [x] [pem](https://github.com/ObserverOfTime/tree-sitter-pem) (maintained by @ObserverOfTime)
|
||||
- [x] [perl](https://github.com/tree-sitter-perl/tree-sitter-perl) (maintained by @RabbiVeesh, @LeoNerd)
|
||||
- [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka)
|
||||
- [x] [php_only](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka)
|
||||
- [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl)
|
||||
- [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228)
|
||||
- [x] [po](https://github.com/erasin/tree-sitter-po) (maintained by @amaanq)
|
||||
- [x] [pod](https://github.com/tree-sitter-perl/tree-sitter-pod) (maintained by @RabbiVeesh, @LeoNerd)
|
||||
- [x] [Path of Exile item filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter) (experimental, maintained by @ObserverOfTime)
|
||||
- [x] [pony](https://github.com/amaanq/tree-sitter-pony) (maintained by @amaanq, @mfelsche)
|
||||
- [x] [printf](https://github.com/ObserverOfTime/tree-sitter-printf) (maintained by @ObserverOfTime)
|
||||
- [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva)
|
||||
- [x] [problog](https://github.com/foxyseta/tree-sitter-prolog) (maintained by @foxyseta)
|
||||
- [x] [prolog](https://github.com/foxyseta/tree-sitter-prolog) (maintained by @foxyseta)
|
||||
- [x] [promql](https://github.com/MichaHoffmann/tree-sitter-promql) (maintained by @MichaHoffmann)
|
||||
- [x] [properties](https://github.com/ObserverOfTime/tree-sitter-properties) (maintained by @ObserverOfTime)
|
||||
- [x] [properties](https://github.com/tree-sitter-grammars/tree-sitter-properties) (maintained by @ObserverOfTime)
|
||||
- [x] [proto](https://github.com/treywood/tree-sitter-proto) (maintained by @treywood)
|
||||
- [x] [prql](https://github.com/PRQL/tree-sitter-prql) (maintained by @matthias-Q)
|
||||
- [x] [psv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq)
|
||||
@ -343,33 +369,38 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [qmldir](https://github.com/Decodetalkers/tree-sitter-qmldir) (maintained by @amaanq)
|
||||
- [x] [qmljs](https://github.com/yuja/tree-sitter-qmljs) (maintained by @Decodetalkers)
|
||||
- [x] [Tree-Sitter query language](https://github.com/nvim-treesitter/tree-sitter-query) (maintained by @steelsojka)
|
||||
- [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @echasnovski)
|
||||
- [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @ribru17)
|
||||
- [ ] [racket](https://github.com/6cdh/tree-sitter-racket)
|
||||
- [x] [ralph](https://github.com/alephium/tree-sitter-ralph) (maintained by @tdroxler)
|
||||
- [x] [rasi](https://github.com/Fymyte/tree-sitter-rasi) (maintained by @Fymyte)
|
||||
- [x] [rbs](https://github.com/joker1007/tree-sitter-rbs) (maintained by @joker1007)
|
||||
- [x] [re2c](https://github.com/amaanq/tree-sitter-re2c) (maintained by @amaanq)
|
||||
- [x] [readline](https://github.com/ribru17/tree-sitter-readline) (maintained by @ribru17)
|
||||
- [x] [regex](https://github.com/tree-sitter/tree-sitter-regex) (maintained by @theHamsta)
|
||||
- [x] [rego](https://github.com/FallenAngel97/tree-sitter-rego) (maintained by @FallenAngel97)
|
||||
- [x] [pip requirements](https://github.com/ObserverOfTime/tree-sitter-requirements) (maintained by @ObserverOfTime)
|
||||
- [x] [rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) (maintained by @bamonroe)
|
||||
- [x] [robot](https://github.com/Hubro/tree-sitter-robot) (maintained by @Hubro)
|
||||
- [x] [robots](https://github.com/opa-oz/tree-sitter-robots-txt) (maintained by @opa-oz)
|
||||
- [x] [roc](https://github.com/faldor20/tree-sitter-roc) (maintained by @nat-418)
|
||||
- [x] [ron](https://github.com/amaanq/tree-sitter-ron) (maintained by @amaanq)
|
||||
- [x] [rst](https://github.com/stsewd/tree-sitter-rst) (maintained by @stsewd)
|
||||
- [x] [ruby](https://github.com/tree-sitter/tree-sitter-ruby) (maintained by @TravonteD)
|
||||
- [x] [rust](https://github.com/tree-sitter/tree-sitter-rust) (maintained by @amaanq)
|
||||
- [x] [scala](https://github.com/tree-sitter/tree-sitter-scala) (maintained by @stevanmilic)
|
||||
- [x] [scfg](https://git.sr.ht/~rockorager/tree-sitter-scfg) (maintained by @WhyNotHugo)
|
||||
- [x] [scfg](https://github.com/rockorager/tree-sitter-scfg) (maintained by @WhyNotHugo)
|
||||
- [ ] [scheme](https://github.com/6cdh/tree-sitter-scheme)
|
||||
- [x] [scss](https://github.com/serenadeai/tree-sitter-scss) (maintained by @elianiva)
|
||||
- [x] [slang](https://github.com/theHamsta/tree-sitter-slang) (experimental, maintained by @theHamsta)
|
||||
- [x] [slint](https://github.com/jrmoulton/tree-sitter-slint) (experimental, maintained by @jrmoulton)
|
||||
- [x] [smali](https://git.sr.ht/~yotam/tree-sitter-smali) (maintained by @amaanq)
|
||||
- [x] [slint](https://github.com/slint-ui/tree-sitter-slint) (maintained by @hunger)
|
||||
- [x] [smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) (maintained by @amaanq)
|
||||
- [x] [smithy](https://github.com/indoorvivants/tree-sitter-smithy) (maintained by @amaanq, @keynmol)
|
||||
- [ ] [snakemake](https://github.com/osthomas/tree-sitter-snakemake) (experimental)
|
||||
- [x] [solidity](https://github.com/JoranHonig/tree-sitter-solidity) (maintained by @amaanq)
|
||||
- [x] [soql](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber)
|
||||
- [x] [sosl](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber)
|
||||
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis)
|
||||
- [x] [sourcepawn](https://github.com/nilshelmig/tree-sitter-sourcepawn) (maintained by @Sarrus1)
|
||||
- [x] [sparql](https://github.com/GordianDziwis/tree-sitter-sparql) (maintained by @GordianDziwis)
|
||||
- [x] [sql](https://github.com/derekstride/tree-sitter-sql) (maintained by @derekstride)
|
||||
- [x] [squirrel](https://github.com/amaanq/tree-sitter-squirrel) (maintained by @amaanq)
|
||||
- [x] [ssh_config](https://github.com/ObserverOfTime/tree-sitter-ssh-config) (maintained by @ObserverOfTime)
|
||||
@ -378,12 +409,15 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [styled](https://github.com/mskelton/tree-sitter-styled) (maintained by @mskelton)
|
||||
- [x] [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) (maintained by @madskjeldgaard)
|
||||
- [x] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay)
|
||||
- [x] [svelte](https://github.com/Himujjal/tree-sitter-svelte) (maintained by @elianiva)
|
||||
- [x] [svelte](https://github.com/tree-sitter-grammars/tree-sitter-svelte) (maintained by @amaanq)
|
||||
- [x] [swift](https://github.com/alex-pinkus/tree-sitter-swift) (maintained by @alex-pinkus)
|
||||
- [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki)
|
||||
- [x] [systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) (maintained by @ok-ryoko)
|
||||
- [x] [systemverilog](https://github.com/zhangwwpeng/tree-sitter-systemverilog) (maintained by @zhangwwpeng)
|
||||
- [x] [t32](https://gitlab.com/xasc/tree-sitter-t32.git) (maintained by @xasc)
|
||||
- [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq)
|
||||
- [x] [tact](https://github.com/tact-lang/tree-sitter-tact) (maintained by @novusnota)
|
||||
- [x] [tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) (maintained by @lewis6991)
|
||||
- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce)
|
||||
- [x] [templ](https://github.com/vrischmann/tree-sitter-templ) (maintained by @vrischmann)
|
||||
- [x] [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
|
||||
@ -391,34 +425,41 @@ We are looking for maintainers to add more parsers and to write query files for
|
||||
- [x] [thrift](https://github.com/duskmoon314/tree-sitter-thrift) (maintained by @amaanq, @duskmoon314)
|
||||
- [x] [tiger](https://github.com/ambroisie/tree-sitter-tiger) (maintained by @ambroisie)
|
||||
- [x] [tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) (maintained by @ahelwer, @susliko)
|
||||
- [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) (experimental, maintained by @arnarg)
|
||||
- [x] [toml](https://github.com/ikatyang/tree-sitter-toml) (maintained by @tk-shirasaka)
|
||||
- [x] [tmux](https://github.com/Freed-Wu/tree-sitter-tmux) (maintained by @Freed-Wu)
|
||||
- [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt) (experimental, maintained by @arnarg)
|
||||
- [x] [toml](https://github.com/tree-sitter-grammars/tree-sitter-toml) (maintained by @tk-shirasaka)
|
||||
- [x] [tsv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq)
|
||||
- [x] [tsx](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [turtle](https://github.com/BonaBeavis/tree-sitter-turtle) (maintained by @BonaBeavis)
|
||||
- [x] [turtle](https://github.com/GordianDziwis/tree-sitter-turtle) (maintained by @GordianDziwis)
|
||||
- [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod)
|
||||
- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [typespec](https://github.com/happenslol/tree-sitter-typespec) (maintained by @happenslol)
|
||||
- [x] [typoscript](https://github.com/Teddytrombone/tree-sitter-typoscript) (maintained by @Teddytrombone)
|
||||
- [x] [typst](https://github.com/uben0/tree-sitter-typst) (maintained by @uben0, @RaafatTurki)
|
||||
- [x] [udev](https://github.com/ObserverOfTime/tree-sitter-udev) (maintained by @ObserverOfTime)
|
||||
- [x] [ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) (maintained by @Philipp-M, @amaanq)
|
||||
- [x] [unison](https://github.com/kylegoetz/tree-sitter-unison) (maintained by @tapegram)
|
||||
- [x] [usd](https://github.com/ColinKennedy/tree-sitter-usd) (maintained by @ColinKennedy)
|
||||
- [x] [uxn tal](https://github.com/amaanq/tree-sitter-uxntal) (maintained by @amaanq)
|
||||
- [x] [v](https://github.com/v-analyzer/v-analyzer) (maintained by @kkharji, @amaanq)
|
||||
- [x] [v](https://github.com/vlang/v-analyzer) (maintained by @kkharji, @amaanq)
|
||||
- [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781)
|
||||
- [x] [vento](https://github.com/ventojs/tree-sitter-vento) (maintained by @wrapperup, @oscarotero)
|
||||
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv)
|
||||
- [x] [vhdl](https://github.com/jpt13653903/tree-sitter-vhdl) (maintained by @jpt13653903)
|
||||
- [x] [vhs](https://github.com/charmbracelet/tree-sitter-vhs) (maintained by @caarlos0)
|
||||
- [x] [vim](https://github.com/neovim/tree-sitter-vim) (maintained by @clason)
|
||||
- [x] [vimdoc](https://github.com/neovim/tree-sitter-vimdoc) (maintained by @clason)
|
||||
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
|
||||
- [x] [vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) (maintained by @WhyNotHugo, @lucario387)
|
||||
- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok)
|
||||
- [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta)
|
||||
- [x] [wing](https://github.com/winglang/wing) (experimental, maintained by @gshpychka, @MarkMcCulloh)
|
||||
- [x] [wing](https://github.com/winglang/tree-sitter-wing) (maintained by @gshpychka, @MarkMcCulloh)
|
||||
- [x] [wit](https://github.com/liamwh/tree-sitter-wit) (maintained by @liamwh)
|
||||
- [x] [xcompose](https://github.com/ObserverOfTime/tree-sitter-xcompose) (maintained by @ObserverOfTime)
|
||||
- [x] [xml](https://github.com/ObserverOfTime/tree-sitter-xml) (maintained by @ObserverOfTime)
|
||||
- [x] [yaml](https://github.com/ikatyang/tree-sitter-yaml) (maintained by @stsewd)
|
||||
- [x] [xml](https://github.com/tree-sitter-grammars/tree-sitter-xml) (maintained by @ObserverOfTime)
|
||||
- [x] [yaml](https://github.com/tree-sitter-grammars/tree-sitter-yaml) (maintained by @amaanq)
|
||||
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
|
||||
- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq)
|
||||
- [x] [zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) (maintained by @Freed-Wu)
|
||||
- [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino)
|
||||
<!--parserinfo-->
|
||||
|
||||
@ -497,12 +538,11 @@ require'nvim-treesitter.configs'.setup {
|
||||
|
||||
#### Folding
|
||||
|
||||
Tree-sitter based folding. _(Technically not a module because it's per windows and not per buffer.)_
|
||||
Tree-sitter based folding (implemented in Neovim itself, see `:h vim.treesitter.foldexpr()`). To enable it for the current window, set
|
||||
|
||||
```vim
|
||||
set foldmethod=expr
|
||||
set foldexpr=nvim_treesitter#foldexpr()
|
||||
set nofoldenable " Disable folding at startup.
|
||||
```lua
|
||||
vim.wo.foldmethod = 'expr'
|
||||
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
```
|
||||
|
||||
This will respect your `foldminlines` and `foldnestmax` settings.
|
||||
@ -515,11 +555,13 @@ If you want to install the parsers to a custom directory you can specify this
|
||||
directory with `parser_install_dir` option in that is passed to `setup`.
|
||||
`nvim-treesitter` will then install the parser files into this directory.
|
||||
|
||||
This directory must be writeable and must be explicitly added to the
|
||||
This directory must be writeable and must be explicitly prepended to the
|
||||
`runtimepath`. For example:
|
||||
|
||||
```lua
|
||||
vim.opt.runtimepath:append("/some/path/to/store/parsers")
|
||||
-- It MUST be at the beginning of runtimepath. Otherwise the parsers from Neovim itself
|
||||
-- is loaded that may not be compatible with the queries from the 'nvim-treesitter' plugin.
|
||||
vim.opt.runtimepath:prepend("/some/path/to/store/parsers")
|
||||
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
parser_install_dir = "/some/path/to/store/parsers",
|
||||
@ -595,18 +637,18 @@ like the `queries` folder of this plugin, e.g. `queries/{language}/{locals,highl
|
||||
Other modules may require additional queries such as `folding.scm`. You can find a
|
||||
list of all supported capture names in [CONTRIBUTING.md](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations).
|
||||
|
||||
All queries found in the runtime directories will be combined.
|
||||
By convention, if you want to write a query, use the `queries/` directory,
|
||||
but if you want to extend a query use the `after/queries/` directory.
|
||||
The first query file on `runtimepath` will be used (see `:h treesitter-query`).
|
||||
If you want to make a query on the user config extend other queries instead of
|
||||
replacing them, see `:h treesitter-query-modeline-extends`.
|
||||
|
||||
If you want to completely override a query, you can use `:h set_query()`.
|
||||
If you want to completely override a query, you can use `:h vim.treesitter.query.set()`.
|
||||
For example, to override the `injections` queries from `c` with your own:
|
||||
|
||||
```lua
|
||||
require("vim.treesitter.query").set_query("c", "injections", "(comment) @comment")
|
||||
vim.treesitter.query.set("c", "injections", "(comment) @comment")
|
||||
```
|
||||
|
||||
Note: when using `set_query`, all queries in the runtime directories will be ignored.
|
||||
Note: when using `query.set()`, all queries in the runtime directories will be ignored.
|
||||
|
||||
## Adding modules
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -24,4 +24,16 @@ function M.get_node_text(node, bufnr)
|
||||
return (ts.get_node_text or tsq.get_node_text)(node, bufnr)
|
||||
end
|
||||
|
||||
function M.require_language(lang, opts)
|
||||
return (ts.language.add or ts.language.require_language)(lang, opts)
|
||||
end
|
||||
|
||||
function M.flatten(t)
|
||||
if vim.fn.has "nvim-0.11" == 1 then
|
||||
return vim.iter(t):flatten():totable()
|
||||
else
|
||||
return vim.tbl_flatten(t)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -23,8 +23,8 @@ local NVIM_TREESITTER_MINIMUM_ABI = 13
|
||||
local function install_health()
|
||||
_start "Installation"
|
||||
|
||||
if fn.has "nvim-0.9.1" ~= 1 then
|
||||
_error "Nvim-treesitter requires Neovim 0.9.1+"
|
||||
if fn.has "nvim-0.9.2" ~= 1 then
|
||||
_error "Nvim-treesitter requires Nvim 0.9.2 or newer"
|
||||
end
|
||||
|
||||
if fn.executable "tree-sitter" == 0 then
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user