Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
2026-04-15 21:14:54 +02:00
3 changed files with 92 additions and 37 deletions
+10
View File
@@ -92,3 +92,13 @@ vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" })
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" })
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
-- Folding keymaps
vim.keymap.set("n", "za", "za", { desc = "Toggle fold under cursor" })
vim.keymap.set("n", "zA", "zA", { desc = "Toggle fold recursively" })
vim.keymap.set("n", "zR", "zR", { desc = "Open all folds" })
vim.keymap.set("n", "zM", "zM", { desc = "Close all folds" })
vim.keymap.set("n", "zo", "zo", { desc = "Open fold under cursor" })
vim.keymap.set("n", "zc", "zc", { desc = "Close fold under cursor" })
vim.keymap.set("n", "zO", "zO", { desc = "Open all folds under cursor" })
vim.keymap.set("n", "zC", "zC", { desc = "Close all folds under cursor" })
+34 -9
View File
@@ -10,20 +10,45 @@
- vim.go.* for global option shorthand
]]
-- ============================================================================
-- TREESITTER (Built-in Neovim 0.10+ features)
-- ============================================================================
-- Enable Treesitter syntax highlighting (native in Neovim 0.10+)
-- This replaces the old nvim-treesitter highlight module
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
callback = function()
if vim.bo.buftype == "" and vim.bo.filetype ~= "" then
pcall(vim.treesitter.start)
end
end,
desc = "Enable Treesitter highlighting",
})
-- ============================================================================
-- FOLDING SETTINGS (Code folding)
-- ============================================================================
-- Foldmethod determines how code blocks are detected and folded
-- "expr" means folds are based on expressions (we use treesitter for this)
vim.opt.foldmethod = "expr"
-- Foldexpr is the expression used to determine fold level
-- v:lua.vim.treesitter.foldexpr() uses Treesitter to calculate folds
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- NOTE: In Neovim 0.10+, Treesitter folding must be set per-buffer via FileType autocmd
-- Setting it globally causes the foldexpr to evaluate before Treesitter attaches
-- Foldlevel: Higher number = more folds are open by default
-- 99 means almost all folds are open when opening a file
vim.opt.foldlevel = 99
-- 1-2 means you'll see folds by default; 99 means all folds are open
vim.opt.foldlevel = 1
vim.opt.foldlevelstart = 1
-- Setup Treesitter folding for each buffer after filetype is detected
-- This ensures the parser is loaded before foldexpr evaluates
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
callback = function()
-- Only set folding for file buffers with Treesitter support
if vim.bo.buftype == "" then
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end
end,
desc = "Setup Treesitter folding per filetype",
})
-- ============================================================================
-- LINE NUMBERS
+48 -28
View File
@@ -3,36 +3,56 @@ return {
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
config = function()
-- Ensure nvim-treesitter queries are preferred over runtime queries
-- This fixes the "except*" syntax error with updated parsers
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/nvim-treesitter")
-- In the latest nvim-treesitter (post-refactor), the plugin only handles
-- parser installation. Highlighting, folding, and indenting are handled
-- by native Neovim Treesitter integration.
local ok, configs = pcall(require, "nvim-treesitter.configs")
-- CRITICAL: Add nvim-treesitter/runtime to runtimepath so queries are found
local ts_runtime = vim.fn.stdpath("data") .. "/lazy/nvim-treesitter/runtime"
vim.opt.runtimepath:prepend(ts_runtime)
-- Setup nvim-treesitter (minimal config for parser installation)
require("nvim-treesitter").setup({
-- Parser installation directory (default: stdpath('data')/site)
install_dir = vim.fn.stdpath("data") .. "/site",
})
-- Auto-install parsers for these languages when opening a file
local ensure_installed = {
"python",
"lua",
"json",
"yaml",
"javascript",
"typescript",
"tsx",
"vue",
"html",
"css",
"bash",
"markdown",
"markdown_inline",
}
-- Install parsers
local ok, install = pcall(require, "nvim-treesitter.install")
if ok then
configs.setup({
auto_install = true,
ensure_installed = {
"python",
"lua",
"json",
"yaml",
"javascript",
"typescript",
"tsx",
"vue",
"html",
"css",
"bash",
"markdown",
"markdown_inline",
},
highlight = {
enable = true,
-- Disable additional_vim_regex_highlighting to avoid conflicts
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
})
for _, lang in ipairs(ensure_installed) do
vim.schedule(function()
install.install({ lang })
end)
end
end
-- Enable Treesitter-based indenting (natively supported by Neovim)
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
callback = function()
if vim.bo.buftype == "" and vim.bo.filetype ~= "" then
vim.bo.indentexpr = "v:lua.vim.treesitter.indentexpr()"
end
end,
desc = "Enable Treesitter indenting",
})
end,
}