.files/.config/nvim/after/plugin/treesitter.lua

56 lines
1.5 KiB
Lua

require("nvim-treesitter.configs").setup {
ensure_installed = {
-- funny language hehe
"haskell",
"rust",
"nix",
-- vim
"lua",
-- misc
"html",
"scss",
"css",
"json",
},
ignore_install = { "typst", "markdown" },
sync_install = false,
auto_install = true,
highlight = { enable = true },
-- Disable for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then return true end
end,
-- Text objets
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},
include_surrounding_whitespace = true,
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
},
}