feat: folding, mini.pairs
This commit is contained in:
parent
3f444e3892
commit
fa86178061
36
init.lua
36
init.lua
|
|
@ -196,6 +196,31 @@ vim.o.scrolloff = 10
|
||||||
-- See `:help 'confirm'`
|
-- See `:help 'confirm'`
|
||||||
vim.o.confirm = true
|
vim.o.confirm = true
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- FOLDING CONFIGURATION - For Flutter widgets and code blocks
|
||||||
|
-- ========================================================================
|
||||||
|
-- Enable folding based on Treesitter (for Flutter widgets, functions, etc.)
|
||||||
|
vim.o.foldmethod = 'expr'
|
||||||
|
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
-- Start with all folds open (don't fold on file open)
|
||||||
|
vim.o.foldenable = false
|
||||||
|
-- Set fold level (higher = more unfolded by default)
|
||||||
|
vim.o.foldlevel = 99
|
||||||
|
vim.o.foldlevelstart = 99
|
||||||
|
-- Customize fold text to show more context
|
||||||
|
vim.o.foldtext = ''
|
||||||
|
-- Hide fold column globally (saves space, folds still work with za/zc/zo)
|
||||||
|
vim.o.foldcolumn = '0' -- Set to '1' if you want the fold column back
|
||||||
|
|
||||||
|
-- Folding keymaps:
|
||||||
|
-- za - Toggle fold under cursor
|
||||||
|
-- zc - Close fold under cursor
|
||||||
|
-- zo - Open fold under cursor
|
||||||
|
-- zM - Close all folds
|
||||||
|
-- zR - Open all folds
|
||||||
|
-- zj - Move to next fold
|
||||||
|
-- zk - Move to previous fold
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
|
||||||
|
|
@ -995,6 +1020,13 @@ require('lazy').setup({
|
||||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||||
require('mini.surround').setup()
|
require('mini.surround').setup()
|
||||||
|
|
||||||
|
-- Autopairs - automatically close brackets, quotes, etc.
|
||||||
|
--
|
||||||
|
-- When you type { it automatically adds }
|
||||||
|
-- When you type " it automatically adds the closing "
|
||||||
|
-- Press <CR> between brackets to add proper indentation
|
||||||
|
require('mini.pairs').setup()
|
||||||
|
|
||||||
-- Simple and easy statusline.
|
-- Simple and easy statusline.
|
||||||
-- You could remove this setup call if you don't like it,
|
-- You could remove this setup call if you don't like it,
|
||||||
-- and try some other statusline plugin
|
-- and try some other statusline plugin
|
||||||
|
|
@ -1051,6 +1083,10 @@ require('lazy').setup({
|
||||||
additional_vim_regex_highlighting = { 'ruby' },
|
additional_vim_regex_highlighting = { 'ruby' },
|
||||||
},
|
},
|
||||||
indent = { enable = true, disable = { 'ruby' } },
|
indent = { enable = true, disable = { 'ruby' } },
|
||||||
|
-- Enable folding based on Treesitter
|
||||||
|
fold = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
-- There are additional nvim-treesitter modules that you can use to interact
|
-- There are additional nvim-treesitter modules that you can use to interact
|
||||||
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,43 @@ return {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- ENABLE TREESITTER FOLDING FOR DART FILES
|
||||||
|
-- ========================================================================
|
||||||
|
-- Set fold method to use Treesitter for Flutter widgets
|
||||||
|
-- Using multiple autocmds to ensure it sticks (some plugins override it)
|
||||||
|
local fold_augroup = vim.api.nvim_create_augroup('DartFolding', { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufRead', 'BufEnter', 'BufWinEnter' }, {
|
||||||
|
group = fold_augroup,
|
||||||
|
pattern = '*.dart',
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.foldmethod = 'expr'
|
||||||
|
vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
vim.opt_local.foldlevel = 99 -- High level = everything unfolded
|
||||||
|
vim.opt_local.foldlevelstart = 99 -- Start with everything unfolded
|
||||||
|
|
||||||
|
-- Hide fold column (no extra column, folds still work!)
|
||||||
|
vim.opt_local.foldcolumn = '0'
|
||||||
|
|
||||||
|
-- Minimal fold display (VS Code style - just shows first line)
|
||||||
|
vim.opt_local.foldtext = ''
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Also set after LSP attaches (flutter-tools might reset it)
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = fold_augroup,
|
||||||
|
callback = function(args)
|
||||||
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
if client and client.name == 'dartls' then
|
||||||
|
vim.opt_local.foldmethod = 'expr'
|
||||||
|
vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
vim.opt_local.foldlevel = 99 -- Everything unfolded
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- ========================================================================
|
-- ========================================================================
|
||||||
-- FLUTTER-SPECIFIC KEYMAPS
|
-- FLUTTER-SPECIFIC KEYMAPS
|
||||||
-- ========================================================================
|
-- ========================================================================
|
||||||
|
|
@ -257,6 +294,16 @@ return {
|
||||||
callback = function()
|
callback = function()
|
||||||
local opts = { buffer = true, silent = true }
|
local opts = { buffer = true, silent = true }
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- ENABLE TREESITTER FOLDING FOR DART FILES
|
||||||
|
-- ========================================================================
|
||||||
|
-- Set fold method to use Treesitter for Flutter widgets
|
||||||
|
vim.opt_local.foldmethod = 'expr'
|
||||||
|
vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
vim.opt_local.foldenable = false -- Start with folds open
|
||||||
|
vim.opt_local.foldlevel = 99
|
||||||
|
vim.opt_local.foldlevelstart = 99
|
||||||
|
|
||||||
-- Flutter run/quit
|
-- Flutter run/quit
|
||||||
-- WORKFLOW:
|
-- WORKFLOW:
|
||||||
-- 1. First time: <leader>fd to select device
|
-- 1. First time: <leader>fd to select device
|
||||||
|
|
@ -338,4 +385,18 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- DART TREESITTER - Ensure dart parser is installed for proper folding
|
||||||
|
-- ========================================================================
|
||||||
|
{
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
ft = 'dart',
|
||||||
|
opts = function(_, opts)
|
||||||
|
-- Ensure Dart parser is installed
|
||||||
|
opts.ensure_installed = opts.ensure_installed or {}
|
||||||
|
vim.list_extend(opts.ensure_installed, { 'dart' })
|
||||||
|
return opts
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue