diff options
3 files changed, 183 insertions, 144 deletions
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/core/autocmds.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/core/autocmds.lua index b981a3c..feaa619 100644 --- a/ar/.config/TheSiahxyz/lua/thesiahxyz/core/autocmds.lua +++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/core/autocmds.lua @@ -31,7 +31,7 @@ autocmd("TextYankPost", { end, }) --- resize splits if window got resized +-- Resize splits if window got resized autocmd({ "VimResized" }, { group = augroup("window_config"), callback = function() @@ -41,7 +41,7 @@ autocmd({ "VimResized" }, { end, }) --- go to last loc when opening a buffer +-- Go to last loc when opening a buffer autocmd("BufReadPost", { group = augroup("last_loc"), callback = function(event) @@ -59,7 +59,7 @@ autocmd("BufReadPost", { end, }) --- close some filetypes with <q> +-- Close some filetypes with <q> autocmd("FileType", { group = augroup("close_with_q"), pattern = { @@ -156,6 +156,17 @@ autocmd("BufWritePre", { end, }) +-- Go to insert mode in terminal +local win_enter = augroup("win_enter") +autocmd("WinEnter", { + group = win_enter, + callback = function() + if vim.bo.buftype == "terminal" then + vim.cmd("startinsert") + end + end, +}) + -- Correct email signature delimiter in neomutt files autocmd("BufWritePre", { group = file_save, @@ -233,13 +244,13 @@ vim.api.nvim_create_user_command("SudoWritequit", function() end, {}) -- Markdown for specific files and directories -vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { +autocmd({ "BufRead", "BufNewFile" }, { pattern = { "/tmp/calcurse*", "~/.calcurse/notes/*" }, command = "set filetype=markdown", }) -- Groff for specific file extensions -vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { +autocmd({ "BufRead", "BufNewFile" }, { pattern = { "*.ms", "*.me", "*.mom", "*.man" }, callback = function() vim.cmd([[ @@ -254,13 +265,13 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { }) -- TeX for .tex files -vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { +autocmd({ "BufRead", "BufNewFile" }, { pattern = { "*.tex" }, command = "set filetype=tex", }) -- When shortcut files are updated, renew bash and lf configs with new material: -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = augroup("bookmarks"), pattern = { "bm-files", "bm-dirs" }, callback = function() @@ -276,7 +287,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { -- Source lfrc if it's edited local lf_config = augroup("lf_config") -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = lf_config, pattern = { "lfrc" }, callback = function() @@ -286,7 +297,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { -- Set vimwiki's index filetype to vimwiki instead of markdown local vimwiki_config = augroup("vimwiki_config") -vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { +autocmd({ "BufRead", "BufNewFile" }, { group = vimwiki_config, pattern = vim.fn.expand("~/.local/share/vimwiki") .. "/**/*.md", callback = function(args) @@ -296,14 +307,14 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { -- Run xrdb whenever Xdefaults or Xresources are updated. local x_config = augroup("x_config") -vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { +autocmd({ "BufRead", "BufNewFile" }, { group = x_config, pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, callback = function() vim.bo.filetype = "xdefaults" end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = x_config, pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, callback = function() @@ -315,7 +326,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { local home = os.getenv("HOME") local suckless_config = vim.api.nvim_create_augroup("suckless_config", { clear = true }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = suckless_config, pattern = home .. "/.local/src/suckless/dmenu/config.def.h", callback = function() @@ -323,7 +334,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = suckless_config, pattern = home .. "/.local/src/suckless/dwmblocks/config.def.h", callback = function() @@ -335,7 +346,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = suckless_config, pattern = home .. "/.local/src/suckless/slock/config.def.h", callback = function() @@ -344,7 +355,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { }) local suckless_keys = augroup("suckless_keys") -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = suckless_keys, pattern = home .. "/.local/src/suckless/dwm/config.def.h", callback = function() @@ -352,7 +363,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = suckless_keys, pattern = home .. "/.local/src/suckless/st/config.def.h", callback = function() @@ -360,7 +371,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { end, }) -vim.api.nvim_create_autocmd("BufWritePost", { +autocmd("BufWritePost", { group = augroup("suckless_doc"), pattern = home .. "/.local/src/suckless/dwm/thesiah-default.mom", callback = function() @@ -368,7 +379,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { end, }) -vim.api.nvim_create_autocmd({ "BufRead", "BufEnter" }, { +autocmd({ "BufRead", "BufEnter" }, { pattern = { "*.c", "*.cpp", "*.h", "*.hpp" }, callback = function() local suckless_path = vim.fn.expand("~/.local/src/suckless"):gsub("/+$", "") diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/neo-tree.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/neo-tree.lua index b21b130..6666f2d 100644 --- a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/neo-tree.lua +++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/neo-tree.lua @@ -1,121 +1,141 @@ return { - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - { "3rd/image.nvim", opts = {} }, -- Optional image support in preview window: See `# Preview Mode` for more information - }, - lazy = false, -- neo-tree will lazily load itself - ---@module "neo-tree" - ---@type neotree.Config? - opts = { - filesystem = { - follow_current_file = { enabled = false }, - commands = { - -- over write default 'delete' command to 'trash'. - delete = function(state) - if vim.fn.executable("trash") == 0 then - vim.api.nvim_echo({ - { "- Trash utility not installed. Make sure to install it first\n", nil }, - { "- In macOS run `brew install trash`\n", nil }, - { "- Or delete the `custom delete command` section in neo-tree", nil }, - }, false, {}) - return - end - local inputs = require("neo-tree.ui.inputs") - local path = state.tree:get_node().path - local msg = "Are you sure you want to trash " .. path - inputs.confirm(msg, function(confirmed) - if not confirmed then - return - end - - vim.fn.system({ "trash", vim.fn.fnameescape(path) }) - require("neo-tree.sources.manager").refresh(state.name) - end) - end, - -- Overwrite default 'delete_visual' command to 'trash' x n. - delete_visual = function(state, selected_nodes) - if vim.fn.executable("trash") == 0 then - vim.api.nvim_echo({ - { "- Trash utility not installed. Make sure to install it first\n", nil }, - { "- In macOS run `brew install trash`\n", nil }, - { "- Or delete the `custom delete command` section in neo-tree", nil }, - }, false, {}) - return - end - local inputs = require("neo-tree.ui.inputs") - - -- Function to get the count of items in a table - local function GetTableLen(tbl) - local len = 0 - for _ in pairs(tbl) do - len = len + 1 - end - return len - end - - local count = GetTableLen(selected_nodes) - local msg = "Are you sure you want to trash " .. count .. " files?" - inputs.confirm(msg, function(confirmed) - if not confirmed then - return - end - for _, node in ipairs(selected_nodes) do - vim.fn.system({ "trash", vim.fn.fnameescape(node.path) }) - end - require("neo-tree.sources.manager").refresh(state.name) - end) - end, - }, - }, - }, - keys = { - { "<leader>e", false }, - { "<leader>E", false }, - { - "<leader>en", - function() - local buf_name = vim.api.nvim_buf_get_name(0) - -- Function to check if NeoTree is open in any window - local function is_neo_tree_open() - for _, win in ipairs(vim.api.nvim_list_wins()) do - local buf = vim.api.nvim_win_get_buf(win) - if vim.bo[buf].filetype == "neo-tree" then - return true - end - end - return false - end - -- Check if the current file exists - if - vim.fn.filereadable(buf_name) == 1 - or vim.fn.isdirectory(vim.fn.fnamemodify(buf_name, ":p:h")) == 1 - then - if is_neo_tree_open() then - -- Close NeoTree if it's open - vim.cmd("Neotree close") - else - -- Open NeoTree and reveal the current file - vim.cmd("Neotree reveal") - end - else - -- If the file doesn't exist, execute the logic for <leader>R - require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) - end - end, - desc = "Open neo-tree", - }, - { - "<leader>eN", - function() - require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) - end, - desc = "Open neo-tree (cwd)", - }, - }, - }, + -- { + -- "nvim-neo-tree/neo-tree.nvim", + -- branch = "v3.x", + -- dependencies = { + -- "nvim-lua/plenary.nvim", + -- "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + -- "MunifTanjim/nui.nvim", + -- { + -- "s1n7ax/nvim-window-picker", -- for open_with_window_picker keymaps + -- version = "2.*", + -- config = function() + -- require("window-picker").setup({ + -- filter_rules = { + -- include_current_win = false, + -- autoselect_one = true, + -- -- filter using buffer options + -- bo = { + -- -- if the file type is one of following, the window will be ignored + -- filetype = { "neo-tree", "neo-tree-popup", "notify" }, + -- -- if the buffer type is one of following, the window will be ignored + -- buftype = { "terminal", "quickfix" }, + -- }, + -- }, + -- }) + -- end, + -- }, + -- { "3rd/image.nvim", opts = {} }, -- Optional image support in preview window: See `# Preview Mode` for more information + -- }, + -- lazy = false, -- neo-tree will lazily load itself + -- ---@module "neo-tree" + -- ---@type neotree.Config? + -- opts = { + -- hijack_netrw_behavior = "disabled", -- netrw disabled, opening a directory opens neo-tree + -- filesystem = { + -- follow_current_file = { enabled = false }, + -- commands = { + -- -- over write default 'delete' command to 'trash'. + -- delete = function(state) + -- if vim.fn.executable("trash") == 0 then + -- vim.api.nvim_echo({ + -- { "- Trash utility not installed. Make sure to install it first\n", nil }, + -- { "- In macOS run `brew install trash`\n", nil }, + -- { "- Or delete the `custom delete command` section in neo-tree", nil }, + -- }, false, {}) + -- return + -- end + -- local inputs = require("neo-tree.ui.inputs") + -- local path = state.tree:get_node().path + -- local msg = "Are you sure you want to trash " .. path + -- inputs.confirm(msg, function(confirmed) + -- if not confirmed then + -- return + -- end + -- + -- vim.fn.system({ "trash", vim.fn.fnameescape(path) }) + -- require("neo-tree.sources.manager").refresh(state.name) + -- end) + -- end, + -- -- Overwrite default 'delete_visual' command to 'trash' x n. + -- delete_visual = function(state, selected_nodes) + -- if vim.fn.executable("trash") == 0 then + -- vim.api.nvim_echo({ + -- { "- Trash utility not installed. Make sure to install it first\n", nil }, + -- { "- In macOS run `brew install trash`\n", nil }, + -- { "- Or delete the `custom delete command` section in neo-tree", nil }, + -- }, false, {}) + -- return + -- end + -- local inputs = require("neo-tree.ui.inputs") + -- + -- -- Function to get the count of items in a table + -- local function GetTableLen(tbl) + -- local len = 0 + -- for _ in pairs(tbl) do + -- len = len + 1 + -- end + -- return len + -- end + -- + -- local count = GetTableLen(selected_nodes) + -- local msg = "Are you sure you want to trash " .. count .. " files?" + -- inputs.confirm(msg, function(confirmed) + -- if not confirmed then + -- return + -- end + -- for _, node in ipairs(selected_nodes) do + -- vim.fn.system({ "trash", vim.fn.fnameescape(node.path) }) + -- end + -- require("neo-tree.sources.manager").refresh(state.name) + -- end) + -- end, + -- }, + -- }, + -- }, + -- keys = { + -- { "<leader>e", false }, + -- { "<leader>E", false }, + -- { + -- "<leader>en", + -- function() + -- local buf_name = vim.api.nvim_buf_get_name(0) + -- -- Function to check if NeoTree is open in any window + -- local function is_neo_tree_open() + -- for _, win in ipairs(vim.api.nvim_list_wins()) do + -- local buf = vim.api.nvim_win_get_buf(win) + -- if vim.bo[buf].filetype == "neo-tree" then + -- return true + -- end + -- end + -- return false + -- end + -- -- Check if the current file exists + -- if + -- vim.fn.filereadable(buf_name) == 1 + -- or vim.fn.isdirectory(vim.fn.fnamemodify(buf_name, ":p:h")) == 1 + -- then + -- if is_neo_tree_open() then + -- -- Close NeoTree if it's open + -- vim.cmd("Neotree close") + -- else + -- -- Open NeoTree and reveal the current file + -- vim.cmd("Neotree reveal") + -- end + -- else + -- -- If the file doesn't exist, execute the logic for <leader>R + -- require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) + -- end + -- end, + -- desc = "Open neo-tree", + -- }, + -- { + -- "<leader>eN", + -- function() + -- require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) + -- end, + -- desc = "Open neo-tree (cwd)", + -- }, + -- }, + -- }, } diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/urlview.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/urlview.lua index 00d04b5..907a58e 100644 --- a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/urlview.lua +++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/urlview.lua @@ -78,13 +78,21 @@ return { end local actions = require("urlview.actions") - actions["firefox_tmux"] = function(url) - vim.fn.jobstart({ - "firefox", - "--profile", - vim.fn.expand("~/.mozilla/firefox/si.tmux"), - url, - }, { detach = true }) + actions["browser_tmux"] = function(url) + local browser = vim.env.BROWSER or "firefox" + local cmd = { "setsid", "-f", browser } + + if browser:match("firefox") then + table.insert(cmd, "--profile") + table.insert(cmd, vim.fn.expand("~/.mozilla/firefox/si.tmux")) + elseif browser:match("librewolf") then + table.insert(cmd, "--profile") + table.insert(cmd, vim.fn.expand("~/.librewolf/si.tmux")) + end + + table.insert(cmd, url) + + vim.fn.jobstart(cmd, { detach = true }) end -- Load urlview |
