Closed Aneeqasif closed 1 year ago
mini config
mini config
mini config
sorry i forgot here it is
vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
vim.o.foldcolumn = '1'
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
-- require('ufo').setup()
-- require("ufo").setup(
-- {
-- provider_selector = function(bufnr, filetype, buftype)
-- return {"treesitter", "indent"}
-- end
-- }
-- )
local ftMap = {
vim = 'indent',
python = {'indent'},
git = ''
}
require('ufo').setup({
open_fold_hl_timeout = 150,
close_fold_kinds = {'imports', 'comment'},
preview = {
win_config = {
border = {'', '─', '', '', '', '─', '', ''},
-- winhighlight = 'Normal:Normal',
winhighlight = 'IncSearch:Folded',
winblend = 0
},
mappings = {
scrollU = '<C-u>',
scrollD = '<C-d>',
jumpTop = '[',
jumpBot = ']'
}
},
provider_selector = function(bufnr, filetype, buftype)
-- if you prefer treesitter provider rather than lsp,
return ftMap[filetype] or {'treesitter', 'indent'}
-- return ftMap[filetype]
-- refer to ./doc/example.lua for detail
end
})
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
vim.keymap.set('n', 'op', function()
local winid = require('ufo').peekFoldedLinesUnderCursor()
if not winid then
-- choose one of coc.nvim and nvim lsp
vim.fn.CocActionAsync('definitionHover') -- coc.nvim
vim.lsp.buf.hover()
end
end)
-- buffer scope handler
-- will override global handler if it is existed
-- local bufnr = vim.api.nvim_get_current_buf()
-- require('ufo').setFoldVirtTextHandler(bufnr, handler)
--
local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (' %d '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, {chunkText, hlGroup})
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, {suffix, 'MoreMsg'})
return newVirtText
end
-- global handler
-- `handler` is the 2nd parameter of `setFoldVirtTextHandler`,
-- check out `./lua/ufo.lua` and search `setFoldVirtTextHandler` for detail.
require('ufo').setup({
fold_virt_text_handler = handler
})
Change your own defined map op
to other key sequences not starting with key o
.
If you map op
, when you press key o
, vim will wait for timeoutlen
milliseconds for another key. So to make the builtin o
work as normal, you should guarantee that no other mappings starts with o
.
Neovim version (nvim -v | head -n1)
NVIM v0.8.3 Build type: Release LuaJIT 2.1.0-beta3 Compiled by builduser
Operating system/version
archo linux
How to reproduce the issue
noremap o o
nnoremap O O
Expected behavior
the o key is responding after a considerable delay, when i disbale the plugin it behaves as fast as it do normally
Actual behavior
o remaps should work properly