onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.34k stars 299 forks source link

LSP Folding provider #2086

Open DeltaEvo opened 6 years ago

DeltaEvo commented 6 years ago

I saw some commits these days on the css-language-service about folding https://github.com/Microsoft/vscode-languageserver-protocol-foldingprovider/blob/master/protocol.foldingProvider.md :tada:

I think we can play a lot with this thing xD

TODO:

Now the only question that I have is how do we gave back these information to neovim ?

oni-bot[bot] commented 6 years ago

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

DeltaEvo commented 6 years ago

From my knowledge of vim folding I think the best solution is to set foldmethod=manual and use http://vimdoc.sourceforge.net/htmldoc/fold.html#zf but with this solution to remove a fold we need to use http://vimdoc.sourceforge.net/htmldoc/fold.html#zd and so move the cursor

Edit: for zd we can use :normal ex command to avoid moving the cursor

CrossR commented 6 years ago

I think ideally, there would be an upstream change with neovim to expose a nvim_create_fold() function that we could call with the API, so we don't have to mess with the cursor etc.

Unless I'm reading the changes wrong, it looks like this PR (https://github.com/neovim/neovim/pull/6073) is adding that functionality, which would make this much easier.

teto commented 6 years ago

The PR you mentioned does add nvim_create/delete_fold. Now the API has not been discussed so I am not sure how easy it would be to merge as it is. Maybe folds should have an id for instance (to help remove them rather than clearing all folds) ?

Kinda related request (fold API) https://github.com/neovim/neovim/issues/7544#issuecomment-386788893