diff options
Diffstat (limited to 'ar/.config')
| -rw-r--r-- | ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/ai.lua | 47 | ||||
| -rw-r--r-- | ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/textobject.lua | 309 | ||||
| -rw-r--r-- | ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/treesitter.lua | 78 | ||||
| -rw-r--r-- | ar/.config/shell/profile | 13 | ||||
| -rw-r--r-- | ar/.config/yazi/keymap-default.toml | 2 |
5 files changed, 256 insertions, 193 deletions
diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/ai.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/ai.lua index 6ff4ac6..52ceb01 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/ai.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/ai.lua @@ -260,6 +260,53 @@ return { }, }, { + "NickvanDyke/opencode.nvim", + dependencies = { + -- Recommended for `ask()` and `select()`. + -- Required for `snacks` provider. + ---@module 'snacks' <- Loads `snacks.nvim` types for configuration intellisense. + { "folke/snacks.nvim", opts = { input = {}, picker = {}, terminal = {} } }, + }, + config = function() + ---@type opencode.Opts + vim.g.opencode_opts = { + -- Your configuration, if any — see `lua/opencode/config.lua`, or "goto definition". + } + + -- Required for `opts.events.reload`. + vim.o.autoread = true + + -- Recommended/example keymaps. + vim.keymap.set({ "n", "x" }, "<C-a>", function() + require("opencode").ask("@this: ", { submit = true }) + end, { desc = "Ask opencode" }) + vim.keymap.set({ "n", "x" }, "<C-x>", function() + require("opencode").select() + end, { desc = "Execute opencode action…" }) + vim.keymap.set({ "n", "t" }, "<C-.>", function() + require("opencode").toggle() + end, { desc = "Toggle opencode" }) + + vim.keymap.set({ "n", "x" }, "go", function() + return require("opencode").operator("@this ") + end, { expr = true, desc = "Add range to opencode" }) + vim.keymap.set("n", "goo", function() + return require("opencode").operator("@this ") .. "_" + end, { expr = true, desc = "Add line to opencode" }) + + vim.keymap.set("n", "<S-C-u>", function() + require("opencode").command("session.half.page.up") + end, { desc = "opencode half page up" }) + vim.keymap.set("n", "<S-C-d>", function() + require("opencode").command("session.half.page.down") + end, { desc = "opencode half page down" }) + + -- You may want these if you stick with the opinionated "<C-a>" and "<C-x>" above — otherwise consider "<leader>o". + vim.keymap.set("n", "+", "<C-a>", { desc = "Increment", noremap = true }) + vim.keymap.set("n", "-", "<C-x>", { desc = "Decrement", noremap = true }) + end, + }, + { "kkrampis/codex.nvim", lazy = true, cmd = { "Codex", "CodexToggle" }, -- Optional: Load only on command execution diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/textobject.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/textobject.lua index 2aa7054..b82eac6 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/textobject.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/textobject.lua @@ -1,140 +1,173 @@ return { - -- "nvim-treesitter/nvim-treesitter-textobjects", - -- dependencies = { - -- { "nvim-treesitter", build = ":TSUpdate" }, - -- { "nvim-treesitter/nvim-treesitter" }, - -- { - -- "chrisgrieser/nvim-various-textobjs", - -- event = "UIEnter", - -- opts = { - -- keymaps = { - -- useDefaults = true, - -- }, - -- }, - -- }, - -- }, - -- init = function() - -- local wk = require("which-key") - -- wk.add({ - -- { - -- mode = { "n", "v", "x" }, - -- { "g>", group = "Swap next" }, - -- { "g<", group = "Swap prev" }, - -- { "<leader>]", group = "Next" }, - -- { "<leader>[", group = "Prev" }, - -- }, - -- }) - -- end, - -- config = function() - -- require("nvim-treesitter.configs").setup({ - -- textobjects = { - -- select = { - -- enable = true, - -- - -- -- Automatically jump forward to textobj, similar to targets.vim - -- lookahead = true, - -- - -- keymaps = { - -- -- You can use the capture groups defined in textobjects.scm - -- ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, - -- ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, - -- ["h="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, - -- ["l="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, - -- - -- -- works for javascript/typescript files (custom capture I created in after/queries/ecma/textobjects.scm) - -- ["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" }, - -- ["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" }, - -- ["h:"] = { query = "@property.lhs", desc = "Select left part of an object property" }, - -- ["l:"] = { query = "@property.rhs", desc = "Select right part of an object property" }, - -- - -- ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, - -- ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, - -- - -- ["an"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, - -- ["in"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, - -- - -- ["ap"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, - -- ["ip"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, - -- - -- ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, - -- ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, - -- - -- ["am"] = { - -- query = "@function.outer", - -- desc = "Select outer part of a method/function definition", - -- }, - -- ["im"] = { - -- query = "@function.inner", - -- desc = "Select inner part of a method/function definition", - -- }, - -- - -- ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, - -- ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, - -- }, - -- }, - -- swap = { - -- enable = true, - -- swap_next = { - -- ["g>a"] = { query = "@parameter.inner", desc = "swap parameters/argument with next" }, - -- ["g>:"] = { query = "@property.outer", desc = "swap object property with next" }, - -- ["g>m"] = { query = "@function.outer", desc = "swap function with next" }, - -- }, - -- swap_previous = { - -- ["g<a"] = { query = "@parameter.inner", desc = "swap parameters/argument with prev" }, - -- ["g<:"] = { query = "@property.outer", desc = "swap object property with prev" }, - -- ["g<m"] = { query = "@function.outer", desc = "swap function with previous" }, - -- }, - -- }, - -- move = { - -- enable = true, - -- set_jumps = true, -- whether to set jumps in the jumplist - -- goto_next_start = { - -- ["]f"] = { query = "@call.outer", desc = "Next function call start" }, - -- ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, - -- ["]c"] = { query = "@class.outer", desc = "Next class start" }, - -- ["]="] = { query = "@conditional.outer", desc = "Next conditional start" }, - -- ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, - -- - -- -- You can pass a query group to use query from `queries/<lang>/<query_group>.scm file in your runtime path. - -- -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. - -- ["]-"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, - -- ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, - -- }, - -- goto_next_end = { - -- ["]F"] = { query = "@call.outer", desc = "Next function call end" }, - -- ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, - -- ["]C"] = { query = "@class.outer", desc = "Next class end" }, - -- ["]+"] = { query = "@conditional.outer", desc = "Next conditional end" }, - -- ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, - -- }, - -- goto_previous_start = { - -- ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, - -- ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, - -- ["[c"] = { query = "@class.outer", desc = "Prev class start" }, - -- ["[="] = { query = "@conditional.outer", desc = "Prev conditional start" }, - -- ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, - -- }, - -- goto_previous_end = { - -- ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, - -- ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, - -- ["[C"] = { query = "@class.outer", desc = "Prev class end" }, - -- ["[+"] = { query = "@conditional.outer", desc = "Prev conditional end" }, - -- ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, - -- }, - -- }, - -- }, - -- }) - -- - -- local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") - -- - -- -- vim way: ; goes to the direction you were moving. - -- vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) - -- vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) - -- - -- -- Optionally, make builtin f, F, t, T also repeatable with ; and , - -- vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f_expr, { expr = true }) - -- vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F_expr, { expr = true }) - -- vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t_expr, { expr = true }) - -- vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T_expr, { expr = true }) - -- end, + "nvim-treesitter/nvim-treesitter-textobjects", + branch = "main", + dependencies = { + { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + { + "chrisgrieser/nvim-various-textobjs", + event = "UIEnter", + opts = { + keymaps = { + useDefaults = true, + }, + }, + }, + }, + init = function() + -- Disable entire built-in ftplugin mappings to avoid conflicts. + -- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins. + vim.g.no_plugin_maps = true + + -- Or, disable per filetype (add as you like) + -- vim.g.no_python_maps = true + -- vim.g.no_ruby_maps = true + -- vim.g.no_rust_maps = true + -- vim.g.no_go_maps = true + + local wk = require("which-key") + wk.add({ + { + mode = { "n", "v", "x" }, + { "g>", group = "Swap next" }, + { "g<", group = "Swap prev" }, + { "<leader>]", group = "Next" }, + { "<leader>[", group = "Prev" }, + }, + }) + end, + config = function() + require("nvim-treesitter-textobjects").setup({ + select = { + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '<c-v>') or a table + -- mapping query_strings to modes. + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + ["@class.outer"] = "<c-v>", -- blockwise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true of false + include_surrounding_whitespace = false, + }, + move = { + -- whether to set jumps in the jumplist + set_jumps = true, + }, + }) + + -- keymaps + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ "x", "o" }, "am", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "im", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ac", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ic", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ "x", "o" }, "as", function() + require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals") + end) + -- keymaps + vim.keymap.set("n", "<leader>a", function() + require("nvim-treesitter-textobjects.swap").swap_next("@parameter.inner") + end) + vim.keymap.set("n", "<leader>A", function() + require("nvim-treesitter-textobjects.swap").swap_previous("@parameter.outer") + end) + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ "n", "x", "o" }, "]m", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "]]", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@class.outer", "textobjects") + end) + -- You can also pass a list to group multiple queries. + vim.keymap.set({ "n", "x", "o" }, "]o", function() + move.goto_next_start({ "@loop.inner", "@loop.outer" }, "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` or `folds.scm` + vim.keymap.set({ "n", "x", "o" }, "]s", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@local.scope", "locals") + end) + vim.keymap.set({ "n", "x", "o" }, "]z", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@fold", "folds") + end) + + vim.keymap.set({ "n", "x", "o" }, "]M", function() + require("nvim-treesitter-textobjects.move").goto_next_end("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "][", function() + require("nvim-treesitter-textobjects.move").goto_next_end("@class.outer", "textobjects") + end) + + vim.keymap.set({ "n", "x", "o" }, "[m", function() + require("nvim-treesitter-textobjects.move").goto_previous_start("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[[", function() + require("nvim-treesitter-textobjects.move").goto_previous_start("@class.outer", "textobjects") + end) + + vim.keymap.set({ "n", "x", "o" }, "[M", function() + require("nvim-treesitter-textobjects.move").goto_previous_end("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[]", function() + require("nvim-treesitter-textobjects.move").goto_previous_end("@class.outer", "textobjects") + end) + + -- Go to either the start or the end, whichever is closer. + -- Use if you want more granular movements + vim.keymap.set({ "n", "x", "o" }, "]d", function() + require("nvim-treesitter-textobjects.move").goto_next("@conditional.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[d", function() + require("nvim-treesitter-textobjects.move").goto_previous("@conditional.outer", "textobjects") + end) + + local ts_repeat_move = require("nvim-treesitter-textobjects.repeatable_move") + + -- Repeat movement with ; and , + -- ensure ; goes forward and , goes backward regardless of the last direction + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous) + + -- vim way: ; goes to the direction you were moving. + -- vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) + -- vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + + -- Optionally, make builtin f, F, t, T also repeatable with ; and , + vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T_expr, { expr = true }) + + -- This repeats the last query with always previous direction and to the start of the range. + vim.keymap.set({ "n", "x", "o" }, "<home>", function() + ts_repeat_move.repeat_last_move({ forward = false, start = true }) + end) + + -- This repeats the last query with always next direction and to the end of the range. + vim.keymap.set({ "n", "x", "o" }, "<end>", function() + ts_repeat_move.repeat_last_move({ forward = true, start = false }) + end) + end, } diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/treesitter.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/treesitter.lua index 7ca4ae9..7a9639c 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/treesitter.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/plugins/treesitter.lua @@ -1,62 +1,38 @@ return { "nvim-treesitter/nvim-treesitter", + lazy = false, build = ":TSUpdate", dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" }, config = function() require("nvim-treesitter").setup({ - -- A list of parser names, or "all" - ensure_installed = { - "bash", - "c", - "cpp", - "dockerfile", - "html", - "java", - "json5", - "latex", - "lua", - "markdown", - "markdown_inline", - "python", - "sql", - "vim", - "vimdoc", - }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = true, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don"t have `tree-sitter` CLI installed locally - auto_install = true, - - -- List of parsers to ignore installing (or "all") - ignore_install = {}, - - highlight = { - -- `false` will disable the whole extension - enable = true, - disable = { "csv" }, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on "syntax" being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = { "markdown" }, - }, + install_dir = vim.fn.stdpath("data") .. "/treesitter", }) - - -- local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs() - -- treesitter_parser_config.templ = { - -- install_info = { - -- url = "https://github.com/vrischmann/tree-sitter-templ.git", - -- files = { "src/parser.c", "src/scanner.c" }, - -- branch = "master", - -- }, - -- } - -- - -- vim.treesitter.language.register("templ", "templ") end, keys = { - { "<leader>T", ":TSUpdate<cr>", desc = "Update treesitter" }, + { "<leader>TU", ":TSUpdate<cr>", desc = "Update treesitter" }, + { + "<leader>TI", + function() + require("nvim-treesitter").install({ + "bash", + "c", + "cpp", + "dockerfile", + "html", + "java", + "javascript", + "json5", + "latex", + "lua", + "markdown", + "markdown_inline", + "python", + "sql", + "vim", + "vimdoc", + }) + end, + desc = "Update treesitter", + }, }, } diff --git a/ar/.config/shell/profile b/ar/.config/shell/profile index 4d3312b..f68a4b8 100644 --- a/ar/.config/shell/profile +++ b/ar/.config/shell/profile @@ -20,8 +20,11 @@ unsetopt PROMPT_SP 2>/dev/null export BROWSER=$(command -v librewolf || command -v firefox || command -v qutebrowser) export EDITOR="nvim" export EDITOR2="vim" -# export FILE_MANAGER="lf $(lf -version)" -export FILE_MANAGER="yazi $(yazi --version)" +if command -v lf >/dev/null 2>&1; then + export FILE_MANAGER="lf $(lf -version)" +elif command -v yazi >/dev/null 2>&1; then + export FILE_MANAGER="yazi $(yazi --version)" +fi export KEYTIMEOUT=10 export SUDO_EDITOR=$EDITOR export SUDO_ASKPASS="$HOME/.local/bin/dmenupass" @@ -61,6 +64,10 @@ export ANDROID_SDK_HOME="$XDG_CONFIG_HOME/android" ### --- ANSIBLE --- ### export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible/ansible.cfg" +### --- ASDF --- ### +export ASDF_CONFIG_FILE="$XDG_CONFIG_HOME/asdf/asdfrc" +export ASDF_DATA_DIR="$XDG_DATA_HOME/asdf" + ### --- BAT --- ### export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/bat/config" @@ -262,7 +269,7 @@ export SDCV_PAGER='less --quit-if-one-screen -RX' [ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f shortcuts >/dev/null 2>&1 ### --- START GRAPHICAL SERVER ON USER'S CURRENT TTY IF NOT ALREADY RUNNING --- ### -[ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC" +tty -s && [ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC" ### --- LAPTOP KEYMAP --- ### sudo -n loadkeys "$XDG_DATA_HOME/thesiah/ttymaps.kmap" 2>/dev/null diff --git a/ar/.config/yazi/keymap-default.toml b/ar/.config/yazi/keymap-default.toml index 6b7acad..24c5376 100644 --- a/ar/.config/yazi/keymap-default.toml +++ b/ar/.config/yazi/keymap-default.toml @@ -190,7 +190,7 @@ run = "plugin chmod" desc = "Chmod on selected files" [[mgr.prepend_keymap]] -on = "<C-d>" +on = [ "g", "f" ] run = "plugin diff" desc = "Diff the selected with the hovered file" |
