<commit_before>local nvim        = require'nvim'
local load_module = require'tools'.helpers.load_module

local plugins          = nvim.plugins

local set_autocmd = nvim.autocmds.set_autocmd
-- local set_command = nvim.commands.set_command
-- local set_mapping = nvim.mappings.set_mapping

local treesitter = load_module'nvim-treesitter.configs'

if treesitter == nil then
    return false
end

local ensure_installed = {
    'c',
    'cpp',
    'lua',
    'bash',
    'python',
    'latex',
    -- 'query',
}

local disable = nil

if plugins.semshi ~= nil then
    disable = {'python'}
end

if plugins['vim-lsp-cxx-highlight'] ~= nil then
    disable = disable == nil and {'c', 'cpp'} or vim.list_extend(disable, {'c', 'cpp'})
end

local commet_txtobj = nil
if plugins['vim-textobj-comment'] == nil then
    commet_txtobj = '@comment.outer'
end

treesitter.setup{
    ensure_installed = ensure_installed,
    indent = {
        enable = true,
    },
    highlight = {
        enable = true,
        disable = disable,
    },
    textobjects = {
        swap = {
            enable = true,
            swap_next = {
                ["<leader>a"] = "@parameter.inner",
                ["<leader>m"] = "@function.outer",
            },
            swap_previous = {
                ["<leader><leader>a"] = "@parameter.inner",
                ["<leader><leader>m"] = "@function.outer",
            },
        },
        select = {
            enable = true,
            keymaps = {
                ["af"] = "@conditional.outer",
                ["if"] = "@conditional.inner",
                ["am"] = "@function.outer",    -- Same as [m, ]m "method"
                ["im"] = "@function.inner",
                ["as"] = "@class.outer",<commit_msg>feat: Add treesitter incremental selection<commit_after>local nvim        = require'nvim'
local load_module = require'tools'.helpers.load_module

local plugins          = nvim.plugins

local set_autocmd = nvim.autocmds.set_autocmd
-- local set_command = nvim.commands.set_command
-- local set_mapping = nvim.mappings.set_mapping

local treesitter = load_module'nvim-treesitter.configs'

if treesitter == nil then
    return false
end

local ensure_installed = {
    'c',
    'cpp',
    'lua',
    'bash',
    'python',
    'latex',
    -- 'query',
}

local disable = nil

if plugins.semshi ~= nil then
    disable = {'python'}
end

if plugins['vim-lsp-cxx-highlight'] ~= nil then
    disable = disable == nil and {'c', 'cpp'} or vim.list_extend(disable, {'c', 'cpp'})
end

local commet_txtobj = nil
if plugins['vim-textobj-comment'] == nil then
    commet_txtobj = '@comment.outer'
end

treesitter.setup{
    ensure_installed = ensure_installed,
    indent = {
        enable = true,
    },
    incremental_selection = {
        enable = true,
        keymaps = {
            init_selection = "<A-i>",
            node_incremental = "<A-I>",
            scope_incremental = "<A-c>",
            node_decremental = "<A-D>",
        },
    },
    highlight = {
        enable = true,
        disable = disable,
    },
    textobjects = {
        swap = {
            enable = true,
            swap_next = {
                ["<leader>a"] = "@parameter.inner",
                ["<leader>m"] = "@function.outer",
            },
            swap_previous = {
                ["<leader><leader>a"] = "@parameter.inner",
                ["<leader><leader>m"] = "@function.outer",
            },
        },
        select = {
            enable = true,
            keymaps = {
                ["af"] = "@conditional.outer",
                ["if"] = "@conditional.inner",
                ["am"] = "@function.outer",    -- Same as [m, ]m "method"
                ["im"] = "@function.inner",
                ["as"] = "@class.outer",
{'fraction_non_alphanumeric': 0.14908317831517406, 'fraction_numerical': 0.0, 'mean_word_length': 1.93603744149766, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '784296', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1142, 'n_words': 247}