mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-15 06:22:36 +01:00
26 lines
972 B
Text
26 lines
972 B
Text
|
(local (ufo ts-parsers)
|
||
|
(values (require :ufo) (require :nvim-treesitter.parsers)))
|
||
|
|
||
|
(fn lsp-folds? [bufnr]
|
||
|
(accumulate [has false _ client (ipairs (vim.lsp.get_active_clients {: bufnr}))
|
||
|
&until has]
|
||
|
(not= client.server_capabilities.foldingRangeProvider nil)))
|
||
|
|
||
|
(ufo.setup {:open_fold_hl_timeout 0
|
||
|
:provider_selector (fn [bufnr ft _]
|
||
|
(if (lsp-folds? bufnr) [:lsp :indent]
|
||
|
(ts-parsers.has_parser ft) [:treesitter
|
||
|
:indent]
|
||
|
[:indent]))})
|
||
|
|
||
|
(tset vim :o :foldcolumn :0)
|
||
|
(tset vim :o :foldlevel 256)
|
||
|
(tset vim :o :foldlevelstart 256)
|
||
|
(tset vim :o :foldenable true)
|
||
|
|
||
|
(let [mopt (. (require :mzte_nv) :utils :map_opt)]
|
||
|
;; toggle fold
|
||
|
(vim.keymap.set :n :t :za mopt)
|
||
|
(vim.keymap.set :n :zO ufo.openAllFolds mopt)
|
||
|
(vim.keymap.set :n :zC ufo.closeAllFolds mopt))
|