From e8588369a7c2cc0f31b0439ff21c89d4c637a3e8 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 3 Apr 2026 01:44:58 +0300 Subject: [PATCH] . --- .config/fish/completions/bun.fish | 20 ++++-- .config/nvim/lua/autocmd.lua | 1 + .config/nvim/lua/keymaps.lua | 16 +++++ .config/nvim/lua/options.lua | 1 - .config/nvim/lua/plugins/autopairs.lua | 2 +- .config/nvim/lua/plugins/flash.lua | 33 +++++---- .config/nvim/lua/plugins/init.lua | 2 +- .config/nvim/lua/plugins/treesitter.lua | 94 ++++++------------------- .config/nvim/nvim-pack-lock.json | 23 +++--- 9 files changed, 89 insertions(+), 103 deletions(-) diff --git a/.config/fish/completions/bun.fish b/.config/fish/completions/bun.fish index e262bb6..6b2dc5b 100644 --- a/.config/fish/completions/bun.fish +++ b/.config/fish/completions/bun.fish @@ -35,8 +35,8 @@ end set -l bun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't update package.json or save a lockfile" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependencies" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder" -set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x -set -l bun_builtin_cmds_accepting_flags create help bun upgrade discord run init link unlink pm x +set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add update init pm x repl +set -l bun_builtin_cmds_accepting_flags create help bun upgrade discord run init link unlink pm x update function __bun_complete_bins_scripts --inherit-variable bun_builtin_cmds_without_run -d "Emit bun completions for bins and scripts" # Do nothing if we already have a builtin subcommand, @@ -148,14 +148,14 @@ complete -c bun \ for i in (seq (count $bun_install_boolean_flags)) complete -c bun \ - -n "__fish_seen_subcommand_from install add remove" -l "$bun_install_boolean_flags[$i]" -d "$bun_install_boolean_flags_descriptions[$i]" + -n "__fish_seen_subcommand_from install add remove update" -l "$bun_install_boolean_flags[$i]" -d "$bun_install_boolean_flags_descriptions[$i]" end complete -c bun \ - -n "__fish_seen_subcommand_from install add remove" -l 'cwd' -d 'Change working directory' + -n "__fish_seen_subcommand_from install add remove update" -l 'cwd' -d 'Change working directory' complete -c bun \ - -n "__fish_seen_subcommand_from install add remove" -l 'cache-dir' -d 'Choose a cache directory (default: $HOME/.bun/install/cache)' + -n "__fish_seen_subcommand_from install add remove update" -l 'cache-dir' -d 'Choose a cache directory (default: $HOME/.bun/install/cache)' complete -c bun \ -n "__fish_seen_subcommand_from add" -d 'Popular' -a '(__fish__get_bun_packages)' @@ -183,4 +183,14 @@ complete -c bun -n "__fish_use_subcommand" -a "unlink" -d "Unregister a local np complete -c bun -n "__fish_use_subcommand" -a "pm" -d "Additional package management utilities" -f complete -c bun -n "__fish_use_subcommand" -a "x" -d "Execute a package binary, installing if needed" -f complete -c bun -n "__fish_use_subcommand" -a "outdated" -d "Display the latest versions of outdated dependencies" -f +complete -c bun -n "__fish_use_subcommand" -a "update" -d "Update dependencies to their latest versions" -f complete -c bun -n "__fish_use_subcommand" -a "publish" -d "Publish your package from local to npm" -f +complete -c bun -n "__fish_use_subcommand" -a "repl" -d "Start a REPL session with Bun" -f +complete -c bun -n "__fish_seen_subcommand_from repl" -s "e" -l "eval" -r -d "Evaluate argument as a script, then exit" -f +complete -c bun -n "__fish_seen_subcommand_from repl" -s "p" -l "print" -r -d "Evaluate argument as a script, print the result, then exit" -f +complete -c bun -n "__fish_seen_subcommand_from repl" -s "r" -l "preload" -r -d "Import a module before other modules are loaded" +complete -c bun -n "__fish_seen_subcommand_from repl" -l "smol" -d "Use less memory, but run garbage collection more often" -f +complete -c bun -n "__fish_seen_subcommand_from repl" -s "c" -l "config" -r -d "Specify path to Bun config file" +complete -c bun -n "__fish_seen_subcommand_from repl" -l "cwd" -r -d "Absolute path to resolve files & entry points from" +complete -c bun -n "__fish_seen_subcommand_from repl" -l "env-file" -r -d "Load environment variables from the specified file(s)" +complete -c bun -n "__fish_seen_subcommand_from repl" -l "no-env-file" -d "Disable automatic loading of .env files" -f diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua index 8b95048..c01fe54 100644 --- a/.config/nvim/lua/autocmd.lua +++ b/.config/nvim/lua/autocmd.lua @@ -53,6 +53,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { pattern = vim.fn.stdpath("config") .. "/**", callback = function() vim.cmd("AutoSession save") + vim.cmd("wa!") vim.cmd("restart") end, }) diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 33c7e13..1b84fb9 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -101,3 +101,19 @@ map("v", "", ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { map("v", "<", "", ">gv") + +map({ "n", "o", "v" }, "", function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require("vim.treesitter._select").select_parent(vim.v.count1) + else + vim.lsp.buf.selection_range(vim.v.count1) + end +end, { desc = "Select parent treesitter node or outer incremental lsp selections" }) + +map({ "n", "o", "v" }, "", function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require("vim.treesitter._select").select_child(vim.v.count1) + else + vim.lsp.buf.selection_range(-vim.v.count1) + end +end, { desc = "Select child treesitter node or inner incremental lsp selections" }) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 4372530..ba7ccb6 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -69,7 +69,6 @@ vim.opt.scrolloff = 10 -- folds vim.opt.foldcolumn = "0" vim.opt.foldmethod = "expr" -vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.opt.foldtext = "" -- vim.opt.foldnestmax = 3 diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua index 790ebf6..6f2898c 100644 --- a/.config/nvim/lua/plugins/autopairs.lua +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -2,4 +2,4 @@ vim.pack.add({ "https://github.com/windwp/nvim-autopairs" }) local Autopairs = require("nvim-autopairs") -Autopairs.setup({}) +Autopairs.setup({ map_cr = false }) diff --git a/.config/nvim/lua/plugins/flash.lua b/.config/nvim/lua/plugins/flash.lua index 4f2c166..f3f614b 100644 --- a/.config/nvim/lua/plugins/flash.lua +++ b/.config/nvim/lua/plugins/flash.lua @@ -3,19 +3,24 @@ vim.pack.add({ "https://github.com/folke/flash.nvim" }) local Flash = require("flash") Flash.setup({ - jump = { - autojump = true, - }, - label = { - after = true, - min_pattern_length = 1, - style = "overlay", - }, - search = { - mode = "search", - }, - }) + jump = { + autojump = true, + }, + label = { + after = true, + min_pattern_length = 1, + style = "overlay", + }, + search = { + mode = "search", + }, +}) + +vim.keymap.set({ "n", "x", "o" }, "s", function() + require("flash").jump() +end, { desc = "Flash" }) -vim.keymap.set({ "n", "x", "o" }, "s", function() require("flash").jump() end, { desc = "Flash" }) -- TODO: use treesitter objects for vim motions --- vim.keymap.set({ "o", "x" }, "R", function() require("flash").treesitter_search() end, { desc = "Treesitter Search" }) +vim.keymap.set({ "o", "x" }, "R", function() + require("flash").treesitter_search() +end, { desc = "Treesitter Search" }) diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 9492c89..72761f6 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -6,6 +6,7 @@ require("plugins.luasnip") require("plugins.surround") require("plugins.conform") require("plugins.flash") +require("plugins.blink") require("plugins.autopairs") require("plugins.treesitter") require("plugins.lualine") @@ -14,7 +15,6 @@ require("plugins.cursor") require("plugins.snacks") require("plugins.aerial") require("plugins.i18n") -require("plugins.blink") require("plugins.session") require("plugins.markdown") require("plugins.grug") diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index 346db9d..ab0bd9a 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,78 +1,30 @@ -vim.pack.add({ { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" } }) +vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter" }) -local configs = require("nvim-treesitter.configs") +local ts = require("nvim-treesitter") -configs.setup({ - ensure_installed = { - "bash", - "blade", - "c", - "comment", - "css", - "diff", - "dockerfile", - "fish", - "gitcommit", - "gitignore", - "go", - "gomod", - "gosum", - "gowork", - "html", - "ini", - "javascript", - "jsdoc", - "json", - "lua", - "luadoc", - "luap", - "make", - "markdown", - "markdown_inline", - "nginx", - "nix", - "proto", - "python", - "query", - "regex", - "rust", - "scss", - "sql", - "toml", - "tsx", - "typescript", - "vim", - "vimdoc", - "xml", - "yaml", - "zig", - }, - auto_install = true, - sync_install = true, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - scope_incremental = "", - node_incremental = "", - node_decremental = "", - }, - }, -}) +-- Installs treesitter for filetype if available +-- enables highlighting and indentation +vim.api.nvim_create_autocmd("FileType", { + pattern = { "*" }, + callback = function(args) + local ft = vim.bo[args.buf].filetype + local lang = vim.treesitter.language.get_lang(ft) -vim.api.nvim_create_autocmd("PackChanged", { - desc = "Handle nvim-treesitter updates", - group = vim.api.nvim_create_augroup("nvim-treesitter-pack-changed-update-handler", { clear = true }), - callback = function(event) - if event.data.kind == "update" then - local ok = pcall(vim.cmd, "TSUpdate") - if ok then - vim.notify("TSUpdate completed successfully!", vim.log.levels.INFO) - else - vim.notify("TSUpdate command not available yet, skipping", vim.log.levels.WARN) + if not vim.treesitter.language.add(lang) then + local available = vim.g.ts_available or ts.get_available() + if not vim.g.ts_available then + vim.g.ts_available = available end + if vim.tbl_contains(available, lang) then + ts.install(lang) + end + end + + if vim.treesitter.language.add(lang) then + vim.treesitter.start(args.buf, lang) + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.wo[0][0].foldmethod = "expr" end end, }) diff --git a/.config/nvim/nvim-pack-lock.json b/.config/nvim/nvim-pack-lock.json index a80d85f..177e2f4 100644 --- a/.config/nvim/nvim-pack-lock.json +++ b/.config/nvim/nvim-pack-lock.json @@ -14,7 +14,7 @@ "src": "https://github.com/rmagatti/auto-session" }, "blink.cmp": { - "rev": "612f4bd2bc29d9e7dc7be1dde960908951bedad1", + "rev": "679a2ffad4bae720bb12e6bcdf57b0dd8b8a80f8", "src": "https://github.com/saghen/blink.cmp" }, "conform.nvim": { @@ -37,6 +37,10 @@ "rev": "128959499a9425bb4f1a5574fd92a23be00cb442", "src": "https://github.com/yelog/i18n.nvim" }, + "incr.nvim": { + "rev": "87aa1f6de5c10e60d57b0bc151573a5c50ac9fe6", + "src": "https://github.com/daliusd/incr.nvim" + }, "js-i18n.nvim": { "rev": "124f22f91d51e85641ba10e9a32f3b858394c2dd", "src": "https://github.com/nabekou29/js-i18n.nvim", @@ -67,17 +71,16 @@ "src": "https://github.com/windwp/nvim-autopairs" }, "nvim-lspconfig": { - "rev": "841c6d4139aedb8a3f2baf30cef5327371385b93", + "rev": "8e2084bf5e40c79c1f42210a6ef96a0a4793a763", "src": "https://github.com/neovim/nvim-lspconfig" }, "nvim-surround": { - "rev": "61319d4bd1c5e336e197defa15bd104c51f0fb29", + "rev": "19e39478ccf5fa2eefdb3595af2f2927d0ff2416", "src": "https://github.com/kylechui/nvim-surround" }, "nvim-treesitter": { - "rev": "42fc28ba918343ebfd5565147a42a26580579482", - "src": "https://github.com/nvim-treesitter/nvim-treesitter", - "version": "'master'" + "rev": "539abf6da5ee8702e37b82cc953131dadd570da2", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" }, "nvim-web-devicons": { "rev": "d7462543c9e366c0d196c7f67a945eaaf5d99414", @@ -88,7 +91,7 @@ "src": "https://github.com/nvim-lua/plenary.nvim" }, "render-markdown.nvim": { - "rev": "e3c18ddd27a853f85a6f513a864cf4f2982b9f26", + "rev": "c7188a8f9d2953696b6303caccbf39c51fa2c1b1", "src": "https://github.com/MeanderingProgrammer/render-markdown.nvim" }, "smear-cursor.nvim": { @@ -96,11 +99,11 @@ "src": "https://github.com/sphamba/smear-cursor.nvim" }, "snacks.nvim": { - "rev": "e6fd58c82f2f3fcddd3fe81703d47d6d48fc7b9f", + "rev": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e", "src": "https://github.com/folke/snacks.nvim" }, "tokyonight.nvim": { - "rev": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd", + "rev": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6", "src": "https://github.com/folke/tokyonight.nvim" }, "which-key.nvim": { @@ -108,4 +111,4 @@ "src": "https://github.com/folke/which-key.nvim" } } -} \ No newline at end of file +}