diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua index c8566be..eb80ad8 100644 --- a/after/ftplugin/markdown.lua +++ b/after/ftplugin/markdown.lua @@ -3,4 +3,12 @@ -- See :h awa vim.opt.awa=true -vim.opt.foldlevel = 1 +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'markdown' }, + callback = function () + vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.wo.foldmethod = 'expr' + vim.opt.foldlevel = 1 + -- indentation, provided by nvim-treesitter + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index cfe3874..33b1eec 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -21,109 +21,69 @@ return { dependencies = { "nvim-treesitter/nvim-treesitter-textobjects", }, - build = ":TSUpdate", + lazy = false, + build = ":TSUpdate", -- Configure treesitter - config = function() - ---@diagnostic disable-next-line: missing-fields - local config = require("nvim-treesitter.config") + config = function () + local treesitter = require('nvim-treesitter') + treesitter.setup() + treesitter.install({ + 'bash', + 'css', + 'dot', + 'gitignore', + 'html', + 'javascript', + 'json', + 'julia', + 'latex', + 'lua', + 'markdown', + 'markdown_inline', + 'mermaid', + 'norg', + 'python', + 'query', + 'r', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', + }) - config.setup({ - -- Enable color syntax - highlight = { - enable = true, - disable = { - "markdown" - }, - }, - -- Enable better indentation management - indent = { enable = true }, + vim.api.nvim_create_autocmd('FileType', { + pattern = { + 'bash', + 'css', + 'dot', + 'gitignore', + 'html', + 'javascript', + 'json', + 'julia', + 'latex', + 'lua', + 'mermaid', + 'norg', + 'python', + 'query', + 'r', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', + }, + callback = function() + -- syntax highlighting, provided by Neovim + vim.treesitter.start() + -- folds, provided by Neovim + vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.wo.foldmethod = 'expr' + -- indentation, provided by nvim-treesitter + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, + }) - -- Installed and configured languages - ensure_installed = { - "bash", - "css", - "dot", - "gitignore", - "html", - "javascript", - "json", - "julia", - "latex", - "lua", - "markdown", - "markdown_inline", - "mermaid", - "norg", - "python", - "query", - "r", - "typescript", - "vim", - "vimdoc", - "yaml", - }, - - -- Do not install parses synchronously - sync_install = false, - - -- Do not install automatically missing parsers - auto_install = false, - - -- select the current bloc - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - }) - end, + end }