Closed anuvyklack closed 2 years ago
I can't reproduce it, please provide a minimal config.
I reproduced this problem with very minimal init.lua
:
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use { 'neovim/nvim-lspconfig', as = 'lspconfig',
requires = { 'williamboman/nvim-lsp-installer', 'folke/lua-dev.nvim' },
config = function()
require('nvim-lsp-installer').setup {}
local function create_capabilities()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
return capabilities
end
require('lspconfig').sumneko_lua.setup({
capabilities = create_capabilities()
})
end
}
use { 'nvim-telescope/telescope.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('telescope').setup{}
end
}
use { 'kevinhwang91/nvim-ufo',
requires = 'kevinhwang91/promise-async',
config = function()
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)
end
}
if packer_bootstrap then
require('packer').sync()
end
end)
-- vim: ts=3 sts=3
This is not a minal config. Please using like this:
vim.o.packpath = '~/.local/share/nvim/site'
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
-- promise-async under start
-- nvim-lspconfig under opt
-- plenary.nvim under opt
-- telescope.nvim under opt
-- nvim-ufo under opt
vim.cmd('pa nvim-lspconfig')
vim.cmd('pa plenary.nvim')
vim.cmd('pa telescope.nvim')
vim.cmd('pa nvim-ufo')
local function create_capabilities()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
return capabilities
end
require('lspconfig').sumneko_lua.setup({
capabilities = create_capabilities(),
cmd = {'/usr/bin/lua-language-server'},
on_attach = function(...)
print('attach', ...)
end
})
local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)
nvim --clean -u mini.lua your_file.lua
It happens to sumneko-lua when you open with telescope Lua file that not belongs to any project and opens in single file mode.
I'm not familiar with single file mode
, could you provide lsp config and a directory tree to explain?
This is a known telescope problem. Nothing to do with this plugin.
If you do not want to wait on an official fix, you could try setting custom picker maps like this
local foldMaps = function(_)
require("telescope.actions.set").select:enhance {
post = function()
vim.cmd ":normal! zx"
end,
}
return true
end
require("telescope").setup {
pickers = {
find_files = { attach_mappings = foldMaps },
old_files = { attach_mappings = foldMaps},
}
}
No, it is not this problem. I am aware about it and even suggested another temporary fix and this problem is not that, zx
does not fix it.
I'm not familiar with single file mode, could you provide lsp config and a directory tree to explain?
The single file support for Sumneko_lua turn on by default in lspconfig plugin. So you need just open from telescope, any Lua file that doesn't have any of the next files somewhere downstairs in the file tree:
".luarc.json", ".luacheckrc", ".stylua.toml", "selene.toml", ".git"
You can check if lsp is in single file mode with :LspInfo
command
I found another case where this problem appears:
vim
file: nvim file.vim
;I do not appear folds, however UfoInspect
says that ufo is attached.
Can't reproduce all of the cases you said even LspInfo
tell me root directory: Running in single file mode.
ping me if has new info
Neovim version (nvim -v | head -n1)
NVIM 0.7.0
Operating system/version
Fedora 36
How to reproduce the issue
:Telescope find_files
or vim builtingf
Expected behavior
Folds should work in the buffer open with Telescope also.
Actual behavior
Folds not applied.
UfoInspect
returnsUfoEnableFold
has no effect.If open file with
:edit path/to/file
folds are working.