~theonlymrcat/tree-sitter-runscript

Runscript grammar for tree-sitter
Improve documentation and queries for nvim
57039db5 — Max Guppy 2 years ago
Add README and LICENSE
49137648 — Max Guppy 2 years ago
Initial commit

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~theonlymrcat/tree-sitter-runscript
read/write
git@git.sr.ht:~theonlymrcat/tree-sitter-runscript

You can also use your local clone with git send-email.

#tree-sitter-runscript

Runscript grammar for tree-sitter.

#Installation

#Neovim

Install nvim-treesitter.

#Add the parser

Source: https://github.com/nvim-treesitter/nvim-treesitter#adding-parsers

Add the following lua code to your startup file:

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.runscript = {
  install_info = {
    url = "https://git.sr.ht/~theonlymrcat/tree-sitter-runscript",
    files = {"src/parser.c"},
    generate_requires_npm = false,
    requires_generate_from_grammar = false,
  },
  filetype = "runscript",
}

After doing this, start nvim and run :TSInstall runscript and :TSInstall bash. You only need to do this once.

#Add queries

Source: https://github.com/nvim-treesitter/nvim-treesitter#highlight

Copy the contents of queries/nvim/ into .config/nvim/queries/runscript.

#Add the filetype

Add the following lua code to your startup file:

vim.filetype.add({
  extension = {
    run = "runscript",
  },
  filename = {
    ['run'] = "runscript",
  },
})

Or the equivalent vimscript code.

#Enable tree-sitter syntax highlighting

Source: https://github.com/nvim-treesitter/nvim-treesitter#highlight

Add the following lua code to your startup file:

require'nvim-treesitter.configs'.setup {
  highlight = {
    -- Replace this with `enable = true` to enable tree-sitter highlighting for all buffers
    enable = { "runscript" },
    -- See source link for details on this option
    additional_vim_regex_highlighting = false,
  },
}

#Helix

Add the following to your languages.toml file (usually in ~/.config/helix):

[[language]]
name = "runscript"
scope = "source.runscript"
injection-regex = "^runscript$"
file-types = ["run"]
roots = []
comment-token = "#"

[[grammar]]
name = "runscript"
source = { git = "https://git.sr.ht/~theonlymrcat/tree-sitter-runscript", rev = "49137648f2932637288804d6f83f5b90e177cbca" }

Then copy the contents of queries/helix/ into runtime/queries/runscript/ (where runtime is the helix runtime directory; /var/lib/helix/runtime on Linux)

To find your runtime directory, check the first few lines of output of hx --health