From b09dc7e7480d4b2c880def347d0d8c253bc6c64c Mon Sep 17 00:00:00 2001 From: iGor milhit Date: Wed, 18 Feb 2026 20:01:36 +0100 Subject: [PATCH] plugins: update the treesitter configuration - Updates the treesitter configruation according to the API documentation. - Updates the mkdnflow configuration according to the documentation. - Forces the filetype of *.md files before mkdnflow is loaded. Co-Authored-by: iGor milhit --- after/ftplugin/markdown.lua | 1 - after/ftplugin/pandoc.lua | 2 - lua/core/init.lua | 1 + lua/core/set-md-filetype.lua | 9 ++ lua/plugins/markdown/mkdnflow.lua | 8 +- lua/plugins/markdown/pandoc.lua | 13 +-- lua/plugins/treesitter.lua | 158 +++++++++++------------------- 7 files changed, 77 insertions(+), 115 deletions(-) create mode 100644 lua/core/set-md-filetype.lua diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua index c8566be..bacf62f 100644 --- a/after/ftplugin/markdown.lua +++ b/after/ftplugin/markdown.lua @@ -3,4 +3,3 @@ -- See :h awa vim.opt.awa=true -vim.opt.foldlevel = 1 diff --git a/after/ftplugin/pandoc.lua b/after/ftplugin/pandoc.lua index 6da8148..8a2ff02 100644 --- a/after/ftplugin/pandoc.lua +++ b/after/ftplugin/pandoc.lua @@ -3,5 +3,3 @@ -- See :h awa vim.opt.awa=true --- vim.opt.foldlevel = 1 --- vim.opt.conceallevel = 2 diff --git a/lua/core/init.lua b/lua/core/init.lua index 794a20b..bd470d4 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,3 +1,4 @@ -- Load all module files +require("core.set-md-filetype") require("core.keymaps") require("core.options") diff --git a/lua/core/set-md-filetype.lua b/lua/core/set-md-filetype.lua new file mode 100644 index 0000000..8811d73 --- /dev/null +++ b/lua/core/set-md-filetype.lua @@ -0,0 +1,9 @@ +-- Ensure vim-pandoc sets the filetype +-- This is a workaround to avoid that during the mkdnflow loading, neovim +-- sets the filetype to .md files to markdown +-- "Solution" provided by the Quick assistant of Kagi. +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + pattern = "*.md", + command = "set filetype=pandoc" +}) + diff --git a/lua/plugins/markdown/mkdnflow.lua b/lua/plugins/markdown/mkdnflow.lua index ddc2ea3..fe721ce 100644 --- a/lua/plugins/markdown/mkdnflow.lua +++ b/lua/plugins/markdown/mkdnflow.lua @@ -28,9 +28,13 @@ return { qmd = true, rmd = true, }, - perspective = { + modules = { + folds = false, + foldtext = false, + }, + path_resolution = { -- Ensure that paths are relative to the current file - priority = "current" + primary = "current" }, links = { conceal = true, diff --git a/lua/plugins/markdown/pandoc.lua b/lua/plugins/markdown/pandoc.lua index 64f2a24..ca804c8 100644 --- a/lua/plugins/markdown/pandoc.lua +++ b/lua/plugins/markdown/pandoc.lua @@ -48,14 +48,9 @@ return { 'markdown', 'pandoc' }, + dependencies = { + "vim-pandoc/vim-pandoc-syntax", + }, lazy = true, - }, - { - "vim-pandoc/vim-pandoc-syntax", - ft = { - 'markdown', - 'pandoc' - }, - lazy = true, - }, + } } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index cfe3874..1873cbe 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -21,109 +21,65 @@ 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', + 'mermaid', + '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', + '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 }