aboutsummaryrefslogtreecommitdiff
path: root/nvim/lua/config/treesitter.lua
blob: 948365354341dada9cb96bde981915c871b77a73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local M = {}

-- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/SUPPORTED_LANGUAGES.md
M.languages = {
  "bash",
  "c",
  "cpp",
  "html",
  "javascript",
  -- "jinja",
  -- "jinja_inline",
  "jq",
  "json", -- deckt auch den Dateityp jsonc ab (siehe lua/config/filetypes.lua)
  "lua",
  "make",
  "markdown",
  "markdown_inline",
  "po",
  "powershell",
  "prisma",
  "python",
  "typescript",
  "vim",
  "vimdoc",
  "xml",
  "yaml",
  "zsh",
}

-- Filetypes ohne gleichnamigen Parser, samt Parser, den sie nutzen sollen.
local extra_filetypes = {
  -- nvim-treesitter stellt keinen jsonc-Parser bereit; der json-Parser
  -- versteht // und /* */ Kommentare.
  jsonc = "json",
}

-- Macht die Parser der Filetypes ohne gleichnamigen Parser bekannt.
function M.register_extra_filetypes()
  for filetype, parser in pairs(extra_filetypes) do
    vim.treesitter.language.register(parser, filetype)
  end
end

-- Filetypes, fuer die Treesitter-Features aktiviert werden.
function M.filetypes()
  local filetypes = {}

  for _, language in ipairs(M.languages) do
    table.insert(filetypes, language)
  end

  for filetype in pairs(extra_filetypes) do
    table.insert(filetypes, filetype)
  end

  return filetypes
end

return M