diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 95da0db..82d7b54 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -18,189 +18,168 @@ end -- This file is automatically loaded by lazyvim.config.init. local function augroup(name) - return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true }) + return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true }) end -- Check if we need to reload the file when it changed vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { - group = augroup("checktime"), - callback = function() - if vim.o.buftype ~= "nofile" then - vim.cmd("checktime") - end - end, + group = augroup("checktime"), + callback = function() + if vim.o.buftype ~= "nofile" then + vim.cmd("checktime") + end + end, }) -- Highlight on yank vim.api.nvim_create_autocmd("TextYankPost", { - group = augroup("highlight_yank"), - callback = function() - vim.highlight.on_yank() - end, + group = augroup("highlight_yank"), + callback = function() + (vim.hl or vim.highlight).on_yank() + end, }) -- resize splits if window got resized vim.api.nvim_create_autocmd({ "VimResized" }, { - group = augroup("resize_splits"), - callback = function() - local current_tab = vim.fn.tabpagenr() - vim.cmd("tabdo wincmd =") - vim.cmd("tabnext " .. current_tab) - end, + group = augroup("resize_splits"), + callback = function() + local current_tab = vim.fn.tabpagenr() + vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) + end, }) -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { - group = augroup("last_loc"), - callback = function(event) - local exclude = { "gitcommit" } - local buf = event.buf - if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then - return - end - vim.b[buf].lazyvim_last_loc = true - local mark = vim.api.nvim_buf_get_mark(buf, '"') - local lcount = vim.api.nvim_buf_line_count(buf) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, + group = augroup("last_loc"), + callback = function(event) + local exclude = { "gitcommit" } + local buf = event.buf + if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then + return + end + vim.b[buf].lazyvim_last_loc = true + local mark = vim.api.nvim_buf_get_mark(buf, '"') + local lcount = vim.api.nvim_buf_line_count(buf) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, }) -- close some filetypes with vim.api.nvim_create_autocmd("FileType", { - group = augroup("close_with_q"), - pattern = { - "PlenaryTestPopup", - "grug-far", - "help", - "lspinfo", - "notify", - "qf", - "spectre_panel", - "startuptime", - "tsplayground", - "neotest-output", - "checkhealth", - "neotest-summary", - "neotest-output-panel", - "dbout", - "gitsigns.blame", - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "q", "close", { - buffer = event.buf, - silent = true, - desc = "Quit buffer", - }) - end, + group = augroup("close_with_q"), + pattern = { + "PlenaryTestPopup", + "checkhealth", + "dbout", + "gitsigns-blame", + "grug-far", + "help", + "lspinfo", + "neotest-output", + "neotest-output-panel", + "neotest-summary", + "notify", + "qf", + "spectre_panel", + "startuptime", + "tsplayground", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.schedule(function() + vim.keymap.set("n", "q", function() + vim.cmd("close") + pcall(vim.api.nvim_buf_delete, event.buf, { force = true }) + end, { + buffer = event.buf, + silent = true, + desc = "Quit buffer", + }) + end) + end, }) -- make it easier to close man-files when opened inline vim.api.nvim_create_autocmd("FileType", { - group = augroup("man_unlisted"), - pattern = { "man" }, - callback = function(event) - vim.bo[event.buf].buflisted = false - end, + group = augroup("man_unlisted"), + pattern = { "man" }, + callback = function(event) + vim.bo[event.buf].buflisted = false + end, }) -- wrap and check for spell in text filetypes vim.api.nvim_create_autocmd("FileType", { - group = augroup("wrap_spell"), - pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.spell = true - end, + group = augroup("wrap_spell"), + pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, }) -- Fix conceallevel for json files vim.api.nvim_create_autocmd({ "FileType" }, { - group = augroup("json_conceal"), - pattern = { "json", "jsonc", "json5" }, - callback = function() - vim.opt_local.conceallevel = 0 - end, + group = augroup("json_conceal"), + pattern = { "json", "jsonc", "json5" }, + callback = function() + vim.opt_local.conceallevel = 0 + end, }) -- Auto create dir when saving a file, in case some intermediate directory does not exist vim.api.nvim_create_autocmd({ "BufWritePre" }, { - group = augroup("auto_create_dir"), - callback = function(event) - if event.match:match("^%w%w+:[\\/][\\/]") then - return - end - local file = vim.uv.fs_realpath(event.match) or event.match - vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") - end, + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+:[\\/][\\/]") then + return + end + local file = vim.uv.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, }) -vim.filetype.add({ - pattern = { - [".*"] = { - function(path, buf) - return vim.bo[buf] - and vim.bo[buf].filetype ~= "bigfile" - and path - and vim.fn.getfsize(path) > vim.g.bigfile_size - and "bigfile" - or nil - end, - }, - }, -}) +local function insert_file_header() + local filename = vim.fn.expand('%:t') + local date = os.date('%Y-%m-%d') + + local author = vim.fn.system("git config user.name") + author = author:gsub("\n", "") + + local header_lines = { + string.format("File: %s", filename), + string.format("Author: %s", author), + string.format("Date: %s", date), + "Description: " + } + + local max_length = 0 + for _, line in ipairs(header_lines) do + if #line > max_length then + max_length = #line + end + end -vim.api.nvim_create_autocmd({ "FileType" }, { - group = augroup("bigfile"), - pattern = "bigfile", - callback = function(ev) - vim.b.minianimate_disable = true - vim.schedule(function() - vim.bo[ev.buf].syntax = vim.filetype.match({ buf = ev.buf }) or "" - end) - end, -}) + local border_length = max_length + 2 -- 1 for space, 1 for `#` + local border_line = string.rep("#", border_length) -local function insert_file_header() - local filename = vim.fn.expand('%:t') - local date = os.date('%Y-%m-%d') - - local author = vim.fn.system("git config user.name") - author = author:gsub("\n", "") - - local header_lines = { - string.format("File: %s", filename), - string.format("Author: %s", author), - string.format("Date: %s", date), - "Description: " - } - - local max_length = 0 - for _, line in ipairs(header_lines) do - if #line > max_length then - max_length = #line + local header = border_line .. "\n" + for _, line in ipairs(header_lines) do + local padded_line = "# " .. line -- remove # in right side + header = header .. padded_line .. "\n" end - end - - local border_length = max_length + 2 -- 1 for space, 1 for `#` - local border_line = string.rep("#", border_length) - - local header = border_line .. "\n" - for _, line in ipairs(header_lines) do - local padded_line = "# " .. line -- remove # in right side - header = header .. padded_line .. "\n" - end - header = header .. border_line .. "\n" - - vim.api.nvim_buf_set_lines(0, 0, 0, false, vim.split(header, '\n')) + header = header .. border_line .. "\n" + + vim.api.nvim_buf_set_lines(0, 0, 0, false, vim.split(header, '\n')) end -- check config for whether enable_file_header if vim.g.enable_file_header then - vim.api.nvim_create_autocmd("BufNewFile", { - pattern = "*", - callback = insert_file_header, - }) + vim.api.nvim_create_autocmd("BufNewFile", { + pattern = "*", + callback = insert_file_header, + }) end diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 601acc3..5fa4069 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -1,51 +1,52 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - -- bootstrap lazy.nvim - -- stylua: ignore - vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", - lazypath }) + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", + lazypath }) end vim.opt.rtp:prepend(vim.env.LAZY or lazypath) require("lazy").setup({ - spec = { - -- add LazyVim and import its plugins - { "LazyVim/LazyVim", import = "lazyvim.plugins" }, - { import = "lazyvim.plugins.extras.ui.edgy" }, - -- import any extras modules here - { import = "lazyvim.plugins.extras.lang.typescript" }, - { import = "lazyvim.plugins.extras.ui.mini-animate" }, - { import = "lazyvim.plugins.extras.util.gitui" }, - { import = "lazyvim.plugins.extras.editor.fzf" }, - { import = "lazyvim.plugins.extras.editor.inc-rename" }, - -- { import = "lazyvim.plugins.extras.lang.json" }, - -- import/override with your plugins - { import = "plugins" }, - }, - defaults = { - -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. - -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. - lazy = false, - -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, - -- have outdated releases, which may break your Neovim install. - version = false, -- always use the latest git commit - -- version = "*", -- try installing the latest stable version for plugins that support semver - }, - install = { colorscheme = { "catppuccin" } }, - checker = { enabled = true }, -- automatically check for plugin updates - performance = { - rtp = { - -- disable some rtp plugins - disabled_plugins = { - "gzip", - -- "matchit", - -- "matchparen", - -- "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + { import = "lazyvim.plugins.extras.ui.edgy" }, + -- import any extras modules here + { import = "lazyvim.plugins.extras.lang.typescript" }, + { import = "lazyvim.plugins.extras.ui.mini-animate" }, + { import = "lazyvim.plugins.extras.util.gitui" }, + { import = "lazyvim.plugins.extras.editor.fzf" }, + { import = "lazyvim.plugins.extras.editor.inc-rename" }, + { import = "lazyvim.plugins.extras.coding.blink" }, + -- { import = "lazyvim.plugins.extras.lang.json" }, + -- import/override with your plugins + { import = "plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + -- version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "catppuccin" } }, + checker = { enabled = true }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, }, - }, }) diff --git a/lua/config/options.lua b/lua/config/options.lua index c7792c3..70ae8f9 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -38,66 +38,66 @@ opt.autowrite = true -- Enable auto write -- integration works automatically. Requires Neovim >= 0.10.0 opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard opt.completeopt = "menu,menuone,noselect" -opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions -opt.confirm = true -- Confirm to save changes before exiting modified buffer -opt.cursorline = true -- Enable highlighting of the current line -opt.expandtab = true -- Use spaces instead of tabs +opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions +opt.confirm = true -- Confirm to save changes before exiting modified buffer +opt.cursorline = true -- Enable highlighting of the current line +opt.expandtab = true -- Use spaces instead of tabs opt.fillchars = { - foldopen = "", - foldclose = "", - fold = " ", - foldsep = " ", - diff = "╱", - eob = " ", + foldopen = "", + foldclose = "", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", } opt.foldlevel = 99 opt.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()" opt.formatoptions = "jcroqlnt" -- tcqj opt.grepformat = "%f:%l:%c:%m" opt.grepprg = "rg --vimgrep" -opt.ignorecase = true -- Ignore case -opt.inccommand = "nosplit" -- preview incremental substitute -opt.laststatus = 3 -- global statusline -opt.list = true -- Show some invisible characters (tabs... -opt.mouse = "a" -- Enable mouse mode -opt.number = true -- Print line number -opt.pumblend = 10 -- Popup blend -opt.pumheight = 10 -- Maximum number of entries in a popup -opt.relativenumber = false -- Relative line numbers -opt.scrolloff = 1 -- Lines of context +opt.ignorecase = true -- Ignore case +opt.inccommand = "nosplit" -- preview incremental substitute +opt.laststatus = 3 -- global statusline +opt.list = true -- Show some invisible characters (tabs... +opt.mouse = "a" -- Enable mouse mode +opt.number = true -- Print line number +opt.pumblend = 10 -- Popup blend +opt.pumheight = 10 -- Maximum number of entries in a popup +opt.relativenumber = false -- Relative line numbers +opt.scrolloff = 1 -- Lines of context opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" } -opt.shiftround = true -- Round indent -opt.shiftwidth = 4 -- Size of an indent +opt.shiftround = true -- Round indent +opt.shiftwidth = 4 -- Size of an indent opt.shortmess:append({ W = true, I = true, c = true, C = true }) -opt.showmode = false -- Dont show mode since we have a statusline -opt.sidescrolloff = 8 -- Columns of context -opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time -opt.smartcase = true -- Don't ignore case with capitals -opt.smartindent = true -- Insert indents automatically +opt.showmode = false -- Dont show mode since we have a statusline +opt.sidescrolloff = 8 -- Columns of context +opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +opt.smartcase = true -- Don't ignore case with capitals +opt.smartindent = true -- Insert indents automatically opt.spelllang = { "en" } -opt.splitbelow = true -- Put new windows below current +opt.splitbelow = true -- Put new windows below current opt.splitkeep = "screen" -opt.splitright = true -- Put new windows right of current +opt.splitright = true -- Put new windows right of current opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]] -opt.tabstop = 4 -- Number of spaces tabs count for -opt.termguicolors = true -- True color support +opt.tabstop = 4 -- Number of spaces tabs count for +opt.termguicolors = true -- True color support opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key opt.undofile = true opt.undolevels = 10000 -opt.updatetime = 200 -- Save swap file and trigger CursorHold -opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode +opt.updatetime = 200 -- Save swap file and trigger CursorHold +opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode opt.wildmode = "longest:full,full" -- Command-line completion mode -opt.winminwidth = 5 -- Minimum window width -opt.wrap = true -- Eisable line wrap +opt.winminwidth = 5 -- Minimum window width +opt.wrap = true -- Eisable line wrap if vim.fn.has("nvim-0.10") == 1 then - opt.smoothscroll = true - opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()" - opt.foldmethod = "expr" - opt.foldtext = "" + opt.smoothscroll = true + opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()" + opt.foldmethod = "expr" + opt.foldtext = "" else - opt.foldmethod = "indent" - opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()" + opt.foldmethod = "indent" + opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()" end -- Fix markdown indentation settings diff --git a/lua/plugins/blink-cmp.lua b/lua/plugins/blink-cmp.lua new file mode 100644 index 0000000..340f7a0 --- /dev/null +++ b/lua/plugins/blink-cmp.lua @@ -0,0 +1,151 @@ +return { + "saghen/blink.cmp", + version = not vim.g.lazyvim_blink_main and "*", + build = vim.g.lazyvim_blink_main and "cargo build --release", + opts_extend = { + "sources.completion.enabled_providers", + "sources.compat", + "sources.default", + }, + dependencies = { + "rafamadriz/friendly-snippets", + -- add blink.compat to dependencies + { + "saghen/blink.compat", + optional = true, -- make optional so it's only enabled if any extras need it + opts = {}, + version = not vim.g.lazyvim_blink_main and "*", + }, + }, + event = "InsertEnter", + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + snippets = { + expand = function(snippet, _) + return LazyVim.cmp.expand(snippet) + end, + }, + appearance = { + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = false, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + completion = { + accept = { + -- experimental auto-brackets support + auto_brackets = { + enabled = true, + }, + }, + menu = { + draw = { + treesitter = { "lsp" }, + }, + }, + documentation = { + auto_show = true, + auto_show_delay_ms = 200, + }, + ghost_text = { + enabled = vim.g.ai_cmp, + }, + }, + + -- experimental signature help support + -- signature = { enabled = true }, + + sources = { + -- adding any nvim-cmp sources here will enable them + -- with blink.compat + compat = {}, + default = { "lsp", "path", "snippets", "buffer" }, + cmdline = {}, + }, + + keymap = { + preset = "enter", + [""] = { "select_and_accept" }, + }, + }, + ---@param opts blink.cmp.Config | { sources: { compat: string[] } } + config = function(_, opts) + -- setup compat sources + local enabled = opts.sources.default + for _, source in ipairs(opts.sources.compat or {}) do + opts.sources.providers[source] = vim.tbl_deep_extend( + "force", + { name = source, module = "blink.compat.source" }, + opts.sources.providers[source] or {} + ) + if type(enabled) == "table" and not vim.tbl_contains(enabled, source) then + table.insert(enabled, source) + end + end + + -- add ai_accept to key + if not opts.keymap[""] then + if opts.keymap.preset == "super-tab" then -- super-tab + opts.keymap[""] = { + require("blink.cmp.keymap.presets")["super-tab"][""][1], + LazyVim.cmp.map({ "snippet_forward", "ai_accept" }), + "fallback", + } + else -- other presets + opts.keymap[""] = { + LazyVim.cmp.map({ "snippet_forward", "ai_accept" }), + "fallback", + } + end + end + + --- NOTE: compat with latest version. Currenlty 0.7.6 + if not vim.g.lazyvim_blink_main then + ---@diagnostic disable-next-line: inject-field + opts.sources.completion = opts.sources.completion or {} + opts.sources.completion.enabled_providers = enabled + if vim.tbl_get(opts, "completion", "menu", "draw", "treesitter") then + ---@diagnostic disable-next-line: assign-type-mismatch + opts.completion.menu.draw.treesitter = true + end + end + + -- Unset custom prop to pass blink.cmp validation + opts.sources.compat = nil + + -- check if we need to override symbol kinds + for _, provider in pairs(opts.sources.providers or {}) do + ---@cast provider blink.cmp.SourceProviderConfig|{kind?:string} + if provider.kind then + local CompletionItemKind = require("blink.cmp.types").CompletionItemKind + local kind_idx = #CompletionItemKind + 1 + + CompletionItemKind[kind_idx] = provider.kind + ---@diagnostic disable-next-line: no-unknown + CompletionItemKind[provider.kind] = kind_idx + + ---@type fun(ctx: blink.cmp.Context, items: blink.cmp.CompletionItem[]): blink.cmp.CompletionItem[] + local transform_items = provider.transform_items + ---@param ctx blink.cmp.Context + ---@param items blink.cmp.CompletionItem[] + provider.transform_items = function(ctx, items) + items = transform_items and transform_items(ctx, items) or items + for _, item in ipairs(items) do + item.kind = kind_idx or item.kind + end + return items + end + + -- Unset custom prop to pass blink.cmp validation + provider.kind = nil + end + end + + require("blink.cmp").setup(opts) + end, +} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 6aeaf34..7217dcb 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,66 +1,67 @@ return { - { - "catppuccin/nvim", - name = "catppuccin", - lazy = true, - opts = { - colorscheme = "catppuccin", - integrations = { - aerial = true, - alpha = true, - cmp = true, - dashboard = true, - flash = true, - gitsigns = true, - headlines = true, - illuminate = true, - indent_blankline = { enabled = true }, - leap = true, - lsp_trouble = true, - mason = true, - markdown = true, - mini = true, - native_lsp = { - enabled = true, - underlines = { - errors = { "undercurl" }, - hints = { "undercurl" }, - warnings = { "undercurl" }, - information = { "undercurl" }, - }, + { + "catppuccin/nvim", + name = "catppuccin", + lazy = true, + opts = { + colorscheme = "catppuccin", + integrations = { + aerial = true, + alpha = true, + cmp = true, + blink_cmp = true, + dashboard = true, + flash = true, + gitsigns = true, + headlines = true, + illuminate = true, + indent_blankline = { enabled = true }, + leap = true, + lsp_trouble = true, + mason = true, + markdown = true, + mini = true, + native_lsp = { + enabled = true, + underlines = { + errors = { "undercurl" }, + hints = { "undercurl" }, + warnings = { "undercurl" }, + information = { "undercurl" }, + }, + }, + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + -- miscs = {}, -- Uncomment to turn off hard-coded styles + }, + navic = { enabled = true, custom_bg = "lualine" }, + neotest = true, + neotree = true, + noice = true, + notify = true, + semantic_tokens = true, + telescope = true, + treesitter = true, + treesitter_context = true, + which_key = true, + }, }, - styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): - comments = { "italic" }, -- Change the style of comments - conditionals = { "italic" }, - loops = {}, - functions = {}, - keywords = {}, - strings = {}, - variables = {}, - numbers = {}, - booleans = {}, - properties = {}, - types = {}, - operators = {}, - -- miscs = {}, -- Uncomment to turn off hard-coded styles - }, - navic = { enabled = true, custom_bg = "lualine" }, - neotest = true, - neotree = true, - noice = true, - notify = true, - semantic_tokens = true, - telescope = true, - treesitter = true, - treesitter_context = true, - which_key = true, - }, }, - }, - { - "LazyVim/LazyVim", - opts = { - colorscheme = "catppuccin-mocha", + { + "LazyVim/LazyVim", + opts = { + colorscheme = "catppuccin-mocha", + }, }, - }, } diff --git a/lua/plugins/conform-nvim.lua b/lua/plugins/conform-nvim.lua index aa7355e..42b3c89 100644 --- a/lua/plugins/conform-nvim.lua +++ b/lua/plugins/conform-nvim.lua @@ -35,19 +35,19 @@ return { end, opts = function() local plugin = require("lazy.core.config").plugins["conform.nvim"] --- if plugin.config ~= M.setup then --- LazyVim.error({ --- "Don't set `plugin.config` for `conform.nvim`.\n", --- "This will break **LazyVim** formatting.\n", --- "Please refer to the docs at https://www.lazyvim.org/plugins/formatting", --- }, { title = "LazyVim" }) --- end + -- if plugin.config ~= M.setup then + -- LazyVim.error({ + -- "Don't set `plugin.config` for `conform.nvim`.\n", + -- "This will break **LazyVim** formatting.\n", + -- "Please refer to the docs at https://www.lazyvim.org/plugins/formatting", + -- }, { title = "LazyVim" }) + -- end ---@type conform.setupOpts local opts = { default_format_opts = { timeout_ms = 3000, - async = false, -- not recommended to change - quiet = false, -- not recommended to change + async = false, -- not recommended to change + quiet = false, -- not recommended to change lsp_format = "fallback", -- not recommended to change }, formatters_by_ft = { diff --git a/lua/plugins/dashboard-nvim.lua b/lua/plugins/dashboard-nvim.lua index cd8cab5..0d8dc30 100644 --- a/lua/plugins/dashboard-nvim.lua +++ b/lua/plugins/dashboard-nvim.lua @@ -1,8 +1,8 @@ return { - "nvimdev/dashboard-nvim", - lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin. - opts = function() - local logo = [[ + "nvimdev/dashboard-nvim", + lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin. + opts = function() + local logo = [[ █████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗ ██╔══██╗████╗ ██║██║ ██║██║████╗ ████║ ███████║██╔██╗ ██║██║ ██║██║██╔████╔██║ @@ -11,18 +11,18 @@ return { ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ A pre-configured nvim based on LazyVim ]] - -- http://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=ANVim%20 - logo = string.rep("\n", 8) .. logo .. "\n\n" + -- http://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=ANVim%20 + logo = string.rep("\n", 8) .. logo .. "\n\n" - local opts = { - theme = "doom", - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = vim.split(logo, "\n"), + local opts = { + theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, + config = { + header = vim.split(logo, "\n"), -- stylua: ignore center = { { action = LazyVim.pick(), desc = " Find File", icon = " ", key = "f" }, @@ -35,30 +35,30 @@ A pre-configured nvim based on LazyVim { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { " ANVim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } - end, - }, - } + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { " ANVim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } + end, + }, + } - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" - end + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + button.key_format = " %s" + end - -- close Lazy and re-open when the dashboard is ready - if vim.o.filetype == "lazy" then - vim.cmd.close() - vim.api.nvim_create_autocmd("User", { - pattern = "DashboardLoaded", - callback = function() - require("lazy").show() - end, - }) - end + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardLoaded", + callback = function() + require("lazy").show() + end, + }) + end - return opts - end, + return opts + end, } diff --git a/lua/plugins/git-blame.lua b/lua/plugins/git-blame.lua index becb883..0deb2e5 100644 --- a/lua/plugins/git-blame.lua +++ b/lua/plugins/git-blame.lua @@ -1,8 +1,8 @@ -return{ - "f-person/git-blame.nvim", - event = "BufRead", - config = function() - vim.cmd "highlight default link gitblame SpecialComment" - require("gitblame").setup { enabled = false } - end, +return { + "f-person/git-blame.nvim", + event = "BufRead", + config = function() + vim.cmd "highlight default link gitblame SpecialComment" + require("gitblame").setup { enabled = false } + end, } diff --git a/lua/plugins/git-diff.lua b/lua/plugins/git-diff.lua index 728b724..b9333ea 100644 --- a/lua/plugins/git-diff.lua +++ b/lua/plugins/git-diff.lua @@ -1,4 +1,4 @@ -return{ - "sindrets/diffview.nvim", - event = "BufRead", +return { + "sindrets/diffview.nvim", + event = "BufRead", } diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index f4a058e..cd42d89 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,36 +1,36 @@ return { - "lewis6991/gitsigns.nvim", - event = "LazyFile", - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - signs_staged = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - }, - current_line_blame = true, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "right_align", -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - virt_text_priority = 100, - }, - on_attach = function(buffer) - local gs = package.loaded.gitsigns + "lewis6991/gitsigns.nvim", + event = "LazyFile", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + signs_staged = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + }, + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "right_align", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + }, + 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 -- stylua: ignore start map("n", "]h", function() @@ -60,6 +60,6 @@ return { 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, - }, + end, + }, } diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua index 9b77cd4..66db197 100644 --- a/lua/plugins/indent-blankline.lua +++ b/lua/plugins/indent-blankline.lua @@ -1,39 +1,41 @@ return { - "lukas-reineke/indent-blankline.nvim", - event = "LazyFile", - opts = function() - LazyVim.toggle.map("ug", { - name = "Indention Guides", - get = function() - return require("ibl.config").get_config(0).enabled - end, - set = function(state) - require("ibl").setup_buffer(0, { enabled = state }) - end, - }) + "lukas-reineke/indent-blankline.nvim", + event = "LazyFile", + opts = function() + Snacks.toggle({ + name = "Indention Guides", + get = function() + return require("ibl.config").get_config(0).enabled + end, + set = function(state) + require("ibl").setup_buffer(0, { enabled = state }) + end, + }):map("ug") - return { - indent = { - char = "│", - tab_char = "│", - }, - scope = { show_start = true, show_end = false }, - exclude = { - filetypes = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", - }, - }, - } - end, - main = "ibl", + return { + indent = { + char = "│", + tab_char = "│", + }, + scope = { show_start = false, show_end = false }, + exclude = { + filetypes = { + "Trouble", + "alpha", + "dashboard", + "help", + "lazy", + "mason", + "neo-tree", + "notify", + "snacks_notif", + "snacks_terminal", + "snacks_win", + "toggleterm", + "trouble", + }, + }, + } + end, + main = "ibl", } diff --git a/lua/plugins/lazydev.lua b/lua/plugins/lazydev.lua index 00e59f2..5cbad80 100644 --- a/lua/plugins/lazydev.lua +++ b/lua/plugins/lazydev.lua @@ -1,13 +1,13 @@ return { "folke/lazydev.nvim", ft = "lua", - opts = function() - return { - library = { - uv = "luvit-meta/library", - lazyvim = "LazyVim", - }, - } - end, + cmd = "LazyDev", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, + { path = "LazyVim", words = { "LazyVim" } }, + { path = "snacks.nvim", words = { "Snacks" } }, + { path = "lazy.nvim", words = { "LazyVim" } }, + }, + }, } - diff --git a/lua/plugins/livecode.lua b/lua/plugins/livecode.lua index ba401dc..cf53da5 100644 --- a/lua/plugins/livecode.lua +++ b/lua/plugins/livecode.lua @@ -1,6 +1,6 @@ return { "jxm35/livecode.nvim", - config = function () + config = function() -- get current username local git_username = vim.fn.system("git config user.name") git_username = git_username:gsub("\n", "") -- remove \n diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua deleted file mode 100644 index 81e856b..0000000 --- a/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,78 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - version = false, -- last release is way too old - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - }, - -- Not all LSP servers add brackets when completing a function. - -- To better deal with this, LazyVim adds a custom option to cmp, - -- that you can configure. For example: - -- - -- ```lua - -- opts = { - -- auto_brackets = { "python" } - -- } - -- ``` - opts = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - local auto_select = true - return { - auto_brackets = {}, -- configure any filetype to auto add brackets - completion = { - completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect"), - }, - preselect = auto_select and cmp.PreselectMode.Item or cmp.PreselectMode.None, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = LazyVim.cmp.confirm({ select = auto_select }), - [""] = LazyVim.cmp.confirm({ select = true }), - [""] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- 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" }, - }), - formatting = { - format = function(entry, item) - local icons = LazyVim.config.icons.kinds - if icons[item.kind] then - item.kind = icons[item.kind] .. item.kind - end - - local widths = { - abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40, - menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30, - } - - for key, width in pairs(widths) do - if item[key] and vim.fn.strdisplaywidth(item[key]) > width then - item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…" - end - end - - return item - end, - }, - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, - sorting = defaults.sorting, - } - end, - main = "lazyvim.util.cmp", -} diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua index c57e349..f1b854e 100644 --- a/lua/plugins/nvim-lint.lua +++ b/lua/plugins/nvim-lint.lua @@ -1,99 +1,99 @@ return { - "mfussenegger/nvim-lint", - event = "LazyFile", - opts = { - -- Event to trigger linters - events = { "BufWritePost", "BufReadPost", "InsertLeave" }, - linters_by_ft = { - fish = { "fish" }, - sh = { "shellcheck" }, - markdown = { "markdownlint-cli2" }, - -- Use the "*" filetype to run linters on all filetypes. - -- ['*'] = { 'global linter' }, - -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. - -- ['_'] = { 'fallback linter' }, - -- ["*"] = { "typos" }, + "mfussenegger/nvim-lint", + event = "LazyFile", + opts = { + -- Event to trigger linters + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + linters_by_ft = { + fish = { "fish" }, + sh = { "shellcheck" }, + markdown = { "markdownlint-cli2" }, + -- Use the "*" filetype to run linters on all filetypes. + -- ['*'] = { 'global linter' }, + -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. + -- ['_'] = { 'fallback linter' }, + -- ["*"] = { "typos" }, + }, + -- LazyVim extension to easily override linter options + -- or add custom linters. + ---@type table + linters = { + -- -- Example of using selene only when a selene.toml file is present + -- selene = { + -- -- `condition` is another LazyVim extension that allows you to + -- -- dynamically enable/disable linters based on the context. + -- condition = function(ctx) + -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + }, }, - -- LazyVim extension to easily override linter options - -- or add custom linters. - ---@type table - linters = { - -- -- Example of using selene only when a selene.toml file is present - -- selene = { - -- -- `condition` is another LazyVim extension that allows you to - -- -- dynamically enable/disable linters based on the context. - -- condition = function(ctx) - -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] - -- end, - -- }, - }, - }, - config = function(_, opts) - local M = {} + config = function(_, opts) + local M = {} + + local lint = require("lint") + for name, linter in pairs(opts.linters) do + if type(linter) == "table" and type(lint.linters[name]) == "table" then + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + if type(linter.prepend_args) == "table" then + lint.linters[name].args = lint.linters[name].args or {} + vim.list_extend(lint.linters[name].args, linter.prepend_args) + end + else + lint.linters[name] = linter + end + end + lint.linters_by_ft = opts.linters_by_ft - local lint = require("lint") - for name, linter in pairs(opts.linters) do - if type(linter) == "table" and type(lint.linters[name]) == "table" then - lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) - if type(linter.prepend_args) == "table" then - lint.linters[name].args = lint.linters[name].args or {} - vim.list_extend(lint.linters[name].args, linter.prepend_args) + function M.debounce(ms, fn) + local timer = vim.uv.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end end - else - lint.linters[name] = linter - end - end - lint.linters_by_ft = opts.linters_by_ft - function M.debounce(ms, fn) - local timer = vim.uv.new_timer() - return function(...) - local argv = { ... } - timer:start(ms, 0, function() - timer:stop() - vim.schedule_wrap(fn)(unpack(argv)) - end) - end - end + function M.lint() + -- Use nvim-lint's logic first: + -- * checks if linters exist for the full filetype first + -- * otherwise will split filetype by "." and add all those linters + -- * this differs from conform.nvim which only uses the first filetype that has a formatter + local names = lint._resolve_linter_by_ft(vim.bo.filetype) - function M.lint() - -- Use nvim-lint's logic first: - -- * checks if linters exist for the full filetype first - -- * otherwise will split filetype by "." and add all those linters - -- * this differs from conform.nvim which only uses the first filetype that has a formatter - local names = lint._resolve_linter_by_ft(vim.bo.filetype) + -- Create a copy of the names table to avoid modifying the original. + names = vim.list_extend({}, names) - -- Create a copy of the names table to avoid modifying the original. - names = vim.list_extend({}, names) + -- Add fallback linters. + if #names == 0 then + vim.list_extend(names, lint.linters_by_ft["_"] or {}) + end - -- Add fallback linters. - if #names == 0 then - vim.list_extend(names, lint.linters_by_ft["_"] or {}) - end + -- Add global linters. + vim.list_extend(names, lint.linters_by_ft["*"] or {}) - -- Add global linters. - vim.list_extend(names, lint.linters_by_ft["*"] or {}) + -- Filter out linters that don't exist or don't match the condition. + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + if not linter then + LazyVim.warn("Linter not found: " .. name, { title = "nvim-lint" }) + end + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) + end, names) - -- Filter out linters that don't exist or don't match the condition. - local ctx = { filename = vim.api.nvim_buf_get_name(0) } - ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") - names = vim.tbl_filter(function(name) - local linter = lint.linters[name] - if not linter then - LazyVim.warn("Linter not found: " .. name, { title = "nvim-lint" }) + -- Run linters. + if #names > 0 then + lint.try_lint(names) + end end - return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) - end, names) - - -- Run linters. - if #names > 0 then - lint.try_lint(names) - end - end - vim.api.nvim_create_autocmd(opts.events, { - group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), - callback = M.debounce(100, M.lint), - }) - end, + vim.api.nvim_create_autocmd(opts.events, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, } diff --git a/lua/plugins/nvim-notify.lua b/lua/plugins/nvim-notify.lua deleted file mode 100644 index 323111b..0000000 --- a/lua/plugins/nvim-notify.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - "rcarriga/nvim-notify", - keys = { - { - "un", - function() - require("notify").dismiss({ silent = true, pending = true }) - end, - desc = "Dismiss All Notifications", - }, - }, - opts = { - stages = "static", - timeout = 3000, - max_height = function() - return math.floor(vim.o.lines * 0.75) - end, - max_width = function() - return math.floor(vim.o.columns * 0.75) - end, - on_open = function(win) - vim.api.nvim_win_set_config(win, { zindex = 100 }) - end, - }, - init = function() - -- when noice is not enabled, install notify on VeryLazy - if not LazyVim.has("noice.nvim") then - LazyVim.on_very_lazy(function() - vim.notify = require("notify") - end) - end - end, -} diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..06c3bca --- /dev/null +++ b/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,79 @@ +return { + "nvim-treesitter/nvim-treesitter", + version = false, -- last release is way too old and doesn't work on Windows + build = ":TSUpdate", + event = { "LazyFile", "VeryLazy" }, + lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer trigger the **nvim-treesitter** module to be loaded in time. + -- Luckily, the only things that those plugins need are the custom queries, which we make available + -- during startup. + 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_extend = { "ensure_installed" }, + ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + "bash", + "c", + "diff", + "html", + "javascript", + "jsdoc", + "json", + "jsonc", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "printf", + "python", + "query", + "regex", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + textobjects = { + move = { + enable = true, + goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" }, + goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" }, + goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" }, + goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" }, + }, + }, + }, + ---@param opts TSConfig + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + opts.ensure_installed = LazyVim.dedup(opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + end, +} diff --git a/lua/plugins/snacks-nvim.lua b/lua/plugins/snacks-nvim.lua new file mode 100644 index 0000000..4d1d383 --- /dev/null +++ b/lua/plugins/snacks-nvim.lua @@ -0,0 +1,82 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + border = "rounded", + }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + wo = { wrap = true } -- Wrap notifications + } + } + }, + keys = { + { "un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, + { "bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "gg", function() Snacks.lazygit() end, desc = "Lazygit" }, + { "gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" }, + { "gB", function() Snacks.gitbrowse() end, desc = "Git Browse" }, + { "gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" }, + { "gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" }, + { "cR", function() Snacks.rename() end, desc = "Rename File" }, + { "", function() Snacks.terminal() end, desc = "Toggle Terminal" }, + { "", function() Snacks.terminal() end, desc = "which_key_ignore" }, + { "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } }, + { "[[", function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference", mode = { "n", "t" } }, + { + "N", + desc = "Neovim News", + function() + Snacks.win({ + file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = "yes", + statuscolumn = " ", + conceallevel = 3, + }, + }) + end, + } + }, + init = function() + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd -- Override print to use snacks for `:=` command + + -- Create some toggle mappings + Snacks.toggle.option("spell", { name = "Spelling" }):map("us") + Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") + Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") + Snacks.toggle.diagnostics():map("ud") + Snacks.toggle.line_number():map("ul") + Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) + :map("uc") + Snacks.toggle.treesitter():map("uT") + Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" }):map( + "ub") + Snacks.toggle.inlay_hints():map("uh") + end, + }) + end, +}