Commit graph

39 commits

Author SHA1 Message Date
Andrei Neculaesei
b23a46aa06
feat(provider): allow using tree-sitter node types as kinds (#243)
* feat(provider): allow using tree-sitter node types as kinds
(adding tree-sitter support to close_fold_kinds_for_ft)

* fix(provider): guard treesitter node type and add mention to README

---------

Co-authored-by: 3rd <3rd@users.noreply.github.com>
Co-authored-by: anon <anon@localhost>
2024-08-23 22:25:45 +08:00
Jongwook Choi
c1e8102e4e
refactor(treesitter): remove nvim-treesitter dependencies (#189)
Replace all the use of nvim-treesitter APIs with core vim.treesitter
APIs. No more nvim-treesitter dependency, just core neovim is enough.

This fix makes ufo work without the nvim-treesitter plugin as an
additional dependency. In fact, nvim-treesitter v1.0 deprecates and
removes some APIs that have been migrated to the core neovim APIs
`vim.treesitter`, which makes ufo's previous treesitter provider
implementation incompatible.

Note that this commit does not change the minimum neovim version
requirement, should work fine with neovim 0.7.x.

Implementation note:

There are four APIs that need to be migrated:

- `nvim-treesitter.parsers.get_parser()`: The difference to the core API
  `vim.treesitter.get_parser()` is whether to throw errors when a parser
  is not available (`has_parser`). We simply mimic the previous behavior
  by catching errors.

- `nvim-treesitter.query.get_query()`: The difference to core API
  `vim.treesitter.query.get()` is whether the query file is cached or
  not. This may have a small performance impact; in neovim 0.10.x, this
  function is memoized and thus very fast, but in neovim <= 0.9.x it
  might be slightly slow due to the lack of cache.

  Note: One can consider as well automatically falling back to the old
  nvim-treesitter (v0.9.x) if available, for neovim < 0.10.

- `nvim-treesitter.query.has_folds()` (i.e., `has_query_files()`):
  can be easily replaced with `vim.treesitter.query.get_files`. Also
  there might be a subtle performance difference of whether cache is
  being used (in the old nvim-treesitter implementations) or not.

- `nvim-treesitter.tsrange`: The `TSRange` API has gone. Note that this
  is used only to implement the `#make-range!` directive; it suffices to
  have `node:range()` only for where it's used. Therefore,
  `TSRange.from_nodes()` is the only API we'll need, which can be easily
  backported into the existing `MetaNode` implementation.
2024-03-19 23:53:46 +08:00
kevinhwang91
7b14dd650b feat(config)!: use close_fold_kinds_for_ft instead close_fold_kinds 2024-03-14 16:39:00 +08:00
kevinhwang91
ad8d336cdd chore!: bump Neovim to 0.7.2 2023-11-24 02:14:20 +08:00
kevinhwang91
aebd36bf54 fix(docs): update nerd fonts code point for 3.0 2023-08-14 15:54:55 +08:00
kevinhwang91
b70c9ef0f8 feat(preview): add jumpTop and jumpBot keymap actions (#109) 2023-02-03 13:54:29 +08:00
kevinhwang91
57f76ff044 feat(highlight): add UfoCursorFoldedLine (#103) 2023-01-23 00:37:18 +08:00
Ray Jameson
8d84a8ad9d
docs(README): Make capabilities for all available lsp servers & remove "other_fields" (#100)
* docs(README): Make capabilities for all avaliable lsp servers

* docs(README): remove "other_fields"

* docs(README): comment for setting other lsp fields in setup
2023-01-03 21:09:19 +08:00
kevinhwang91
ab1cab9712 docs: explain fold_virt_text_handler (#98) 2022-12-23 20:11:21 +08:00
kevinhwang91
de599450c6 fix(preview): respect target buffer opts
Like `iskeyword`, `listchars` and text off for the window
2022-12-16 18:19:41 +08:00
kevinhwang91
e988139f6f feat(provider): use fallback if buftype == 'nofile'
Like `ft=man` scenario, but users should make sure `foldenable` before
ufo apply folds :)
2022-12-03 15:17:45 +08:00
kevinhwang91
11696c3a98 chore: inspect current fold kinds 2022-10-24 21:16:00 +08:00
kevinhwang91
1acfc3d98b feat(preview): export UfoPreviewCursorLine highlight 2022-10-08 19:55:34 +08:00
kevinhwang91
0792fd67d0 feat(preview): show visual winbar for preview if topline scroll
Use floating widnow to mock winbar that is better than native winbar
because can reused highlight group.
2022-09-29 09:15:57 +08:00
aileot
7cf9d2a114
feat(foldtext)!: add enable_get_fold_virt_text option to get virt texts of arbitrary rows (#74)
BREAKING CHANGE: `enable_fold_end_virt_text` is deprecated, use `enable_get_fold_virt_text` instead

Co-authored-by: kevinhwang91 <kevin.hwang@live.com>
2022-09-10 21:44:07 +08:00
kevinhwang91
148665a597 docs: better document of provider_selector. 2022-09-08 00:46:54 +08:00
kevinhwang91
314fd69e46 feat(preview)!: make the window display upward if kind == 'comment' (#73)
Only work for lsp provider.
If the kind of foldingRange is equal to 'comment', display the preview window upward.

BREAKING CHANGE:
1. The signature of `peekFoldedLinesUnderCursor` has been changed. If
   you hack it in depth, please review the document, otherwise, don't
   need to change anything.
2. maxHeight parameters of `peekFoldedLinesUnderCursor` has been moved
   to `preview.win_config.maxheight`.
2022-09-06 00:39:26 +08:00
kevinhwang91
a889c34a78 feat(action): add openFoldsExceptKinds (#64) 2022-08-15 20:14:16 +08:00
kevinhwang91
b42f03dd69 feat(fold): add close_fold_kinds option (#64)
1. Only work for lsp provider for now.
2. Enable by `close_fold_kinds = {'imports', 'comment'}`
2022-08-15 19:01:40 +08:00
kevinhwang91
39e566ade3 docs: perfect closeFoldsWith 2022-08-13 00:50:07 +08:00
kevinhwang91
56a8538d65 chore: assert provider_selector (#61)
'lsp' and 'treesitter' as `main`, 'indent' as fallback
2022-08-05 16:06:17 +08:00
Yusuke Uchida
fa012f8aa9 docs: fixed Command 2022-07-27 09:41:23 +09:00
kevinhwang91
3cf2f3cfd5 docs: update config value for foldlevelstart
Look like `vim.o.foldlevelstart = 99` may help users to conquer ufo.
2022-07-26 01:50:35 +08:00
kevinhwang91
0026114564 chore: update README and .luarc.jsonc 2022-07-23 21:56:40 +08:00
kevinhwang91
fadc60bce7 chore: add buftype to provider_selector function 2022-07-16 14:37:05 +08:00
kevinhwang91
2cbdd88e48 chore(github): update issue template 2022-07-06 09:40:10 +08:00
kevinhwang91
5a80814396 docs: add enable_fold_end_virt_text 2022-07-05 00:49:57 +08:00
kevinhwang91
69cf4708e1 refactor: correct method name and docs 2022-07-04 18:46:52 +08:00
kevinhwang91
7d1e750b0e docs: make it easy to use 2022-07-04 17:12:37 +08:00
kevinhwang91
dd6b38d9c3 docs: correct minimal configuration for nvim lsp 2022-06-22 21:10:07 +08:00
kevinhwang91
7091ba48a2 chore: nvim lsp users can't setup correctly 2022-06-22 16:03:37 +08:00
jeff b
45d784d0b3
Fix incorrect setFoldVirtTextHandler variable name 2022-06-20 10:44:58 -07:00
kevinhwang91
ae73858492 docs: missing bracket for code snippet 2022-06-19 19:09:15 +08:00
kevinhwang91
f76ac1b039 fix: typo 2022-06-19 15:49:19 +08:00
kevinhwang91
95b9e62455 docs: remove WIP
not perfect, but can daily use
2022-06-19 01:36:13 +08:00
kevinhwang91
9569085ffd docs: update 2022-06-18 22:33:45 +08:00
kevinhwang91
9fd41405e7 fix: need handle utf-8 width
add truncate() for fold_virt_text_handler
2022-06-18 02:03:18 +08:00
kevinhwang91
dd725141a2 feat: add fold_virt_text_handler to customize fold text 2022-06-17 00:41:31 +08:00
kevinhwang91
af51cbf704 first commit 2022-06-16 00:33:12 +08:00