correct order for tresitter/lsp folding
This commit is contained in:
@@ -25,19 +25,6 @@ require'nvim-treesitter.configs'.setup {
|
||||
}
|
||||
local vim = vim
|
||||
|
||||
vim.o.foldmethod = 'expr'
|
||||
-- Default to treesitter folding
|
||||
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
-- Prefer LSP folding if client supports it
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client:supports_method('textDocument/foldingRange') then
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
|
||||
end
|
||||
end,
|
||||
})
|
||||
local opt = vim.opt
|
||||
local api = vim.api
|
||||
local M = {}
|
||||
@@ -68,3 +55,16 @@ local autoCommands = {
|
||||
}
|
||||
|
||||
M.nvim_create_augroups(autoCommands)
|
||||
vim.o.foldmethod = 'expr'
|
||||
-- Default to treesitter folding
|
||||
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
-- Prefer LSP folding if client supports it
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client:supports_method('textDocument/foldingRange') then
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user