dotfiles/nvim/.config/nvim/lua/plugins/treesitter.lua
Marty Oehme f33b4c9c37
nvim: Restructure lua dir
Moved plugins into individual component module files which are
automatically required by lazy.nvim. Should make everything a tiny bit
more modular, or at least prepare the way for true modularity if I ever
have the time on my hands to ensure everything works with missing
modules.

Moved core settings into their own directory (`core`), and created a
`personal` folder which contains functions/plugins I wrote that do not
necessarily have to be their own imported plugin yet.

Finally, extended the utility functions a little, so we can detect if a
plugin exists and change e.g. key maps based on that (once again,
extending modularity a little more). Some simple attempts have been made
at that in the `mappings.lua` file, though it is nowhere near extensive
yet - most keymaps are still set regardless of plugin availability.

However, with this slimmer base to work off of, I feel more confident in
changing future things about this setup a little more ad-hoc without
having as many ripple repercussions as before.
2023-06-17 21:54:22 +02:00

73 lines
1.9 KiB
Lua

return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local rainbow = require("ts-rainbow")
require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all",
highlight = {
enable = true,
disable = function(_, bufnr)
return vim.api.nvim_buf_line_count(bufnr) > 7000
end,
},
incremental_selection = { enable = true },
textobjects = { enable = true },
indent = { enable = true },
autotag = { enable = true },
-- enable rainbow brackets, needs p00f/nvim-ts-rainbow
rainbow = {
enable = true,
strategy = { rainbow.strategy.global },
},
-- for improved commentstrings, needs corresponding plugin
context_commentstring = {
enable = true,
enable_autocmd = false, -- since we run it as a hook from the mini.comment plugin
},
-- allows using . and ; to target treesitter branches
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
},
},
})
end,
event = "BufReadPost",
cmd = {
"TSBufDisable",
"TSBufEnable",
"TSBufToggle",
"TSDisable",
"TSEnable",
"TSToggle",
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSModuleInfo",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
},
-- rainbow brackets using treesitter
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
"https://gitlab.com/HiPhish/nvim-ts-rainbow2.git",
{ "romgrk/nvim-treesitter-context", config = true },
"JoosepAlviste/nvim-ts-context-commentstring",
{
"RRethy/nvim-treesitter-textsubjects",
},
"windwp/nvim-ts-autotag",
},
},
{ "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree
}