From 22a4fb32b353e4fe6533ffcc48b04818eaf76f93 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Thu, 9 Mar 2023 13:59:47 +0600 Subject: [PATCH 1/5] fold added --- queries/org/folds.scm | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 queries/org/folds.scm diff --git a/queries/org/folds.scm b/queries/org/folds.scm new file mode 100644 index 000000000..cb376d5b5 --- /dev/null +++ b/queries/org/folds.scm @@ -0,0 +1,2 @@ +((section) @fold + (#trim! @fold)) From bd07be55cf81d6d1e93f5e3dedd626bd92234186 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Thu, 9 Mar 2023 19:27:40 +0600 Subject: [PATCH 2/5] table added --- queries/org/folds.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/queries/org/folds.scm b/queries/org/folds.scm index cb376d5b5..97507539a 100644 --- a/queries/org/folds.scm +++ b/queries/org/folds.scm @@ -1,2 +1,5 @@ -((section) @fold +([ + (section) + (table) + ] @fold (#trim! @fold)) From 4c08d9a53907e39461c41c1e83078af73a143bf6 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Thu, 9 Mar 2023 19:58:49 +0600 Subject: [PATCH 3/5] moved from deprecated API --- lua/orgmode/utils/treesitter.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/orgmode/utils/treesitter.lua b/lua/orgmode/utils/treesitter.lua index 098026535..00d7dcc50 100644 --- a/lua/orgmode/utils/treesitter.lua +++ b/lua/orgmode/utils/treesitter.lua @@ -39,9 +39,11 @@ function M.get_node_at_cursor(cursor, winnr, ignore_injected_langs) winnr = winnr or 0 local buf = vim.api.nvim_win_get_buf(winnr) -- TODO: Use only this function when 0.8 is released - if vim.treesitter.get_node_at_pos then - return vim.treesitter.get_node_at_pos(buf, cursor[1] - 1, cursor[2], { - ignore_injections = ignore_injected_langs, + if vim.treesitter.get_node then + return vim.treesitter.get_node({ + bufrn = buf, + pos = {cursor[1] - 1, cursor[2]}, + ignore_injections = ignore_injected_langs }) end From 29491429cfbbcdd4ddbcaca79bd075b175fd09be Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Fri, 10 Mar 2023 18:30:58 +0600 Subject: [PATCH 4/5] review --- ftplugin/org.vim | 2 +- lua/orgmode/utils/treesitter.lua | 4 ++-- queries/org/folds.scm | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ftplugin/org.vim b/ftplugin/org.vim index 660669886..7800b5e37 100644 --- a/ftplugin/org.vim +++ b/ftplugin/org.vim @@ -20,7 +20,7 @@ endfunction setlocal nomodeline setlocal fillchars+=fold:\ setlocal foldmethod=expr -setlocal foldexpr=OrgmodeFoldExpr() +setlocal foldexpr=nvim_treesitter#foldexpr() setlocal foldtext=OrgmodeFoldText() setlocal formatexpr=OrgmodeFormatExpr() setlocal foldlevel=0 diff --git a/lua/orgmode/utils/treesitter.lua b/lua/orgmode/utils/treesitter.lua index 00d7dcc50..4d620ae85 100644 --- a/lua/orgmode/utils/treesitter.lua +++ b/lua/orgmode/utils/treesitter.lua @@ -42,8 +42,8 @@ function M.get_node_at_cursor(cursor, winnr, ignore_injected_langs) if vim.treesitter.get_node then return vim.treesitter.get_node({ bufrn = buf, - pos = {cursor[1] - 1, cursor[2]}, - ignore_injections = ignore_injected_langs + pos = { cursor[1] - 1, cursor[2] }, + ignore_injections = ignore_injected_langs, }) end diff --git a/queries/org/folds.scm b/queries/org/folds.scm index 97507539a..ebd61aa87 100644 --- a/queries/org/folds.scm +++ b/queries/org/folds.scm @@ -1,5 +1,8 @@ ([ (section) (table) + (drawer) + (property_drawer) + (block) ] @fold (#trim! @fold)) From 6e17e3692d1fd44d3da191552b6f9ae7f9db6918 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Fri, 10 Mar 2023 18:34:07 +0600 Subject: [PATCH 5/5] FoldExpr is not needed anymore --- ftplugin/org.vim | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ftplugin/org.vim b/ftplugin/org.vim index 7800b5e37..805e903f8 100644 --- a/ftplugin/org.vim +++ b/ftplugin/org.vim @@ -1,10 +1,6 @@ lua require('orgmode.config'):setup_mappings('org') lua require('orgmode.config'):setup_mappings('text_objects') -function! OrgmodeFoldExpr() - return luaeval('require("orgmode.org.indent").foldexpr()') -endfunction - function! OrgmodeFoldText() return luaeval('require("orgmode.org.indent").foldtext()') endfunction