From 105d6cf2eab4cf8e7f736dab6054113f290b2d36 Mon Sep 17 00:00:00 2001 From: Simon Lasbrugnas Date: Sat, 20 Apr 2024 04:00:04 +0200 Subject: [PATCH] chore: clean up and reformat feat: remove unused bindings --- lua/config/autocmds.lua | 1 + lua/config/keymaps.lua | 8 +-- lua/config/options.lua | 2 + lua/core/lazy.lua | 18 ++--- lua/plugins/coding.lua | 130 ++++++++++++++++++------------------- lua/plugins/editor.lua | 62 +++++++++--------- lua/plugins/git.lua | 99 +++++++++++++--------------- lua/plugins/lsp.lua | 56 ++++++++-------- lua/plugins/lsp/config.lua | 108 +++++++++++++++--------------- lua/plugins/telescope.lua | 54 ++++++++------- lua/plugins/treesitter.lua | 118 ++++++++++++++++----------------- 11 files changed, 322 insertions(+), 334 deletions(-) diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index d428f11..5eef117 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -1,3 +1,4 @@ +-- Remove trailing whitespace on save -- vim.api.nvim_create_autocmd({"BufWritePre"}, { -- group = vim.api.nvim_create_augroup("Default", {}), -- pattern = "*", diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 7965beb..e44e978 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -12,7 +12,7 @@ vim.keymap.set("n", "", "cnextzz") vim.keymap.set("n", "", "cprevzz") -- Copy to system clipboard -vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set({ "n", "v" }, "y", [["+y]]) -- Escape terminal mode vim.keymap.set("t", "", "") @@ -20,11 +20,7 @@ vim.keymap.set("t", "", "") vim.keymap.set("n", "bd", "bd") -- Thanks to Mr. Primeagen -vim.keymap.set({"n", "v"}, "", "silent !tmux neww tmux-sessionizer") +vim.keymap.set({ "n", "v" }, "", "silent !tmux neww tmux-sessionizer") vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) vim.keymap.set("v", "J", ":m '>+1gv=gv") vim.keymap.set("v", "K", ":m '<-2gv=gv") - --- Typing too fast... -vim.keymap.set("n", "q:", ":q") - diff --git a/lua/config/options.lua b/lua/config/options.lua index a9396bc..9378b0e 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -19,6 +19,8 @@ vim.opt.incsearch = true vim.opt.termguicolors = true +vim.opt.guicursor = "n-v-i-c-ci-ve-sm:block,r-cr-o:hor20" + vim.opt.scrolloff = 8 vim.opt.sidescrolloff = 16 diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua index f3ab19c..4b86146 100644 --- a/lua/core/lazy.lua +++ b/lua/core/lazy.lua @@ -1,17 +1,17 @@ -- Boostrap Lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) -require("lazy").setup({{ import = "plugins" }}) +require("lazy").setup({ { import = "plugins" } }) vim.cmd([[colorscheme peel-enhanced]]) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 83cd562..550e60f 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -1,67 +1,67 @@ return { - -- Autocomplete - { - "hrsh7th/nvim-cmp", - version = false, - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "L3MON4D3/LuaSnip", - }, - opts = function() - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - local cmp_format = require("lsp-zero").cmp_format() - return { - completion = { - completeopt = "menu,menuone,noinsert", - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = function(fallback) - cmp.abort() - fallback() - end, - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "path" }, - }, { - { name = "buffer" }, - }), - sorting = defaults.sorting, - formatting = cmp_format, - } - end, - config = function(_, opts) - require("cmp").setup(opts) - end, - }, - -- Copilot - { 'github/copilot.vim' }, - -- Comment - { - 'numToStr/Comment.nvim', - opts = { - -- add any options here - }, - lazy = false, - config = function () - require("Comment").setup() - end - }, - -- Surround - { 'tpope/vim-surround', event = "BufRead", }, + -- Autocomplete + { + "hrsh7th/nvim-cmp", + version = false, + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + }, + opts = function() + local cmp = require("cmp") + local defaults = require("cmp.config.default")() + local cmp_format = require("lsp-zero").cmp_format() + return { + completion = { + completeopt = "menu,menuone,noinsert", + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = function(fallback) + cmp.abort() + fallback() + end, + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "path" }, + }, { + { name = "buffer" }, + }), + sorting = defaults.sorting, + formatting = cmp_format, + } + end, + config = function(_, opts) + require("cmp").setup(opts) + end, + }, + -- Copilot + { "github/copilot.vim" }, + -- Comment + { + "numToStr/Comment.nvim", + opts = { + -- add any options here + }, + lazy = false, + config = function() + require("Comment").setup() + end + }, + -- Surround + { "tpope/vim-surround", event = "BufRead", }, } diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index a02a796..c8edc8e 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -1,33 +1,33 @@ return { - { - "folke/which-key.nvim", - event = "VeryLazy", - opts = { }, - keys = { - { 'wk', 'WhichKey', desc = 'Show key mappings' }, - }, - }, - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = {}, - keys = { - { 'xx', 'TroubleToggle workspace_diagnostics', desc = 'Trouble Workspace Diagnostics' }, - { 'xd', 'TroubleToggle document_diagnostics', desc = 'Trouble Document Diagnostics' }, - { 'xl', 'TroubleToggle loclist', desc = 'Trouble Loclist' }, - { 'xq', 'TroubleToggle quickfix', desc = 'Trouble Quickfix' }, - { 'xt', 'TroubleToggle lsp_references', desc = 'Trouble LSP References' }, - { 'xj', function() require("trouble").next({skip_groups = true, jump = true}) end, desc = 'Trouble Next' }, - { 'xk', function() require("trouble").previous({skip_groups = true, jump = true}) end, desc = 'Trouble Previous' }, - }, - }, - { 'wsdjeg/vim-fetch', event = "VeryLazy" }, - { 'nvim-tree/nvim-web-devicons' }, - { - 'eandrju/cellular-automaton.nvim', - event = "VeryLazy", - keys = { - { 'mr', 'CellularAutomaton make_it_rain', desc = 'Make it rain' }, - }, - }, + { + "folke/which-key.nvim", + event = "VeryLazy", + opts = {}, + keys = { + { 'wk', 'WhichKey', desc = 'Show key mappings' }, + }, + }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = {}, + keys = { + { "xx", "TroubleToggle workspace_diagnostics", desc = "Trouble Workspace Diagnostics" }, + { "xd", "TroubleToggle document_diagnostics", desc = "Trouble Document Diagnostics" }, + { "xl", "TroubleToggle loclist", desc = "Trouble Loclist" }, + { "xq", "TroubleToggle quickfix", desc = "Trouble Quickfix" }, + { "xt", "TroubleToggle lsp_references", desc = "Trouble LSP References" }, + { "xj", function() require("trouble").next({ skip_groups = true, jump = true }) end, desc = "Trouble Next" }, + { "xk", function() require("trouble").previous({ skip_groups = true, jump = true }) end, desc = "Trouble Previous" }, + }, + }, + { "wsdjeg/vim-fetch", event = "VeryLazy" }, + { "nvim-tree/nvim-web-devicons" }, + { + "eandrju/cellular-automaton.nvim", + event = "VeryLazy", + keys = { + { "mr", "CellularAutomaton make_it_rain", desc = "Make it rain" }, + }, + }, } diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua index 16c046c..4b6c066 100644 --- a/lua/plugins/git.lua +++ b/lua/plugins/git.lua @@ -1,59 +1,50 @@ return { - -- Fugitive - { - "tpope/vim-fugitive", - event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, - config = function() - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { silent = true, noremap = true, desc = desc }) - end + -- Fugitive + { + "tpope/vim-fugitive", + event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, + config = function() + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { silent = true, noremap = true, desc = desc }) + end - map("n", "gs", "Git", "Git Status") - map("n", "gd", "Gvdiffsplit!", "Git Diff") - map("n", "gbl", "Git blame", "Git Blame") - map("n", "gc", "Git commit", "Git Commit") - map("n", "gC", "Git commit --amend", "Git Commit Amend") - map("n", "gp", "Git push", "Git Push") - map("n", "gS", "Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)", "Git Push Set Upstream") - map("n", "gbs", "Git bisect start", "Git Bisect Start") - map("n", "gbg", "Git bisect good", "Git Bisect Good") - map("n", "gbb", "Git bisect bad", "Git Bisect Bad") - map("n", "gbr", "Git bisect reset", "Git Bisect Reset") - end - }, - -- Gitsigns - { - "lewis6991/gitsigns.nvim", - event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - on_attach = function(buffer) - local gs = package.loaded.gitsigns + map("n", "gd", "Gvdiffsplit!", "Git Diff") + map("n", "gl", "Git blame -w -C -C -C", "Git Blame") + map("n", "gS", "Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)", + "Git Push Set Upstream") + map("n", "gbs", "Git bisect start", "Git Bisect Start") + map("n", "gbg", "Git bisect good", "Git Bisect Good") + map("n", "gbb", "Git bisect bad", "Git Bisect Bad") + map("n", "gbr", "Git bisect reset", "Git Bisect Reset") + end + }, + -- Gitsigns + { + "lewis6991/gitsigns.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + on_attach = function(buffer) + local gs = package.loaded.gitsigns - local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) - end + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end - map("n", "]h", gs.next_hunk, "Next Hunk") - map("n", "[h", gs.prev_hunk, "Prev Hunk") - map({ "n", "v" }, "ghs", "Gitsigns stage_hunk", "Stage Hunk") - map({ "n", "v" }, "ghr", "Gitsigns reset_hunk", "Reset Hunk") - map("n", "ghS", gs.stage_buffer, "Stage Buffer") - map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") - map("n", "ghR", gs.reset_buffer, "Reset Buffer") - map("n", "ghp", gs.preview_hunk, "Preview Hunk") - map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") - map("n", "ghd", gs.diffthis, "Diff This") - map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") - map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") - end, - }, - }, + map("n", "]h", gs.next_hunk, "Next Hunk") + map("n", "[h", gs.prev_hunk, "Prev Hunk") + map({ "n", "v" }, "ghr", "Gitsigns reset_hunk", "Reset Hunk") + map("n", "ghR", gs.reset_buffer, "Reset Buffer") + map("n", "ghp", gs.preview_hunk, "Preview Hunk") + map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") + end, + }, + }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index ee18fc8..5aded5c 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,30 +1,30 @@ return { - -- LSP - { - "VonHeikemen/lsp-zero.nvim", - config = function() - require("plugins.lsp.config") - end, - dependencies = { - { "neovim/nvim-lspconfig" }, - { "williamboman/mason-lspconfig.nvim" }, - { "folke/neodev.nvim" }, - { "hrsh7th/nvim-cmp" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "saadparwaiz1/cmp_luasnip" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-nvim-lua" }, - } - }, - -- Mason - { - "williamboman/mason.nvim", - cmd = "Mason", - keys = { { "cm", "Mason", desc = "Mason" } }, - build = ":MasonUpdate", - config = function (_, opts) - require("mason").setup(opts) - end - } + -- LSP + { + "VonHeikemen/lsp-zero.nvim", + config = function() + require("plugins.lsp.config") + end, + dependencies = { + { "neovim/nvim-lspconfig" }, + { "williamboman/mason-lspconfig.nvim" }, + { "folke/neodev.nvim" }, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "saadparwaiz1/cmp_luasnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, + } + }, + -- Mason + { + "williamboman/mason.nvim", + cmd = "Mason", + keys = { { "cm", "Mason", desc = "Mason" } }, + build = ":MasonUpdate", + config = function(_, opts) + require("mason").setup(opts) + end + } } diff --git a/lua/plugins/lsp/config.lua b/lua/plugins/lsp/config.lua index 517b6d1..f8b4d80 100644 --- a/lua/plugins/lsp/config.lua +++ b/lua/plugins/lsp/config.lua @@ -1,69 +1,69 @@ -local lsp_zero = require('lsp-zero') -local lspconfig = require('lspconfig') +local lsp_zero = require("lsp-zero") +local lspconfig = require("lspconfig") lspconfig.lua_ls.setup({ - settings = { - Lua = { - diagnostics = { - globals = { 'vim' }, - }, - }, - }, + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, }) +lspconfig.eslint.setup({ + on_attach = function(_, bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end, +}) + + lsp_zero.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '' + error = "✘", + warn = "▲", + hint = "⚑", + info = "" }) vim.diagnostic.config({ - virtual_text = true, - severity_sort = true, - float = { - style = 'minimal', - border = 'none', - source = 'always', - header = '', - prefix = '', - }, + virtual_text = true, + severity_sort = true, + float = { + style = "minimal", + border = "none", + source = "always", + header = "", + prefix = "", + }, }) lsp_zero.on_attach(function(_, bufnr) - local opts = { buffer = bufnr, remap = false } - lsp_zero.default_keymaps({buffer = bufnr}) + local opts = { buffer = bufnr, remap = false } + lsp_zero.default_keymaps({ buffer = bufnr }) - vim.api.nvim_create_autocmd('BufWritePre', { - pattern = { '*.tsx', '*.ts', '*.jsx', '*.js', '*.vue', '*.cjs', '*.mjs', '*.json', '*.css', '*.scss', '*.less', '*.yml', '*.svelte' }, - command = 'silent! EslintFixAll', - group = vim.api.nvim_create_augroup('EslintAutocmdsFormatting', {}), - }) - - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set("n", "ca", function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set("n", "rr", function() vim.lsp.buf.references() end, opts) - vim.keymap.set("n", "rn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) - vim.keymap.set("n", "ls", function() vim.lsp.buf.signature_help() end, opts) - vim.keymap.set("n", "D", function() vim.lsp.buf.type_definition() end, opts) + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "ca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "rr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "rn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("n", "D", function() vim.lsp.buf.type_definition() end, opts) end) -require('mason-lspconfig').setup({ - handlers = { - lsp_zero.default_setup, - }, - ensure_installed = { - 'lua_ls', - 'html', - 'eslint', - 'gopls', - 'rust_analyzer', - 'zls', - }, +require("mason-lspconfig").setup({ + handlers = { + lsp_zero.default_setup, + }, + ensure_installed = { + "lua_ls", + "html", + "eslint", + "gopls", + "rust_analyzer", + "zls", + }, }) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index c53170d..532ca57 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,30 +1,28 @@ return { - 'nvim-telescope/telescope.nvim', - cmd = "Telescope", - version = false, - dependencies = { - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - { 'nvim-lua/plenary.nvim' }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - } - }, - keys = { - { '', "Telescope find_files", desc = 'Find files' }, - { 'ps', "Telescope live_grep", desc = 'Live Grep' }, - { 'vh', "Telescope help_tags", desc = 'Help Tags' }, - { - 'fa', - function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true }) end, - desc = 'Find all files' - }, - { 'fb', "Telescope buffers", desc = 'Find buffer' }, - { 'fc', "Telescope git_commits", desc = 'Find commits' }, - { 'fg', "Telescope git_status", desc = 'Find git status' }, - }, + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + version = false, + dependencies = { + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { "nvim-lua/plenary.nvim" }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + } + }, + keys = { + { "", "Telescope find_files", desc = "Find files" }, + { "ps", "Telescope live_grep", desc = "Live Grep" }, + { + "fa", + function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true }) end, + desc = "Find all files" + }, + { "fb", "Telescope buffers", desc = "Find buffer" }, + { "fc", "Telescope git_commits", desc = "Find commits" }, + }, } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index bb4ecae..de69dec 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,63 +1,63 @@ return { - { - "nvim-treesitter/nvim-treesitter", - version = false, - build = ":TSUpdate", - event = { "BufReadPost", "BufWritePost", "BufNewFile", "VeryLazy" }, - init = function(plugin) - require("lazy.core.loader").add_to_rtp(plugin) - require("nvim-treesitter.query_predicates") - end, - cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, - keys = { - { "", desc = "Increment selection" }, - { "", desc = "Decrement selection", mode = "x" }, - }, - opts = { - highlight = { - enable = true, - additional_vim_regex_highlighting = { "php", "twig" }, - }, - auto_install = true, - indent = { enable = true }, - ensure_installed = { "lua", "vim", "vimdoc", "typescript", "javascript", "go", "c", "cpp", "rust", "zig", "html", "css" }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - end, - }, + { + "nvim-treesitter/nvim-treesitter", + version = false, + build = ":TSUpdate", + event = { "BufReadPost", "BufWritePost", "BufNewFile", "VeryLazy" }, + init = function(plugin) + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, + keys = { + { "", desc = "Increment selection" }, + { "", desc = "Decrement selection", mode = "x" }, + }, + opts = { + highlight = { + enable = true, + additional_vim_regex_highlighting = { "php", "twig" }, + }, + auto_install = true, + indent = { enable = true }, + ensure_installed = { "lua", "vim", "vimdoc", "typescript", "javascript", "go", "c", "cpp", "rust", "zig", "html", "css" }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, - -- Show context of the current function - { - "nvim-treesitter/nvim-treesitter-context", - event = { "BufReadPost", "BufWritePost", "BufNewFile" }, - enabled = true, - opts = { mode = "cursor", max_lines = 3 }, - keys = { - { - "ut", - function() - local tsc = require("treesitter-context") - tsc.toggle() - end, - desc = "Toggle Treesitter Context", - }, - }, - }, + -- Show context of the current function + { + "nvim-treesitter/nvim-treesitter-context", + event = { "BufReadPost", "BufWritePost", "BufNewFile" }, + enabled = true, + opts = { mode = "cursor", max_lines = 3 }, + keys = { + { + "ut", + function() + local tsc = require("treesitter-context") + tsc.toggle() + end, + desc = "Toggle Treesitter Context", + }, + }, + }, - -- Automatically add closing tags for HTML and JSX - { - "windwp/nvim-ts-autotag", - event = { "BufReadPost", "BufWritePost", "BufNewFile" }, - opts = {}, - }, + -- Automatically add closing tags for HTML and JSX + { + "windwp/nvim-ts-autotag", + event = { "BufReadPost", "BufWritePost", "BufNewFile" }, + opts = {}, + }, }