From 4b03a8311272e99e9fe0c2c869928f60e54c2483 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 9 May 2023 14:08:17 +0300 Subject: Added user directory --- nvim/.config/nvim/.github/README.md | 18 +++ .../nvim/.github/workflows/conventional_commit.yml | 4 +- nvim/.config/nvim/.github/workflows/docs.yml | 2 +- nvim/.config/nvim/.github/workflows/luacheck.yml | 2 +- nvim/.config/nvim/.github/workflows/spell.yml | 2 +- nvim/.config/nvim/.github/workflows/style.yml | 2 +- nvim/.config/nvim/.gitignore | 39 +++++- nvim/.config/nvim/init.lua | 5 +- nvim/.config/nvim/lua/astronvim/autocmds.lua | 18 ++- nvim/.config/nvim/lua/astronvim/health.lua | 25 ++-- .../.config/nvim/lua/astronvim/icons/nerd_font.lua | 22 ++-- nvim/.config/nvim/lua/astronvim/lazy.lua | 2 +- nvim/.config/nvim/lua/astronvim/mappings.lua | 96 +++++++++++---- nvim/.config/nvim/lua/astronvim/options.lua | 3 +- nvim/.config/nvim/lua/astronvim/utils/buffer.lua | 93 ++++++++++++-- nvim/.config/nvim/lua/astronvim/utils/init.lua | 35 +++++- nvim/.config/nvim/lua/astronvim/utils/lsp.lua | 48 ++++++-- nvim/.config/nvim/lua/astronvim/utils/status.lua | 76 ++++++++---- nvim/.config/nvim/lua/astronvim/utils/ui.lua | 15 +-- nvim/.config/nvim/lua/astronvim/utils/updater.lua | 2 +- nvim/.config/nvim/lua/lazy_snapshot.lua | 46 +++---- nvim/.config/nvim/lua/plugins/alpha.lua | 4 +- nvim/.config/nvim/lua/plugins/configs/alpha.lua | 2 +- .../nvim/lua/plugins/configs/mason-lspconfig.lua | 6 +- .../nvim/lua/plugins/configs/mason-nvim-dap.lua | 2 +- .../nvim/lua/plugins/configs/nvim-web-devicons.lua | 1 + nvim/.config/nvim/lua/plugins/core.lua | 16 ++- nvim/.config/nvim/lua/plugins/dap.lua | 3 +- nvim/.config/nvim/lua/plugins/git.lua | 3 +- nvim/.config/nvim/lua/plugins/lsp.lua | 6 +- nvim/.config/nvim/lua/plugins/mason.lua | 1 + nvim/.config/nvim/lua/plugins/neo-tree.lua | 135 ++++++++++----------- nvim/.config/nvim/lua/plugins/treesitter.lua | 5 +- nvim/.config/nvim/lua/plugins/ui.lua | 44 +++---- .../nvim/lua/resession/extensions/astronvim.lua | 32 +++++ nvim/.config/nvim/lua/user | 1 + 36 files changed, 581 insertions(+), 235 deletions(-) create mode 100644 nvim/.config/nvim/lua/resession/extensions/astronvim.lua create mode 160000 nvim/.config/nvim/lua/user (limited to 'nvim') diff --git a/nvim/.config/nvim/.github/README.md b/nvim/.config/nvim/.github/README.md index 54bdad8..12d91e7 100644 --- a/nvim/.config/nvim/.github/README.md +++ b/nvim/.config/nvim/.github/README.md @@ -84,6 +84,8 @@ AstroNvim is an aesthetic and feature-rich neovim config that is extensible and ## 🛠️ Installation +### Linux/Mac OS (Unix) + #### Make a backup of your current nvim and shared folder ```shell @@ -98,6 +100,22 @@ git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim nvim ``` +### Windows (Powershell) + +#### Make a backup of your current nvim and nvim-data folder + +```pwsh +Rename-Item -Path $env:LOCALAPPDATA\nvim -NewName $env:LOCALAPPDATA\nvim.bak +Rename-Item -Path $env:LOCALAPPDATA\nvim-data -NewName $env:LOCALAPPDATA\nvim-data.bak +``` + +#### Clone the repository + +```pwsh +git clone --depth 1 https://github.com/AstroNvim/AstroNvim $env:LOCALAPPDATA\nvim +nvim +``` + ## 📦 Basic Setup #### Install LSP diff --git a/nvim/.config/nvim/.github/workflows/conventional_commit.yml b/nvim/.config/nvim/.github/workflows/conventional_commit.yml index 76819c4..c8d3558 100644 --- a/nvim/.config/nvim/.github/workflows/conventional_commit.yml +++ b/nvim/.config/nvim/.github/workflows/conventional_commit.yml @@ -2,7 +2,7 @@ name: Conventional Commits on: pull_request: - branches: [ main ] + branches: [main] jobs: build: @@ -10,4 +10,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: webiny/action-conventional-commits@v1.0.3 + - uses: webiny/action-conventional-commits@v1.1.0 diff --git a/nvim/.config/nvim/.github/workflows/docs.yml b/nvim/.config/nvim/.github/workflows/docs.yml index 67a997d..47ce3b6 100644 --- a/nvim/.config/nvim/.github/workflows/docs.yml +++ b/nvim/.config/nvim/.github/workflows/docs.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Lua uses: leafo/gh-actions-lua@v8 with: diff --git a/nvim/.config/nvim/.github/workflows/luacheck.yml b/nvim/.config/nvim/.github/workflows/luacheck.yml index f8d48a7..87111d6 100644 --- a/nvim/.config/nvim/.github/workflows/luacheck.yml +++ b/nvim/.config/nvim/.github/workflows/luacheck.yml @@ -9,5 +9,5 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: lunarmodules/luacheck@v1 diff --git a/nvim/.config/nvim/.github/workflows/spell.yml b/nvim/.config/nvim/.github/workflows/spell.yml index 7bae68e..463606f 100644 --- a/nvim/.config/nvim/.github/workflows/spell.yml +++ b/nvim/.config/nvim/.github/workflows/spell.yml @@ -11,4 +11,4 @@ jobs: - name: Checkout Actions Repository uses: actions/checkout@v3 - name: Check spelling - uses: crate-ci/typos@v1.13.26 + uses: crate-ci/typos@v1.14.5 diff --git a/nvim/.config/nvim/.github/workflows/style.yml b/nvim/.config/nvim/.github/workflows/style.yml index 3473f5e..f666542 100644 --- a/nvim/.config/nvim/.github/workflows/style.yml +++ b/nvim/.config/nvim/.github/workflows/style.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: JohnnyMorganz/stylua-action@v2 + - uses: JohnnyMorganz/stylua-action@v3 with: token: ${{ secrets.GITHUB_TOKEN }} version: latest diff --git a/nvim/.config/nvim/.gitignore b/nvim/.config/nvim/.gitignore index 11b67c8..9ed7e4c 100644 --- a/nvim/.config/nvim/.gitignore +++ b/nvim/.config/nvim/.gitignore @@ -1,9 +1,46 @@ +# Project gitignore !colors/astronvim.lua colors/* docs ginit.vim -lua/user plugin ftplugin spell +.github .luarc.json + +# Global gitignore +# ---------------- + +# Mac OS X +.DS_Store +.AppleDouble +.LSOverride +._* + +# Windoze +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +$RECYCLE.BIN/ + +# (Neo)Vim +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] +Session.vim +Sessionx.vim +.netrwhist +*~ +tags +[._]*.un~ + +# VS Code +.vscode +.history + +# JetBrains +.idea diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index a887f21..4f67424 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -11,7 +11,10 @@ end if astronvim.default_colorscheme then if not pcall(vim.cmd.colorscheme, astronvim.default_colorscheme) then - require("astronvim.utils").notify("Error setting up colorscheme: " .. astronvim.default_colorscheme, "error") + require("astronvim.utils").notify( + "Error setting up colorscheme: " .. astronvim.default_colorscheme, + vim.log.levels.ERROR + ) end end diff --git a/nvim/.config/nvim/lua/astronvim/autocmds.lua b/nvim/.config/nvim/lua/astronvim/autocmds.lua index c3b1734..7b47b6e 100644 --- a/nvim/.config/nvim/lua/astronvim/autocmds.lua +++ b/nvim/.config/nvim/lua/astronvim/autocmds.lua @@ -15,7 +15,7 @@ vim.on_key(function(char) end, namespace "auto_hlsearch") local bufferline_group = augroup("bufferline", { clear = true }) -autocmd({ "BufAdd", "BufEnter" }, { +autocmd({ "BufAdd", "BufEnter", "TabNewEntered" }, { desc = "Update buffers when adding new buffers", group = bufferline_group, callback = function(args) @@ -151,6 +151,8 @@ if is_available "alpha-nvim" then vim.opt.showtabline = 0 vim.opt_local.winbar = nil autocmd("BufUnload", { + desc = "Reenable status and tablines for alpha", + group = group_name, pattern = "", callback = function() vim.opt.laststatus = prev_status @@ -179,6 +181,18 @@ if is_available "alpha-nvim" then }) end +if is_available "resession.nvim" then + autocmd("VimLeavePre", { + desc = "Save session on close", + group = augroup("resession_auto_save", { clear = true }), + callback = function() + local save = require("resession").save + save "Last Session" + save(vim.fn.getcwd(), { dir = "dirsession", notify = false }) + end, + }) +end + if is_available "neo-tree.nvim" then autocmd("BufEnter", { desc = "Open Neo-Tree on startup with directory", @@ -214,6 +228,7 @@ autocmd({ "VimEnter", "ColorScheme" }, { }) autocmd({ "BufReadPost", "BufNewFile" }, { + desc = "AstroNvim user events for file detection (AstroFile and AstroGitFile)", group = augroup("file_user_events", { clear = true }), callback = function(args) if not (vim.fn.expand "%" == "" or vim.api.nvim_get_option_value("buftype", { buf = args.buf }) == "nofile") then @@ -236,3 +251,4 @@ cmd( cmd("AstroRollback", function() require("astronvim.utils.updater").rollback() end, { desc = "Rollback AstroNvim" }) cmd("AstroUpdate", function() require("astronvim.utils.updater").update() end, { desc = "Update AstroNvim" }) cmd("AstroVersion", function() require("astronvim.utils.updater").version() end, { desc = "Check AstroNvim Version" }) +cmd("AstroReload", function() require("astronvim.utils").reload() end, { desc = "Reload AstroNvim (Experimental)" }) diff --git a/nvim/.config/nvim/lua/astronvim/health.lua b/nvim/.config/nvim/lua/astronvim/health.lua index 9e48adf..d1fa8a6 100644 --- a/nvim/.config/nvim/lua/astronvim/health.lua +++ b/nvim/.config/nvim/lua/astronvim/health.lua @@ -1,17 +1,26 @@ local M = {} +-- TODO: remove deprecated method check after dropping support for neovim v0.9 +local health = { + start = vim.health.start or vim.health.report_start, + ok = vim.health.ok or vim.health.report_ok, + warn = vim.health.warn or vim.health.report_warn, + error = vim.health.error or vim.health.report_error, + info = vim.health.info or vim.health.report_info, +} + function M.check() - vim.health.report_start "AstroNvim" + health.start "AstroNvim" - vim.health.report_info("AstroNvim Version: " .. require("astronvim.utils.updater").version(true)) - vim.health.report_info("Neovim Version: v" .. vim.fn.matchstr(vim.fn.execute "version", "NVIM v\\zs[^\n]*")) + health.info("AstroNvim Version: " .. require("astronvim.utils.updater").version(true)) + health.info("Neovim Version: v" .. vim.fn.matchstr(vim.fn.execute "version", "NVIM v\\zs[^\n]*")) if vim.version().prerelease then - vim.health.report_warn "Neovim nightly is not officially supported and may have breaking changes" + health.warn "Neovim nightly is not officially supported and may have breaking changes" elseif vim.fn.has "nvim-0.8" == 1 then - vim.health.report_ok "Using stable Neovim >= 0.8.0" + health.ok "Using stable Neovim >= 0.8.0" else - vim.health.report_error "Neovim >= 0.8.0 is required" + health.error "Neovim >= 0.8.0 is required" end local programs = { @@ -41,9 +50,9 @@ function M.check() end if found then - vim.health.report_ok(("`%s` is installed: %s"):format(name, program.msg)) + health.ok(("`%s` is installed: %s"):format(name, program.msg)) else - vim.health["report_" .. program.type](("`%s` is not installed: %s"):format(name, program.msg)) + health[program.type](("`%s` is not installed: %s"):format(name, program.msg)) end end end diff --git a/nvim/.config/nvim/lua/astronvim/icons/nerd_font.lua b/nvim/.config/nvim/lua/astronvim/icons/nerd_font.lua index d6f7f47..8b0a91f 100644 --- a/nvim/.config/nvim/lua/astronvim/icons/nerd_font.lua +++ b/nvim/.config/nvim/lua/astronvim/icons/nerd_font.lua @@ -3,17 +3,17 @@ return { ActiveTS = "", ArrowLeft = "", ArrowRight = "", - BufferClose = "", + BufferClose = "󰅖", DapBreakpoint = "", DapBreakpointCondition = "", DapBreakpointRejected = "", DapLogPoint = ".>", - DapStopped = "", - DefaultFile = "", - Diagnostic = "裂", + DapStopped = "󰁕", + DefaultFile = "󰈙", + Diagnostic = "󰒡", DiagnosticError = "", - DiagnosticHint = "", - DiagnosticInfo = "", + DiagnosticHint = "󰌵", + DiagnosticInfo = "󰋼", DiagnosticWarn = "", Ellipsis = "…", FileModified = "", @@ -24,7 +24,7 @@ return { FolderClosed = "", FolderEmpty = "", FolderOpen = "", - Git = "", + Git = "󰊢", GitAdd = "", GitBranch = "", GitChange = "", @@ -37,12 +37,12 @@ return { GitUntracked = "★", LSPLoaded = "", LSPLoading1 = "", - LSPLoading2 = "", + LSPLoading2 = "󰀚", LSPLoading3 = "", MacroRecording = "", - Paste = "", + Paste = "󰅌", Search = "", Selected = "❯", - Spellcheck = "暈", - TabClose = "", + Spellcheck = "󰓆", + TabClose = "󰅙", } diff --git a/nvim/.config/nvim/lua/astronvim/lazy.lua b/nvim/.config/nvim/lua/astronvim/lazy.lua index 0a5bd32..d918c24 100644 --- a/nvim/.config/nvim/lua/astronvim/lazy.lua +++ b/nvim/.config/nvim/lua/astronvim/lazy.lua @@ -37,7 +37,7 @@ require("lazy").setup(astronvim.user_opts("lazy", { performance = { rtp = { paths = astronvim.supported_configs, - disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" }, + disabled_plugins = { "tohtml", "gzip", "zipPlugin", "netrwPlugin", "tarPlugin" }, }, }, lockfile = vim.fn.stdpath "data" .. "/lazy-lock.json", diff --git a/nvim/.config/nvim/lua/astronvim/mappings.lua b/nvim/.config/nvim/lua/astronvim/mappings.lua index b7a486a..7301d7b 100644 --- a/nvim/.config/nvim/lua/astronvim/mappings.lua +++ b/nvim/.config/nvim/lua/astronvim/mappings.lua @@ -10,8 +10,9 @@ local sections = { l = { desc = " LSP" }, u = { desc = " UI" }, b = { desc = "󰓩 Buffers" }, + bs = { desc = "󰒺 Sort Buffers" }, d = { desc = " Debugger" }, - g = { desc = " Git" }, + g = { desc = "󰊢 Git" }, S = { desc = "󱂬 Session" }, t = { desc = " Terminal" }, } @@ -19,10 +20,8 @@ if not vim.g.icons_enabled then vim.tbl_map(function(opts) opts.desc = opts.desc -- Normal -- -- Standard Operations -maps.n["j"] = { "v:count ? 'j' : 'gj'", expr = true, desc = "Move cursor down" } -maps.n["k"] = { "v:count ? 'k' : 'gk'", expr = true, desc = "Move cursor up" } -maps.v["j"] = maps.n.j -maps.v["k"] = maps.n.k +maps.n["j"] = { "v:count == 0 ? 'gj' : 'j'", expr = true, desc = "Move cursor down" } +maps.n["k"] = { "v:count == 0 ? 'gk' : 'k'", expr = true, desc = "Move cursor up" } maps.n["w"] = { "w", desc = "Save" } maps.n["q"] = { "confirm q", desc = "Quit" } maps.n["n"] = { "enew", desc = "New File" } @@ -50,7 +49,7 @@ maps.n["pl"] = { "AstroChangelog", desc = "AstroNvim Changelog" maps.n["c"] = { function() require("astronvim.utils.buffer").close() end, desc = "Close buffer" } maps.n["C"] = { function() require("astronvim.utils.buffer").close(0, true) end, desc = "Force close buffer" } maps.n["]b"] = -{ function() require("astronvim.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end, desc = "Next buffer" } + { function() require("astronvim.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end, desc = "Next buffer" } maps.n["[b"] = { function() require("astronvim.utils.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end, desc = "Previous buffer", @@ -66,7 +65,7 @@ maps.n["b"] = sections.b maps.n["bc"] = -{ function() require("astronvim.utils.buffer").close_all(true) end, desc = "Close all buffers except current" } + { function() require("astronvim.utils.buffer").close_all(true) end, desc = "Close all buffers except current" } maps.n["bC"] = { function() require("astronvim.utils.buffer").close_all() end, desc = "Close all buffers" } maps.n["bb"] = { function() @@ -82,6 +81,21 @@ maps.n["bd"] = { end, desc = "Delete buffer from tabline", } +maps.n["bl"] = + { function() require("astronvim.utils.buffer").close_left() end, desc = "Close all buffers to the left" } +maps.n["br"] = + { function() require("astronvim.utils.buffer").close_right() end, desc = "Close all buffers to the right" } +maps.n["bs"] = sections.bs +maps.n["bse"] = + { function() require("astronvim.utils.buffer").sort "extension" end, desc = "Sort by extension (buffers)" } +maps.n["bsr"] = + { function() require("astronvim.utils.buffer").sort "unique_path" end, desc = "Sort by relative path (buffers)" } +maps.n["bsp"] = + { function() require("astronvim.utils.buffer").sort "full_path" end, desc = "Sort by full path (buffers)" } +maps.n["bsi"] = + { function() require("astronvim.utils.buffer").sort "bufnr" end, desc = "Sort by buffer number (buffers)" } +maps.n["bsm"] = + { function() require("astronvim.utils.buffer").sort "modified" end, desc = "Sort by modification (buffers)" } maps.n["b\\"] = { function() require("astronvim.utils.status").heirline.buffer_picker(function(bufnr) @@ -126,7 +140,7 @@ if is_available "Comment.nvim" then desc = "Comment line", } maps.v["/"] = - { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", desc = "Toggle comment line" } + { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", desc = "Toggle comment line" } end -- GitSigns @@ -168,7 +182,19 @@ if is_available "neovim-session-manager" then maps.n["Sd"] = { "SessionManager! delete_session", desc = "Delete session" } maps.n["Sf"] = { "SessionManager! load_session", desc = "Search sessions" } maps.n["S."] = - { "SessionManager! load_current_dir_session", desc = "Load current directory session" } + { "SessionManager! load_current_dir_session", desc = "Load current directory session" } +end +if is_available "resession.nvim" then + maps.n["S"] = sections.S + maps.n["Sl"] = { function() require("resession").load "Last Session" end, desc = "Load last session" } + maps.n["Ss"] = { function() require("resession").save() end, desc = "Save this session" } + maps.n["St"] = { function() require("resession").save_tab() end, desc = "Save this tab's session" } + maps.n["Sd"] = { function() require("resession").delete() end, desc = "Delete a session" } + maps.n["Sf"] = { function() require("resession").load() end, desc = "Load a session" } + maps.n["S."] = { + function() require("resession").load(vim.fn.getcwd(), { dir = "dirsession" }) end, + desc = "Load current directory session", + } end -- Package Manager @@ -217,11 +243,11 @@ if is_available "telescope.nvim" then function() local cwd = vim.fn.stdpath "config" .. "/.." local search_dirs = {} - for _, dir in ipairs(astronvim.supported_configs) do -- search all supported config locations - if dir == astronvim.install.home then dir = dir .. "/lua/user" end -- don't search the astronvim core files + for _, dir in ipairs(astronvim.supported_configs) do -- search all supported config locations + if dir == astronvim.install.home then dir = dir .. "/lua/user" end -- don't search the astronvim core files if vim.fn.isdirectory(dir) == 1 then table.insert(search_dirs, dir) end -- add directory to search if exists end - if vim.tbl_isempty(search_dirs) then -- if no config folders found, show warning + if vim.tbl_isempty(search_dirs) then -- if no config folders found, show warning utils.notify("No user configuration files found", vim.log.levels.WARN) else if #search_dirs == 1 then cwd = search_dirs[1] end -- if only one directory, focus cwd @@ -236,7 +262,7 @@ if is_available "telescope.nvim" then } maps.n["fb"] = { function() require("telescope.builtin").buffers() end, desc = "Find buffers" } maps.n["fc"] = - { function() require("telescope.builtin").grep_string() end, desc = "Find for word under cursor" } + { function() require("telescope.builtin").grep_string() end, desc = "Find for word under cursor" } maps.n["fC"] = { function() require("telescope.builtin").commands() end, desc = "Find commands" } maps.n["ff"] = { function() require("telescope.builtin").find_files() end, desc = "Find files" } maps.n["fF"] = { @@ -248,12 +274,12 @@ if is_available "telescope.nvim" then maps.n["fm"] = { function() require("telescope.builtin").man_pages() end, desc = "Find man" } if is_available "nvim-notify" then maps.n["fn"] = - { function() require("telescope").extensions.notify.notify() end, desc = "Find notifications" } + { function() require("telescope").extensions.notify.notify() end, desc = "Find notifications" } end maps.n["fo"] = { function() require("telescope.builtin").oldfiles() end, desc = "Find history" } maps.n["fr"] = { function() require("telescope.builtin").registers() end, desc = "Find registers" } maps.n["ft"] = - { function() require("telescope.builtin").colorscheme { enable_preview = true } end, desc = "Find themes" } + { function() require("telescope.builtin").colorscheme { enable_preview = true } end, desc = "Find themes" } maps.n["fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Find words" } maps.n["fW"] = { function() @@ -308,14 +334,19 @@ end if is_available "nvim-dap" then maps.n["d"] = sections.d + maps.v["d"] = sections.d -- modified function keys found with `showkey -a` in the terminal to get key code -- run `nvim -V3log +quit` and search through the "Terminal info" in the `log` file for the correct keyname - maps.n[""] = { function() require("dap").continue() end, desc = "Debugger: Start" } - maps.n[""] = { - function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, - desc = "Toggle Conditional Breakpoint" + maps.n[""] = { function() require("dap").continue() end, desc = "Debugger: Start" } + maps.n[""] = { function() require("dap").terminate() end, desc = "Debugger: Stop" } -- Shift+F5 + maps.n[""] = { + function() + vim.ui.input({ prompt = "Condition: " }, function(condition) + if condition then require("dap").set_breakpoint(condition) end + end) + end, + desc = "Debugger: Conditional Breakpoint", } - maps.n[""] = { function() require("dap").terminate() end, desc = "Debugger: Stop" } -- Shift+F5 maps.n[""] = { function() require("dap").restart_frame() end, desc = "Debugger: Restart" } -- Control+F5 maps.n[""] = { function() require("dap").pause() end, desc = "Debugger: Pause" } maps.n[""] = { function() require("dap").toggle_breakpoint() end, desc = "Debugger: Toggle Breakpoint" } @@ -323,12 +354,16 @@ if is_available "nvim-dap" then maps.n[""] = { function() require("dap").step_into() end, desc = "Debugger: Step Into" } maps.n[""] = { function() require("dap").step_out() end, desc = "Debugger: Step Out" } -- Shift+F11 maps.n["db"] = { function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint (F9)" } - maps.n["dbc"] = { - function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, - desc = "Toggle Conditional Breakpoint" - } maps.n["dB"] = { function() require("dap").clear_breakpoints() end, desc = "Clear Breakpoints" } maps.n["dc"] = { function() require("dap").continue() end, desc = "Start/Continue (F5)" } + maps.n["dC"] = { + function() + vim.ui.input({ prompt = "Condition: " }, function(condition) + if condition then require("dap").set_breakpoint(condition) end + end) + end, + desc = "Conditional Breakpoint (S-F9)", + } maps.n["di"] = { function() require("dap").step_into() end, desc = "Step Into (F11)" } maps.n["do"] = { function() require("dap").step_over() end, desc = "Step Over (F10)" } maps.n["dO"] = { function() require("dap").step_out() end, desc = "Step Out (S-F11)" } @@ -337,7 +372,18 @@ if is_available "nvim-dap" then maps.n["dp"] = { function() require("dap").pause() end, desc = "Pause (F6)" } maps.n["dr"] = { function() require("dap").restart_frame() end, desc = "Restart (C-F5)" } maps.n["dR"] = { function() require("dap").repl.toggle() end, desc = "Toggle REPL" } + maps.n["ds"] = { function() require("dap").run_to_cursor() end, desc = "Run To Cursor" } + if is_available "nvim-dap-ui" then + maps.n["dE"] = { + function() + vim.ui.input({ prompt = "Expression: " }, function(expr) + if expr then require("dapui").eval(expr) end + end) + end, + desc = "Evaluate Input", + } + maps.v["dE"] = { function() require("dapui").eval() end, desc = "Evaluate Input" } maps.n["du"] = { function() require("dapui").toggle() end, desc = "Toggle Debugger UI" } maps.n["dh"] = { function() require("dap.ui.widgets").hover() end, desc = "Debugger Hover" } end @@ -374,7 +420,7 @@ maps.n["ud"] = { ui.toggle_diagnostics, desc = "Toggle diagnostics" } maps.n["ug"] = { ui.toggle_signcolumn, desc = "Toggle signcolumn" } maps.n["ui"] = { ui.set_indent, desc = "Change indent setting" } maps.n["ul"] = { ui.toggle_statusline, desc = "Toggle statusline" } -maps.n["uL"] = { ui.toggle_codelens, desc = "Toggle CodeLens refresh" } +maps.n["uL"] = { ui.toggle_codelens, desc = "Toggle CodeLens" } maps.n["un"] = { ui.change_number, desc = "Change line numbering" } maps.n["uN"] = { ui.toggle_ui_notifications, desc = "Toggle UI notifications" } maps.n["up"] = { ui.toggle_paste, desc = "Toggle paste mode" } diff --git a/nvim/.config/nvim/lua/astronvim/options.lua b/nvim/.config/nvim/lua/astronvim/options.lua index 0fce646..2a94c75 100644 --- a/nvim/.config/nvim/lua/astronvim/options.lua +++ b/nvim/.config/nvim/lua/astronvim/options.lua @@ -38,7 +38,6 @@ local options = astronvim.user_opts("options", { smartcase = true, -- Case sensitivie searching smartindent = true, -- Smarter autoindentation splitbelow = true, -- Splitting a new window below the current one - splitkeep = vim.fn.has "nvim-0.9" == 1 and "screen" or nil, -- Maintain code view when splitting splitright = true, -- Splitting a new window at the right of the current one tabstop = 2, -- Number of space in a tab termguicolors = true, -- Enable 24-bit RGB color in the TUI @@ -61,7 +60,7 @@ local options = astronvim.user_opts("options", { icons_enabled = true, -- disable icons in the UI (disable if no nerd font is available) ui_notifications_enabled = true, -- disable notifications when toggling UI elements }, - t = { bufs = vim.api.nvim_list_bufs() }, -- initialize buffers for the current tab + t = vim.t.bufs and vim.t.bufs or { bufs = vim.api.nvim_list_bufs() }, -- initialize buffers for the current tab }) for scope, table in pairs(options) do diff --git a/nvim/.config/nvim/lua/astronvim/utils/buffer.lua b/nvim/.config/nvim/lua/astronvim/utils/buffer.lua index cc8249c..8a2a1ab 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/buffer.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/buffer.lua @@ -69,7 +69,7 @@ function M.close(bufnr, force) if require("astronvim.utils").is_available "bufdelete.nvim" then require("bufdelete").bufdelete(bufnr, force) else - vim.cmd((force and "bd!" or "confirm bd") .. bufnr) + vim.cmd((force and "bd!" or "confirm bd") .. (bufnr == nil and "" or bufnr)) end end @@ -77,18 +77,49 @@ end ---@param keep_current? boolean Whether or not to keep the current buffer (default: false) ---@param force? boolean Whether or not to foce close the buffers or confirm changes (default: false) function M.close_all(keep_current, force) - if force == nil then force = false end if keep_current == nil then keep_current = false end local current = vim.api.nvim_get_current_buf() for _, bufnr in ipairs(vim.t.bufs) do - if not keep_current or bufnr ~= current then - if require("astronvim.utils").is_available "bufdelete.nvim" then - require("bufdelete").bufdelete(bufnr, force) - else - vim.cmd((force and "bd!" or "confirm bd") .. bufnr) - end - end + if not keep_current or bufnr ~= current then M.close(bufnr, force) end + end +end + +--- Close buffers to the left of the current buffer +---@param force? boolean Whether or not to foce close the buffers or confirm changes (default: false) +function M.close_left(force) + local current = vim.api.nvim_get_current_buf() + for _, bufnr in ipairs(vim.t.bufs) do + if bufnr == current then break end + M.close(bufnr, force) + end +end + +--- Close buffers to the right of the current buffer +---@param force? boolean Whether or not to foce close the buffers or confirm changes (default: false) +function M.close_right(force) + local current = vim.api.nvim_get_current_buf() + local after_current = false + for _, bufnr in ipairs(vim.t.bufs) do + if after_current then M.close(bufnr, force) end + if bufnr == current then after_current = true end + end +end + +--- Sort a the buffers in the current tab based on some comparator +---@param compare_func string|function a string of a comparator defined in require("astronvim.utils.buffer").comparator or a custom comparator function +---@param skip_autocmd boolean|nil whether or not to skip triggering AstroBufsUpdated autocmd event +---@return boolean # Whether or not the buffers were sorted +function M.sort(compare_func, skip_autocmd) + if type(compare_func) == "string" then compare_func = M.comparator[compare_func] end + if type(compare_func) == "function" then + local bufs = vim.t.bufs + table.sort(bufs, compare_func) + vim.t.bufs = bufs + if not skip_autocmd then require("astronvim.utils").event "BufsUpdated" end + vim.cmd.redrawtabline() + return true end + return false end --- Close the current tab @@ -100,4 +131,48 @@ function M.close_tab() end end +--- A table of buffer comparator functions +M.comparator = {} + +local fnamemodify = vim.fn.fnamemodify +local function bufinfo(bufnr) return vim.fn.getbufinfo(bufnr)[1] end +local function unique_path(bufnr) + return require("astronvim.utils.status").provider.unique_path() { bufnr = bufnr } + .. fnamemodify(bufinfo(bufnr).name, ":t") +end + +--- Comparator of two buffer numbers +---@param bufnr_a integer buffer number A +---@param bufnr_b integer buffer number B +---@return boolean comparison true if A is sorted before B, false if B should be sorted before A +function M.comparator.bufnr(bufnr_a, bufnr_b) return bufnr_a < bufnr_b end + +--- Comparator of two buffer numbers based on the file extensions +---@param bufnr_a integer buffer number A +---@param bufnr_b integer buffer number B +---@return boolean comparison true if A is sorted before B, false if B should be sorted before A +function M.comparator.extension(bufnr_a, bufnr_b) + return fnamemodify(bufinfo(bufnr_a).name, ":e") < fnamemodify(bufinfo(bufnr_b).name, ":e") +end + +--- Comparator of two buffer numbers based on the full path +---@param bufnr_a integer buffer number A +---@param bufnr_b integer buffer number B +---@return boolean comparison true if A is sorted before B, false if B should be sorted before A +function M.comparator.full_path(bufnr_a, bufnr_b) + return fnamemodify(bufinfo(bufnr_a).name, ":p") < fnamemodify(bufinfo(bufnr_b).name, ":p") +end + +--- Comparator of two buffers based on their unique path +---@param bufnr_a integer buffer number A +---@param bufnr_b integer buffer number B +---@return boolean comparison true if A is sorted before B, false if B should be sorted before A +function M.comparator.unique_path(bufnr_a, bufnr_b) return unique_path(bufnr_a) < unique_path(bufnr_b) end + +--- Comparator of two buffers based on modification date +---@param bufnr_a integer buffer number A +---@param bufnr_b integer buffer number B +---@return boolean comparison true if A is sorted before B, false if B should be sorted before A +function M.comparator.modified(bufnr_a, bufnr_b) return bufinfo(bufnr_a).lastused > bufinfo(bufnr_b).lastused end + return M diff --git a/nvim/.config/nvim/lua/astronvim/utils/init.lua b/nvim/.config/nvim/lua/astronvim/utils/init.lua index 3d6edf7..83c8aef 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/init.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/init.lua @@ -19,11 +19,40 @@ function M.extend_tbl(default, opts) return default and vim.tbl_deep_extend("force", default, opts) or opts end +--- Partially reload AstroNvim user settings. Includes core vim options, mappings, and highlights. This is an experimental feature and may lead to instabilities until restart. +---@param quiet? boolean Whether or not to notify on completion of reloading +---@return boolean # True if the reload was successful, False otherwise +function M.reload(quiet) + local core_modules = { "astronvim.bootstrap", "astronvim.options", "astronvim.mappings" } + local modules = vim.tbl_filter(function(module) return module:find "^user%." end, vim.tbl_keys(package.loaded)) + + vim.tbl_map(require("plenary.reload").reload_module, vim.list_extend(modules, core_modules)) + + local success = true + for _, module in ipairs(core_modules) do + local status_ok, fault = pcall(require, module) + if not status_ok then + vim.api.nvim_err_writeln("Failed to load " .. module .. "\n\n" .. fault) + success = false + end + end + if not quiet then -- if not quiet, then notify of result + if success then + M.notify("AstroNvim successfully reloaded", vim.log.levels.INFO) + else + M.notify("Error reloading AstroNvim...", vim.log.levels.ERROR) + end + end + vim.cmd.doautocmd "ColorScheme" + return success +end + --- Insert one or more values into a list like table and maintain that you do not insert non-unique values (THIS MODIFIES `lst`) ----@param lst any[] The list like table that you want to insert into +---@param lst any[]|nil The list like table that you want to insert into ---@param vals any|any[] Either a list like table of values to be inserted or a single value to be inserted ---@return any[] # The modified list like table function M.list_insert_unique(lst, vals) + if not lst then lst = {} end assert(vim.tbl_islist(lst), "Provided table is not a list like table") if not vim.tbl_islist(vals) then vals = { vals } end for _, val in ipairs(vals) do @@ -55,7 +84,7 @@ end --- Get highlight properties for a given highlight name ---@param name string The highlight group name ----@param fallback table The fallback highlight properties +---@param fallback? table The fallback highlight properties ---@return table properties # the highlight group properties function M.get_hlgroup(name, fallback) if vim.fn.hlexists(name) == 1 then @@ -74,7 +103,7 @@ function M.get_hlgroup(name, fallback) end return hl end - return fallback + return fallback or {} end --- Serve a notification with a title of AstroNvim diff --git a/nvim/.config/nvim/lua/astronvim/utils/lsp.lua b/nvim/.config/nvim/lua/astronvim/utils/lsp.lua index 4f9a661..ff02568 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/lsp.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/lsp.lua @@ -87,6 +87,20 @@ M.setup = function(server) if not vim.tbl_contains(astronvim.lsp.skip_setup, server) and setup_handler then setup_handler(server, opts) end end +--- Helper function to check if any active LSP clients given a filter provide a specific capability +---@param capability string The server capability to check for (example: "documentFormattingProvider") +---@param filter vim.lsp.get_active_clients.filter|nil (table|nil) A table with +--- key-value pairs used to filter the returned clients. +--- The available keys are: +--- - id (number): Only return clients with the given id +--- - bufnr (number): Only return clients attached to this buffer +--- - name (string): Only return clients with the given name +---@return boolean # Whether or not any of the clients provide the capability +function M.has_capability(capability, filter) + local clients = vim.lsp.get_active_clients(filter) + return not tbl_isempty(vim.tbl_map(function(client) return client.server_capabilities[capability] end, clients)) +end + local function add_buffer_autocmd(augroup, bufnr, autocmds) if not vim.tbl_islist(autocmds) then autocmds = { autocmds } end local cmds_found, cmds = pcall(vim.api.nvim_get_autocmds, { group = augroup, buffer = bufnr }) @@ -102,6 +116,11 @@ local function add_buffer_autocmd(augroup, bufnr, autocmds) end end +local function del_buffer_autocmd(augroup, bufnr) + local cmds_found, cmds = pcall(vim.api.nvim_get_autocmds, { group = augroup, buffer = bufnr }) + if cmds_found then vim.tbl_map(function(cmd) vim.api.nvim_del_autocmd(cmd.id) end, cmds) end +end + --- The `on_attach` function used by AstroNvim ---@param client table The LSP client details when attaching ---@param bufnr number The buffer that the LSP client is attaching to @@ -150,10 +169,14 @@ M.on_attach = function(client, bufnr) events = { "InsertLeave", "BufEnter" }, desc = "Refresh codelens", callback = function() + if not M.has_capability("codeLensProvider", { bufnr = bufnr }) then + del_buffer_autocmd("lsp_codelens_refresh", bufnr) + return + end if vim.g.codelens_enabled then vim.lsp.codelens.refresh() end end, }) - vim.lsp.codelens.refresh() + if vim.g.codelens_enabled then vim.lsp.codelens.refresh() end lsp_mappings.n["ll"] = { function() vim.lsp.codelens.refresh() end, desc = "LSP CodeLens refresh", @@ -202,6 +225,10 @@ M.on_attach = function(client, bufnr) events = "BufWritePre", desc = "autoformat on save", callback = function() + if not M.has_capability("documentFormattingProvider", { bufnr = bufnr }) then + del_buffer_autocmd("lsp_auto_format", bufnr) + return + end local autoformat_enabled = vim.b.autoformat_enabled if autoformat_enabled == nil then autoformat_enabled = vim.g.autoformat_enabled end if autoformat_enabled and ((not autoformat.filter) or autoformat.filter(bufnr)) then @@ -225,7 +252,13 @@ M.on_attach = function(client, bufnr) { events = { "CursorHold", "CursorHoldI" }, desc = "highlight references when cursor holds", - callback = function() vim.lsp.buf.document_highlight() end, + callback = function() + if not M.has_capability("documentHighlightProvider", { bufnr = bufnr }) then + del_buffer_autocmd("lsp_document_highlight", bufnr) + return + end + vim.lsp.buf.document_highlight() + end, }, { events = { "CursorMoved", "CursorMovedI" }, @@ -282,10 +315,7 @@ M.on_attach = function(client, bufnr) end if capabilities.workspaceSymbolProvider then - lsp_mappings.n["lG"] = { - function() vim.lsp.buf.workspace_symbol() end, - desc = "Search workspace symbols", - } + lsp_mappings.n["lG"] = { function() vim.lsp.buf.workspace_symbol() end, desc = "Search workspace symbols" } end if capabilities.semanticTokensProvider and vim.lsp.semantic_tokens then @@ -308,7 +338,11 @@ M.on_attach = function(client, bufnr) lsp_mappings.n.gT[1] = function() require("telescope.builtin").lsp_type_definitions() end end if lsp_mappings.n["lG"] then - lsp_mappings.n["lG"][1] = function() require("telescope.builtin").lsp_workspace_symbols() end + lsp_mappings.n["lG"][1] = function() + vim.ui.input({ prompt = "Symbol Query: " }, function(query) + if query then require("telescope.builtin").lsp_workspace_symbols { query = query } end + end) + end end end diff --git a/nvim/.config/nvim/lua/astronvim/utils/status.lua b/nvim/.config/nvim/lua/astronvim/utils/status.lua index 1665f39..b98d2dd 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/status.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/status.lua @@ -150,6 +150,7 @@ M.env.sign_handlers = astronvim.user_opts("heirline.sign_handlers", M.env.sign_h ---@param fallback string the color to fallback on if a lualine theme is not present ---@return string # The background color of the lualine theme or the fallback parameter if one doesn't exist function M.hl.lualine_mode(mode, fallback) + if not vim.g.colors_name then return fallback end local lualine_avail, lualine = pcall(require, "lualine.themes." .. vim.g.colors_name) local lualine_opts = lualine_avail and lualine[mode] return lualine_opts and type(lualine_opts.a) == "table" and lualine_opts.a.bg or fallback @@ -361,10 +362,22 @@ end -- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.numbercolumn } -- @see astronvim.utils.status.utils.stylize function M.provider.numbercolumn(opts) - opts = extend_tbl({ escape = false }, opts) + opts = extend_tbl({ thousands = false, culright = true, escape = false }, opts) return function() + local lnum, rnum, virtnum = vim.v.lnum, vim.v.relnum, vim.v.virtnum local num, relnum = vim.opt.number:get(), vim.opt.relativenumber:get() - local str = ((num and not relnum) and "%l") or ((relnum and not num) and "%r") or "%{v:relnum?v:relnum:v:lnum}" + local str + if not num and not relnum then + str = "" + elseif virtnum ~= 0 then + str = "%=" + else + local cur = relnum and (rnum > 0 and rnum or (num and lnum or 0)) or lnum + if opts.thousands and cur > 999 then + cur = string.reverse(cur):gsub("%d%d%d", "%1" .. opts.thousands):reverse():gsub("^%" .. opts.thousands, "") + end + str = (rnum == 0 and not opts.culright and relnum) and cur .. "%=" or "%=" .. cur + end return M.utils.stylize(str, opts) end end @@ -400,7 +413,8 @@ function M.provider.foldcolumn(opts) for col = 1, width do str = str .. ( - ((closed and (col == foldinfo.level or col == width)) and foldclosed) + (vim.v.virtnum ~= 0 and foldsep) + or ((closed and (col == foldinfo.level or col == width)) and foldclosed) or ((foldinfo.start == vim.v.lnum and first_level + col > foldinfo.llevel) and foldopen) or foldsep ) @@ -458,6 +472,16 @@ function M.provider.macro_recording(opts) end end +--- A provider function for displaying the current command +---@param opts? table of options passed to the stylize function +---@return string # the statusline string for showing the current command +-- @usage local heirline_component = { provider = require("astronvim.utils.status").provider.showcmd() } +-- @see astronvim.utils.status.utils.stylize +function M.provider.showcmd(opts) + opts = extend_tbl({ minwid = 0, maxwid = 5, escape = false }, opts) + return M.utils.stylize(("%%%d.%d(%%S%%)"):format(opts.minwid, opts.maxwid), opts) +end + --- A provider function for displaying the current search count ---@param opts? table options for `vim.fn.searchcount` and options passed to the stylize function ---@return function # a function that returns a string of the current search location @@ -607,35 +631,30 @@ function M.provider.unique_path(opts) bufnr = 0, max_length = 16, }, opts) + local function path_parts(bufnr) + local parts = {} + for match in (vim.api.nvim_buf_get_name(bufnr) .. "/"):gmatch("(.-)" .. "/") do + table.insert(parts, match) + end + return parts + end return function(self) opts.bufnr = self and self.bufnr or opts.bufnr local name = opts.buf_name(opts.bufnr) local unique_path = "" -- check for same buffer names under different dirs + local current for _, value in ipairs(vim.t.bufs) do if name == opts.buf_name(value) and value ~= opts.bufnr then - local other = {} - for match in (vim.api.nvim_buf_get_name(value) .. "/"):gmatch("(.-)" .. "/") do - table.insert(other, match) - end - - local current = {} - for match in (vim.api.nvim_buf_get_name(opts.bufnr) .. "/"):gmatch("(.-)" .. "/") do - table.insert(current, match) - end - - unique_path = "" + if not current then current = path_parts(opts.bufnr) end + local other = path_parts(value) for i = #current - 1, 1, -1 do - local value_current = current[i] - local other_current = other[i] - - if value_current ~= other_current then - unique_path = value_current .. "/" + if current[i] ~= other[i] then + unique_path = current[i] .. "/" break end end - break end end return M.utils.stylize( @@ -828,6 +847,13 @@ function M.condition.is_macro_recording() return vim.fn.reg_recording() ~= "" en -- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_hlsearch } function M.condition.is_hlsearch() return vim.v.hlsearch ~= 0 end +--- A condition function if showcmdloc is set to statusline +---@return boolean # whether or not statusline showcmd is enabled +-- @usage local heirline_component = { provider = "Example Provider", condition = require("astronvim.utils.status").condition.is_statusline_showcmd } +function M.condition.is_statusline_showcmd() + return vim.fn.has "nvim-0.9" == 1 and vim.opt.showcmdloc:get() == "statusline" +end + --- A condition function if the current file is in a git repo ---@param bufnr table|integer a buffer number to check the condition for, a table with bufnr property, or nil to get the current buffer ---@return boolean # whether or not the current file is in a git repo @@ -1038,15 +1064,21 @@ function M.component.cmd_info(opts) padding = { left = 1 }, condition = M.condition.is_hlsearch, }, + showcmd = { + padding = { left = 1 }, + condition = M.condition.is_statusline_showcmd, + }, surround = { separator = "center", color = "cmd_info_bg", - condition = function() return M.condition.is_hlsearch() or M.condition.is_macro_recording() end, + condition = function() + return M.condition.is_hlsearch() or M.condition.is_macro_recording() or M.condition.is_statusline_showcmd() + end, }, condition = function() return vim.opt.cmdheight:get() == 0 end, hl = M.hl.get_attributes "cmd_info", }, opts) - return M.component.builder(M.utils.setup_providers(opts, { "macro_recording", "search_count" })) + return M.component.builder(M.utils.setup_providers(opts, { "macro_recording", "search_count", "showcmd" })) end --- A function to build a set of children components for a mode section diff --git a/nvim/.config/nvim/lua/astronvim/utils/ui.lua b/nvim/.config/nvim/lua/astronvim/utils/ui.lua index 8bbd6f5..ea32c98 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/ui.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/ui.lua @@ -94,10 +94,11 @@ function M.toggle_buffer_semantic_tokens(bufnr) end end ---- Toggle codelens refresh +--- Toggle codelens function M.toggle_codelens() vim.g.codelens_enabled = not vim.g.codelens_enabled - ui_notify(string.format("CodeLens refresh %s", bool2str(vim.g.codelens_enabled))) + if not vim.g.codelens_enabled then vim.lsp.codelens.clear() end + ui_notify(string.format("CodeLens %s", bool2str(vim.g.codelens_enabled))) end --- Toggle showtabline=2|0 @@ -149,16 +150,16 @@ function M.set_indent() if not indent or indent == 0 then return end vim.bo.expandtab = (indent > 0) -- local to buffer indent = math.abs(indent) - vim.bo.tabstop = indent -- local to buffer - vim.bo.softtabstop = indent -- local to buffer - vim.bo.shiftwidth = indent -- local to buffer + vim.bo.tabstop = indent -- local to buffer + vim.bo.softtabstop = indent -- local to buffer + vim.bo.shiftwidth = indent -- local to buffer ui_notify(string.format("indent=%d %s", indent, vim.bo.expandtab and "expandtab" or "noexpandtab")) end end --- Change the number display modes function M.change_number() - local number = vim.wo.number -- local to window + local number = vim.wo.number -- local to window local relativenumber = vim.wo.relativenumber -- local to window if not number and not relativenumber then vim.wo.number = true @@ -195,7 +196,7 @@ function M.toggle_syntax() local ts_avail, parsers = pcall(require, "nvim-treesitter.parsers") if vim.g.syntax_on then -- global var for on//off if ts_avail and parsers.has_parser() then vim.cmd.TSBufDisable "highlight" end - vim.cmd.syntax "off" -- set vim.g.syntax_on = false + vim.cmd.syntax "off" -- set vim.g.syntax_on = false else if ts_avail and parsers.has_parser() then vim.cmd.TSBufEnable "highlight" end vim.cmd.syntax "on" -- set vim.g.syntax_on = true diff --git a/nvim/.config/nvim/lua/astronvim/utils/updater.lua b/nvim/.config/nvim/lua/astronvim/utils/updater.lua index e80b579..dd5370c 100644 --- a/nvim/.config/nvim/lua/astronvim/utils/updater.lua +++ b/nvim/.config/nvim/lua/astronvim/utils/updater.lua @@ -24,7 +24,7 @@ end local function confirm_prompt(messages) if messages then echo(messages) end - local confirmed = string.lower(vim.fn.input "(y/n) ") == "y" + local confirmed = string.lower(vim.fn.input "(y/n)󰁔 ") == "y" echo() echo() return confirmed diff --git a/nvim/.config/nvim/lua/lazy_snapshot.lua b/nvim/.config/nvim/lua/lazy_snapshot.lua index fdf4186..0cc1e88 100644 --- a/nvim/.config/nvim/lua/lazy_snapshot.lua +++ b/nvim/.config/nvim/lua/lazy_snapshot.lua @@ -1,51 +1,51 @@ return { { "AstroNvim/astrotheme", version = "^1.1" }, - { "JoosepAlviste/nvim-ts-context-commentstring", commit = "729d83ecb990dc2b30272833c213cc6d49ed5214" }, + { "JoosepAlviste/nvim-ts-context-commentstring", commit = "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, { "L3MON4D3/LuaSnip", version = "^1" }, - { "MunifTanjim/nui.nvim", commit = "1f43b13d133eb4b4f53a4485379d9afa58808389" }, + { "MunifTanjim/nui.nvim", commit = "698e75814cd7c56b0dd8af4936bcef2d13807f3c" }, { "NMAC427/guess-indent.nvim", commit = "b8ae749fce17aa4c267eec80a6984130b94f80b2" }, { "NvChad/nvim-colorizer.lua", commit = "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - { "Shatur/neovim-session-manager", commit = "d1883f30921193f3cff4537e27514e454e0331e9" }, + { "Shatur/neovim-session-manager", commit = "83ea944252d08b0950a407708f36ffdd3fe18e80" }, { "akinsho/toggleterm.nvim", version = "^2" }, - { "b0o/SchemaStore.nvim", commit = "5487658767dd6932ad30b399f0d3b3e68f927793" }, + { "b0o/SchemaStore.nvim", commit = "b8e6c7d966857e8ff14d9b6a23eec9214d99db32" }, { "famiu/bufdelete.nvim", commit = "8933abc09df6c381d47dc271b1ee5d266541448e" }, { "folke/lazy.nvim", version = "^9" }, { "folke/neodev.nvim", version = "^2" }, { "folke/which-key.nvim", version = "^1" }, - { "goolord/alpha-nvim", commit = "dafa11a6218c2296df044e00f88d9187222ba6b0" }, + { "goolord/alpha-nvim", commit = "89eaa18a472be680539dee5977e2255f4dbd0738" }, { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, { "hrsh7th/cmp-nvim-lsp", commit = "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, { "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" }, { "hrsh7th/nvim-cmp", commit = "a9c701fa7e12e9257b3162000e5288a75d280c28" }, - { "jay-babu/mason-null-ls.nvim", version = "^1" }, - { "jay-babu/mason-nvim-dap.nvim", version = "^1" }, - { "jose-elias-alvarez/null-ls.nvim", commit = "5855128178fa78293acdfb5b4e41ef046779240b" }, + { "jay-babu/mason-null-ls.nvim", version = "^2" }, + { "jay-babu/mason-nvim-dap.nvim", version = "^2" }, + { "jose-elias-alvarez/null-ls.nvim", commit = "71797bb303ac99a4435592e15068f127970513d7" }, { "kevinhwang91/nvim-ufo", version = "^1" }, { "kevinhwang91/promise-async", version = "^1" }, { "lewis6991/gitsigns.nvim", version = "^0.6" }, { "lukas-reineke/indent-blankline.nvim", version = "^2" }, - { "max397574/better-escape.nvim", commit = "426d29708064d5b1bfbb040424651c92af1f3f64" }, - { "mfussenegger/nvim-dap", version = "^0.5" }, + { "max397574/better-escape.nvim", commit = "7031dc734add47bb71c010e0551829fa5799375f" }, + { "mfussenegger/nvim-dap", version = "^0.6" }, { "mrjones2014/smart-splits.nvim", version = "^1" }, - { "neovim/nvim-lspconfig", commit = "7d5af779acbc8a6ff9dfd7f2d39ae898fb67480f" }, - { "numToStr/Comment.nvim", commit = "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, + { "neovim/nvim-lspconfig", commit = "5ba7ab746d814413c84ed98c0214c71cd28f130a" }, + { "numToStr/Comment.nvim", version = "^0.8" }, { "nvim-lua/plenary.nvim", version = "^0.1" }, { "nvim-neo-tree/neo-tree.nvim", version = "^2" }, { "nvim-telescope/telescope-fzf-native.nvim", commit = "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, { "nvim-telescope/telescope.nvim", version = "^0.1" }, - { "nvim-tree/nvim-web-devicons", commit = "0568104bf8d0c3ab16395433fcc5c1638efc25d4" }, - { "nvim-treesitter/nvim-treesitter", commit = "c85d059c462ae7de0aa2a6ed0589f0b223e0e6a9" }, - { "onsails/lspkind.nvim", commit = "c68b3a003483cf382428a43035079f78474cd11e" }, - { "rafamadriz/friendly-snippets", commit = "8d91ba2dc2421a54981115f61b914974f938fa77" }, + { "nvim-tree/nvim-web-devicons", commit = "986875b7364095d6535e28bd4aac3a9357e91bbe" }, + { "nvim-treesitter/nvim-treesitter", commit = "b231afbad1569c08f12cac53c6bb8deecdaba013" }, + { "onsails/lspkind.nvim", commit = "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + { "rafamadriz/friendly-snippets", commit = "10f741908e56ce47cf6b3440e3f04b4fdc0da2f2" }, { "rcarriga/nvim-dap-ui", version = "^3" }, { "rcarriga/nvim-notify", version = "^3" }, - { "rebelot/heirline.nvim", commit = "750a112a1cfaf2a7cd2d67a2d67f8f463b00d8af" }, + { "rebelot/heirline.nvim", commit = "2aed06a3a04c877dc64834e9b9dabf6ad3491bc8" }, { "s1n7ax/nvim-window-picker", version = "^1" }, { "saadparwaiz1/cmp_luasnip", commit = "18095520391186d634a0045dacaa346291096566" }, - { "stevearc/aerial.nvim", commit = "7371322c60120a56bcc833c407de96be42c18172" }, - { "stevearc/dressing.nvim", commit = "c705b3890779ea05bd910e9d06af8a209bfb6ad8" }, - { "williamboman/mason-lspconfig.nvim", commit = "d88d3564b2ae1d35163ccefda7184d7df104e198" }, - { "williamboman/mason.nvim", commit = "f778db1840248b3850613702f036f01d8846c696" }, - { "windwp/nvim-autopairs", commit = "0fd6519d44eac3a6736aafdb3fe9da916c3701d4" }, - { "windwp/nvim-ts-autotag", commit = "25698e4033cd6cd3745454bfc837dd670eba0480" }, + { "stevearc/aerial.nvim", commit = "d8f2699f7ae0e5eb62424d7b2ad80ce30179ee92" }, + { "stevearc/dressing.nvim", commit = "540d6e7115fb32b5035ddaf0c1a26cbffb855dac" }, + { "williamboman/mason-lspconfig.nvim", version = "^1.1" }, + { "williamboman/mason.nvim", version = "^1" }, + { "windwp/nvim-autopairs", commit = "7747bbae60074acf0b9e3a4c13950be7a2dff444" }, + { "windwp/nvim-ts-autotag", commit = "40615e96075c743ef47aaf9de966dc348bec6459" }, } diff --git a/nvim/.config/nvim/lua/plugins/alpha.lua b/nvim/.config/nvim/lua/plugins/alpha.lua index 58618b0..e8a345b 100644 --- a/nvim/.config/nvim/lua/plugins/alpha.lua +++ b/nvim/.config/nvim/lua/plugins/alpha.lua @@ -22,8 +22,8 @@ return { dashboard.section.buttons.val = { button("LDR n", " New File "), button("LDR f f", " Find File "), - button("LDR f o", " Recents "), - button("LDR f w", " Find Word "), + button("LDR f o", "󰈙 Recents "), + button("LDR f w", "󰈭 Find Word "), button("LDR f '", " Bookmarks "), button("LDR S l", " Last Session "), } diff --git a/nvim/.config/nvim/lua/plugins/configs/alpha.lua b/nvim/.config/nvim/lua/plugins/configs/alpha.lua index 1bd0649..ab67a6e 100644 --- a/nvim/.config/nvim/lua/plugins/configs/alpha.lua +++ b/nvim/.config/nvim/lua/plugins/configs/alpha.lua @@ -6,7 +6,7 @@ return function(_, opts) local stats = require("lazy").stats() local ms = math.floor(stats.startuptime * 100 + 0.5) / 100 opts.section.footer.val = - { " ", " ", " ", "AstroNvim loaded " .. stats.count .. " plugins  in " .. ms .. "ms" } + { " ", " ", " ", "AstroNvim loaded " .. stats.count .. " plugins  in " .. ms .. "ms" } opts.section.footer.opts.hl = "DashboardFooter" end, }) diff --git a/nvim/.config/nvim/lua/plugins/configs/mason-lspconfig.lua b/nvim/.config/nvim/lua/plugins/configs/mason-lspconfig.lua index eb93fc5..019874e 100644 --- a/nvim/.config/nvim/lua/plugins/configs/mason-lspconfig.lua +++ b/nvim/.config/nvim/lua/plugins/configs/mason-lspconfig.lua @@ -1,8 +1,4 @@ return function(_, opts) - local mason_lspconfig = require "mason-lspconfig" - mason_lspconfig.setup(opts) - mason_lspconfig.setup_handlers { - function(server) require("astronvim.utils.lsp").setup(server) end, - } + require("mason-lspconfig").setup(opts) require("astronvim.utils").event "MasonLspSetup" end diff --git a/nvim/.config/nvim/lua/plugins/configs/mason-nvim-dap.lua b/nvim/.config/nvim/lua/plugins/configs/mason-nvim-dap.lua index 842a581..d2b6ed5 100644 --- a/nvim/.config/nvim/lua/plugins/configs/mason-nvim-dap.lua +++ b/nvim/.config/nvim/lua/plugins/configs/mason-nvim-dap.lua @@ -1,5 +1,5 @@ +-- TODO: remove unnecessary file in AstroNvim v4 return function(_, opts) local mason_nvim_dap = require "mason-nvim-dap" mason_nvim_dap.setup(opts) - mason_nvim_dap.setup_handlers {} end diff --git a/nvim/.config/nvim/lua/plugins/configs/nvim-web-devicons.lua b/nvim/.config/nvim/lua/plugins/configs/nvim-web-devicons.lua index 4463459..bc6cad3 100644 --- a/nvim/.config/nvim/lua/plugins/configs/nvim-web-devicons.lua +++ b/nvim/.config/nvim/lua/plugins/configs/nvim-web-devicons.lua @@ -1,3 +1,4 @@ +-- TODO: remove unnecessary file in AstroNvim v4 return function(_, opts) require("nvim-web-devicons").set_default_icon(require("astronvim.utils").get_icon "DefaultFile", "#6d8086", "66") require("nvim-web-devicons").set_icon(opts) diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua index 7648153..cbfb910 100644 --- a/nvim/.config/nvim/lua/plugins/core.lua +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -4,7 +4,21 @@ return { { "famiu/bufdelete.nvim", cmd = { "Bdelete", "Bwipeout" } }, { "max397574/better-escape.nvim", event = "InsertCharPre", opts = { timeout = 300 } }, { "NMAC427/guess-indent.nvim", event = "User AstroFile", config = require "plugins.configs.guess-indent" }, - { "Shatur/neovim-session-manager", event = "BufWritePost", cmd = "SessionManager" }, + { -- TODO: REMOVE neovim-session-manager with AstroNvim v4 + "Shatur/neovim-session-manager", + event = "BufWritePost", + cmd = "SessionManager", + enabled = vim.g.resession_enabled ~= true, + }, + { + "stevearc/resession.nvim", + enabled = vim.g.resession_enabled == true, + opts = { + buf_filter = function(bufnr) return require("astronvim.utils.buffer").is_valid(bufnr) end, + tab_buf_filter = function(tabpage, bufnr) return vim.tbl_contains(vim.t[tabpage].bufs, bufnr) end, + extensions = { astronvim = {} }, + }, + }, { "s1n7ax/nvim-window-picker", opts = { use_winbar = "smart" } }, { "mrjones2014/smart-splits.nvim", diff --git a/nvim/.config/nvim/lua/plugins/dap.lua b/nvim/.config/nvim/lua/plugins/dap.lua index 96df42e..59a4c92 100644 --- a/nvim/.config/nvim/lua/plugins/dap.lua +++ b/nvim/.config/nvim/lua/plugins/dap.lua @@ -6,8 +6,7 @@ return { "jay-babu/mason-nvim-dap.nvim", dependencies = { "nvim-dap" }, cmd = { "DapInstall", "DapUninstall" }, - opts = { automatic_setup = true }, - config = require "plugins.configs.mason-nvim-dap", + opts = { handlers = {} }, }, { "rcarriga/nvim-dap-ui", diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua index cde7712..6bb18ff 100644 --- a/nvim/.config/nvim/lua/plugins/git.lua +++ b/nvim/.config/nvim/lua/plugins/git.lua @@ -1,14 +1,13 @@ return { "lewis6991/gitsigns.nvim", enabled = vim.fn.executable "git" == 1, - ft = "gitcommit", event = "User AstroGitFile", opts = { signs = { add = { text = "▎" }, change = { text = "▎" }, delete = { text = "▎" }, - topdelete = { text = "契" }, + topdelete = { text = "󰐊" }, changedelete = { text = "▎" }, untracked = { text = "▎" }, }, diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index cd271f7..5774404 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -20,6 +20,10 @@ return { { "williamboman/mason-lspconfig.nvim", cmd = { "LspInstall", "LspUninstall" }, + opts = function(_, opts) + if not opts.handlers then opts.handlers = {} end + opts.handlers[1] = function(server) require("astronvim.utils.lsp").setup(server) end + end, config = require "plugins.configs.mason-lspconfig", }, }, @@ -32,7 +36,7 @@ return { { "jay-babu/mason-null-ls.nvim", cmd = { "NullLsInstall", "NullLsUninstall" }, - opts = { automatic_setup = true, handlers = {} }, + opts = { handlers = {} }, }, }, event = "User AstroFile", diff --git a/nvim/.config/nvim/lua/plugins/mason.lua b/nvim/.config/nvim/lua/plugins/mason.lua index 72902f3..ca9f595 100644 --- a/nvim/.config/nvim/lua/plugins/mason.lua +++ b/nvim/.config/nvim/lua/plugins/mason.lua @@ -19,6 +19,7 @@ return { }, }, }, + build = ":MasonUpdate", config = require "plugins.configs.mason", }, } diff --git a/nvim/.config/nvim/lua/plugins/neo-tree.lua b/nvim/.config/nvim/lua/plugins/neo-tree.lua index 76822ee..a43eb94 100644 --- a/nvim/.config/nvim/lua/plugins/neo-tree.lua +++ b/nvim/.config/nvim/lua/plugins/neo-tree.lua @@ -1,11 +1,46 @@ +local get_icon = require("astronvim.utils").get_icon return { "nvim-neo-tree/neo-tree.nvim", dependencies = { "MunifTanjim/nui.nvim" }, cmd = "Neotree", init = function() vim.g.neo_tree_remove_legacy_commands = true end, - opts = function() - -- TODO: move after neo-tree improves (https://github.com/nvim-neo-tree/neo-tree.nvim/issues/707) - local global_commands = { + opts = { + auto_clean_after_session_restore = true, + close_if_last_window = true, + source_selector = { + winbar = true, + content_layout = "center", + sources = { + { source = "filesystem", display_name = get_icon "FolderClosed" .. " File" }, + { source = "buffers", display_name = get_icon "DefaultFile" .. " Bufs" }, + { source = "git_status", display_name = get_icon "Git" .. " Git" }, + { source = "diagnostics", display_name = get_icon "Diagnostic" .. " Diagnostic" }, + }, + }, + default_component_configs = { + indent = { padding = 0, indent_size = 1 }, + icon = { + folder_closed = get_icon "FolderClosed", + folder_open = get_icon "FolderOpen", + folder_empty = get_icon "FolderEmpty", + default = get_icon "DefaultFile", + }, + modified = { symbol = get_icon "FileModified" }, + git_status = { + symbols = { + added = get_icon "GitAdd", + deleted = get_icon "GitDelete", + modified = get_icon "GitChange", + renamed = get_icon "GitRenamed", + untracked = get_icon "GitUntracked", + ignored = get_icon "GitIgnored", + unstaged = get_icon "GitUnstaged", + staged = get_icon "GitStaged", + conflict = get_icon "GitConflict", + }, + }, + }, + commands = { system_open = function(state) require("astro