Coder Social home page Coder Social logo

Comments (8)

tomtomjhj avatar tomtomjhj commented on June 24, 2024 2

And should :mksession work with options set the way you suggest?

Yes that works. The problem in the repro script is that filetype is not set when foldexpr is first evaluated, so the foldexpr doesn't recognize the language. Setting up an FileType autocmd to set foldexpr will reevaluate foldexpr with proper filetype.

So there are two options for improvements

  • document that treesitter foldexpr should be set in FileType autocmd or ftplugin; or
  • let treesitter fold module setup FileType autocmd to reevaluate foldexpr, so that it works even when the user doesn't do that

from neovim.

wookayin avatar wookayin commented on June 24, 2024 1

Try evaluating vim.treesitter.foldexpr() manually, e.g. :lua= vim.treesitter.foldexpr(3) and see what it prints. Check setlocal foldexpr and setlocal foldmethod too.

Also ensure the TS parser exists and works for the buffer: :lua= vim.treesitter.get_parser(0):lang().

from neovim.

clason avatar clason commented on June 24, 2024

You need to set these options in a FileType autocommand or ftplugin; these are not "global options".

from neovim.

adrian5 avatar adrian5 commented on June 24, 2024

And should :mksession work with options set the way you suggest? From the help file it looks like it might only track global options.

If it does not restore local options, does that mean I cannot restore folds (sessionoptions) in conjunction with nvim-treesitter?

from neovim.

clason avatar clason commented on June 24, 2024

The folds from treesitter behave exactly like other folds.

from neovim.

adrian5 avatar adrian5 commented on June 24, 2024

As sparse as ever with your answers. I would have liked to figure this out with vanilla nvim, but will return to using nvim-ufo then, which somehow handles these use cases.

from neovim.

clason avatar clason commented on June 24, 2024

That's all the time I have for, unfortunately. You can try your luck with @lewis6991.

from neovim.

adrian5 avatar adrian5 commented on June 24, 2024

Fair enough, just my frustration speaking as I've gotten stuck on this far too long, apologies!

from neovim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.