-
-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting foldmethod causes vim-clap to crash #194
Comments
Hi man ! Thanks for the kind words and thanks for contributing to the effort, you are part of it now 😉
That makes me think that the problem is from upstream. though it looks strange to me that this happens without any edits, as it is typically the way this bug is triggered. This needs further investigation, and thanks for the repro information ! |
I try to avoid setting the fold method for buffers for which I know it's not supported. What happens when you set the foldmethod only for 'c'? |
It looks like that this fixes my issue. Thank you very much 😀 |
Reopening because that's something that needs to be fixed 😉 |
We could have folding just as a module: it would be only set for the buffers where its supported and you can exclude languages. |
But how local parsers = require'nvim-treesitter.parsers'
local M = {}
--local previous_fold_method = {}
--local previous_fold_expr = {}
function M.get_fold_indic(lnum)
if not parsers.has_parser() or not lnum then return '0' end
local function smallest_multiline_containing(node, level)
for index = 0,(node:named_child_count() -1) do
local child = node:named_child(index)
local start, _, stop, _ = child:range()
if start ~= stop and start <= (lnum -1) and stop >= (lnum -1) then
return smallest_multiline_containing(child, level + 1)
end
end
return node, level
end
local parser = parsers.get_parser()
local _, level = smallest_multiline_containing(parser:parse():root(), 0)
return tostring(level)
end
function M.attach(_)
--local buf = bufnr or vim.api.nvim_get_current_buf()
--previous_fold_method[buf] = vim.api.nvim_buf_get_option(buf, 'foldmethod')
--previous_fold_expr[buf] = vim.api.nvim_buf_get_option(buf, 'foldexpr')
--
--local win = vim.api.nvim_get_current_win()
--vim.api.nvim_win_set_option(win, 'foldmethod', "expr")
--vim.api.nvim_win_set_option(win, 'foldexpr', "nvim_treesitter#foldexpr()")
vim.cmd("setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()")
end
function M.detach(_)
--vim.api.nvim_buf_win_option(bufnr, 'foldmethod', previous_fold_method[bufnr])
--vim.api.nvim_buf_win_option(bufnr, 'foldexpr', previous_fold_expr[bufnr])
end
return M |
I personally have a list of languages where I want to have a custom foldmethod: |
|
Is this issue still relevant ? @Conni2461 @theHamsta ? |
Using setlocal as @theHamsta suggested fixes the issue for me. You said the issue needed a solution. |
Is the issue still hapening using latest master ? |
Yes I can still reproduce the issue (latest master for neovim and nvim-treesitter) as described above.
But as I said in my previous comment, the problem no longer exists if you set the foldmethod per filetype. But since I use setlocal I had no complaints with the plugin and it has only improved lately. So thanks again to all maintainers. |
Hey guys,
First of all, great plugin, I really like what you have created here. Keep up the great work.
Describe the bug
I got a bug with the plugin vim-clap.
After a while vim-clap providers will result in an error message and resulting in a floating window without content. I'm not sure if this is a bug on your, vim-clap or neovim core side.
When i tried to create a minimal vimrc i noticed that this bug only appears when
foldmethod=expr foldexpr=nvim_treesitter#foldexpr()
is set.To Reproduce
Steps to reproduce the behavior:
nvim -u ~/minimalrc.vim src/nvim/ui.c
:Clap files
or<leader>q
. e.g.src/tree_sitter/parser.c
Pressing enter opens vim-claps floating window without content.
6. If message is not triggered, try opening more files with vim-clap or move around in the file. It is not entirely deterministic when it fails.
Expected behavior
vim-clap opens normally without triggering a error message and being able to open a new file.
Output of
:checkhealth nvim_treesitter
health#nvim_treesitter#check
Installation
git
executable found.cc
executable found.html parser healthcheck
highlights.scm
found.locals.scm
query found for htmltextobjects.scm
query found for htmltypescript parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for typescriptmarkdown parser healthcheck
highlights.scm
query found for markdownlocals.scm
query found for markdowntextobjects.scm
query found for markdownregex parser healthcheck
highlights.scm
found.locals.scm
query found for regextextobjects.scm
query found for regexc parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
found.java parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for javapython parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
found.yaml parser healthcheck
highlights.scm
query found for yamllocals.scm
query found for yamltextobjects.scm
query found for yamlcpp parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
found.toml parser healthcheck
highlights.scm
query found for tomllocals.scm
query found for tomltextobjects.scm
query found for tomllua parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for luaruby parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for rubygo parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
found.scala parser healthcheck
highlights.scm
query found for scalalocals.scm
query found for scalatextobjects.scm
query found for scalarust parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for rustjson parser healthcheck
highlights.scm
found.locals.scm
query found for jsontextobjects.scm
query found for jsonjavascript parser healthcheck
highlights.scm
found.locals.scm
found.textobjects.scm
query found for javascriptcss parser healthcheck
highlights.scm
found.locals.scm
query found for csstextobjects.scm
query found for cssc_sharp parser healthcheck
highlights.scm
query found for c_sharplocals.scm
query found for c_sharptextobjects.scm
query found for c_sharpbash parser healthcheck
highlights.scm
found.locals.scm
query found for bashtextobjects.scm
query found for bashMissing parsers
nix
swift
elm
vue
ocaml
haskell
jsdoc
julia
php
tsx
Output of
nvim --version
Additional context
Installing vim-claps binaries does not fix this bug so I left this one out.
The text was updated successfully, but these errors were encountered: