73 lines
1.7 KiB
Lua
73 lines
1.7 KiB
Lua
-- Due to the complete infrastructure change in nvim-tressiter
|
|
-- this file exists to install all the languages I want
|
|
-- and then make sure that treesitter support is enabled for them
|
|
|
|
--- This is a mapping of parsers to filetypes
|
|
--- where the parser name and filetype is the same we leave the filetype blank
|
|
--- otherwise the filetype is the filetype(s) that the parser should be used in
|
|
local languages = {
|
|
["bash"] = "",
|
|
["c"] = "",
|
|
["cpp"] = "",
|
|
["css"] = "",
|
|
["c_sharp"] = "",
|
|
["diff"] = "",
|
|
["git_config"] = "gitconfig",
|
|
["git_rebase"] = "",
|
|
["gitcommit"] = "",
|
|
["gitignore"] = "",
|
|
["go"] = "",
|
|
["gomod"] = "",
|
|
["html"] = "",
|
|
["ini"] = "",
|
|
["javascript"] = "",
|
|
["jsonnet"] = "",
|
|
["latex"] = "",
|
|
["lua"] = "",
|
|
["luadoc"] = "",
|
|
["luap"] = "",
|
|
["make"] = "",
|
|
["markdown"] = "",
|
|
["markdown_inline"] = "markdown",
|
|
["python"] = "",
|
|
["query"] = "",
|
|
["regex"] = "",
|
|
["rust"] = "",
|
|
["scss"] = "",
|
|
["typst"] = "",
|
|
["toml"] = "",
|
|
["vim"] = "",
|
|
["vimdoc"] = "",
|
|
["yuck"] = "",
|
|
["yaml"] = "",
|
|
["zig"] = "",
|
|
}
|
|
|
|
local parsers = {}
|
|
local filetypes = {}
|
|
local TS = require("nvim-treesitter")
|
|
|
|
for parser, filetype in pairs(languages) do
|
|
if filetype == "" then
|
|
table.insert(filetypes, parser)
|
|
else
|
|
table.insert(filetypes, parser)
|
|
end
|
|
table.insert(parsers, parser)
|
|
end
|
|
TS.install(parsers, { summary = true })
|
|
|
|
local all_parsers = TS.get_installed()
|
|
|
|
local alltype = vim.tbl_extend("force", filetypes, all_parsers)
|
|
|
|
vim.api.nvim_create_augroup("ts-augroup", {})
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = alltype,
|
|
callback = function()
|
|
vim.treesitter.start()
|
|
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
|
require("treesitter-context").enable()
|
|
end,
|
|
})
|