require('plugins.nvim-treesitter.folding')

return {
	'nvim-treesitter/nvim-treesitter',
	version = false                  ,
	build   = ':TSUpdate'            ,
	dependencies = {
		{
			'nvim-treesitter/nvim-treesitter-textobjects',
		}
	},
	config  = function()
		local configs = require('nvim-treesitter.configs')

		configs.setup({
			highlight             = {
				enable = true,
			},
			indent                = {
				enable = true,
			},
			ensure_installed      = {
				'bash'           ,
				'c'              ,
				'cpp'            ,
				'css'            ,
				'diff'           ,
				'html'           ,
				'javascript'     ,
				'json'           ,
				'markdown'       ,
				'markdown_inline',
				'php'            ,
				'python'         ,
				'regex'          ,
				'rust'           ,
				'xml'            ,
				'vim'            ,
			},
			autotag               = {
				enable = true,
			},
			incremental_selection = {
				enable  = true,
				keymaps = {
					init_selection    = '<Leader>pts',
					node_incremental  = '<Leader>ptn',
					scope_incremental = '<Leader>pts',
					node_decremental  = '<Leader>ptd',
				}
			},
			text_objects          = {
				move = {
					enable              = true,
					set_jumps           = true,
					goto_next_start     = {
						['<Leader>mnf'] = '@function.outer',
						['<Leader>mnc'] = '@class.outer'   ,
						['<Leader>mns'] = {
							query       = '@scope'       ,
							query_group = 'locals'       ,
							desc        = 'Scope suivant',
						}                                  ,
					}                     ,
					goto_next_end       = {
						['<Leader>mnF'] = '@function.outer',
						['<Leader>mnC'] = '@class.outer'   ,
					}                     ,
					goto_previous_start = {
						['<Leader>mpf'] = '@function.outer',
						['<Leader>mpc'] = '@class.outer'   ,
						['<Leader>mns'] = {
							query       = '@scope'         ,
							query_group = 'locals'         ,
							desc        = 'Scope précédent',
						}                                  ,
					}                     ,
					goto_previous_end   = {
						['<Leader>mpF'] = '@function.outer',
						['<Leader>mpC'] = '@function.class',
					}                     ,
				},
			},
			sync_install = false,
			auto_install = true ,
		})
	end
}