From 5f8553132579520c33ec940cb8e56c752c58e272 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Thu, 7 Apr 2022 10:22:47 -0500 Subject: fix: neovim config bugfixes --- git/.gitconfig | 4 +- nvim/.config/nvim/lua/mappings.lua | 70 +++- nvim/.config/nvim/lua/plugins.lua | 527 +++++++++++++++------------- nvim/.config/nvim/lua/plugins/neo-tree.lua | 73 ++++ nvim/.config/nvim/lua/plugins/null-ls.lua | 47 +-- nvim/.config/nvim/lua/plugins/which-key.lua | 2 +- tmux/.config/tmux/tmux.conf | 3 +- tmux/.local/bin/tmux-sessionizer | 22 +- 8 files changed, 447 insertions(+), 301 deletions(-) create mode 100644 nvim/.config/nvim/lua/plugins/neo-tree.lua diff --git a/git/.gitconfig b/git/.gitconfig index c232be3..4a7db61 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -23,9 +23,9 @@ prune = true detachedHead = false [diff] -tool = default-difftool +tool = vscode -[difftool "default-difftool"] +[difftool "vscode"] cmd = code --wait --diff $LOCAL $REMOTE [trailer] diff --git a/nvim/.config/nvim/lua/mappings.lua b/nvim/.config/nvim/lua/mappings.lua index 3b6c7d5..0a21f77 100644 --- a/nvim/.config/nvim/lua/mappings.lua +++ b/nvim/.config/nvim/lua/mappings.lua @@ -13,7 +13,7 @@ local opts = { local mappings = { -- Ctrl maps [""] = { "w!", "Save" }, - [""] = { "NvimTreeToggle", "Explorer" }, + [""] = { "Neotree focus toggle", "Explorer" }, } local nopts = { @@ -112,6 +112,7 @@ local nmappings = { p = { name = "Packer", c = { "PackerCompile", "Compile" }, + C = { "PackerClean", "Clean" }, i = { "PackerInstall", "Install" }, s = { "PackerSync", "Sync" }, S = { "PackerStatus", "Status" }, @@ -180,14 +181,77 @@ local vopts = { local vmappings = { -- Ctrl maps [""] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, - + -- Prefix "" [""] = { ["/"] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, - } + }, +} + +local iopts = { + mode = "i", -- INSERT mode + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local imappings = { + -- Ctrl maps + [""] = { "", "Left" }, + [""] = { "", "Up" }, + [""] = { "", "Down" }, + [""] = { "", "Right" }, } which_key.register(mappings, opts) which_key.register(nmappings, nopts) which_key.register(vmappings, vopts) +which_key.register(imappings, iopts) + +function WhichKeyNeoTree(bufNumber) + local status_ok, which_key = pcall(require, "which-key") + if not status_ok then + return + end + + vim.g.maplocalleader = " " + vim.g.mapleader = "" + + local nopts = { + mode = "n", + buffer = vim.api.nvim_get_current_buf(), + silent = true, + noremap = true, + nowait = true, + } + + local nmappings = { + ["<2-LeftMouse>"] = { " lua require('neo-tree').open()", "Open" }, + [""] = { " lua require('neo-tree').open()", "Open" }, + [""] = { + S = { " lua require('neo-tree').open_split()", "HSplit" }, + s = { " lua require('neo-tree').open_vsplit()", "VSplit" }, + t = { " lua require('neo-tree').open_tabnew()", "New Tab" }, + C = { " lua require('neo-tree').close_node()", "Collapse" }, + z = { " lua require('neo-tree').close_all_nodes()", "Collapse All" }, + R = { " lua require('neo-tree').refresh()", "Refresh" }, + a = { " lua require('neo-tree').add()", "Add" }, + A = { " lua require('neo-tree').add_directory()", "Add Dir" }, + d = { " lua require('neo-tree').delete()", "Delete" }, + r = { " lua require('neo-tree').rename()", "Rename" }, + y = { " lua require('neo-tree').copy_to_clipboard()", "Copy" }, + x = { " lua require('neo-tree').cut_to_clipboard()", "Cut" }, + p = { " lua require('neo-tree').paste_from_clipboard()", "Paste" }, + c = { " lua require('neo-tree').copy()", "Copy To" }, + m = { " lua require('neo-tree').move()", "Move To" }, + q = { " lua require('neo-tree').close_window()", "Close" }, + }, + } + which_key.register(nmappings, nopts) +end + +local bufNo = vim.api.nvim_get_current_buf() + +vim.cmd("autocmd FileType neo-tree lua WhichKeyNeoTree(" .. bufNo .. ")") diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index efd0834..2de99be 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,272 +1,297 @@ local fn = vim.fn -- Automatically install packer -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - print "Installing packer close and reopen Neovim..." - vim.cmd [[packadd packer.nvim]] + packer_bootstrap = fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + print("Installing packer close and reopen Neovim...") + vim.cmd([[packadd packer.nvim]]) end -- Autocommand that reloads neovim whenever you save the plugins.lua file -vim.cmd [[ +vim.cmd([[ augroup packer_user_config autocmd! autocmd BufWritePost plugins.lua source | PackerSync augroup end -]] +]]) -- Use a protected call so we don't error out on first use local status_ok, packer = pcall(require, "packer") if not status_ok then - return + return end -- Have packer use a popup window -packer.init { - display = { - open_fn = function() - return require("packer.util").float { border = "rounded" } - end, - }, -} +packer.init({ + display = { + open_fn = function() + return require("packer.util").float({ border = "rounded" }) + end, + }, +}) -- Install your plugins here -return packer.startup(function(use) - -- My plugins here - - -- Have packer manage itself - - use "wbthomason/packer.nvim" - - use { - 'dstein64/vim-startuptime', - cmd = 'StartupTime', - config = [[vim.g.startuptime_tries = 3]] - } - - use 'lewis6991/impatient.nvim' - use 'andweeb/presence.nvim' - use 'Mofiqul/vscode.nvim' -- vscode theme - - use { - 'tpope/vim-dispatch', - cmd = { - 'Dispatch', - 'Make', - 'Focus', - 'Start' - } - } - - use { - 'neovim/nvim-lspconfig', - config = [[require('plugins/lspconfig')]] - } - - use { - "williamboman/nvim-lsp-installer", - config = [[require('plugins/lsp-installer')]] - } - - use 'nvim-lua/lsp_extensions.nvim' - use 'simrat39/rust-tools.nvim' - use 'simrat39/symbols-outline.nvim' - - use { - "folke/trouble.nvim", - cmd = "TroubleToggle" - } - - use { - 'hrsh7th/nvim-cmp', - requires = { - { "onsails/lspkind-nvim", config = [[require('plugins/lspkind')]] }, -- vscode-like pictograms for cmp - 'ray-x/lsp_signature.nvim', - 'hrsh7th/cmp-nvim-lsp', -- nvim-cmp source for neovim builtin LSP client - 'hrsh7th/cmp-nvim-lua', -- nvim-cmp source for nvim lua - 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words. - 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths. - 'hrsh7th/cmp-calc', -- nvim-cmp source for math calculation. - 'saadparwaiz1/cmp_luasnip', -- luasnip completion source for nvim-cmp - 'hrsh7th/cmp-nvim-lsp-signature-help', -- luasnip completion source for lsp_signature - }, - config = [[require('plugins/cmp')]], - } - - use { - 'nvim-telescope/telescope.nvim', - requires = { - 'nvim-lua/plenary.nvim', - 'BurntSushi/ripgrep', - 'nvim-telescope/telescope-dap.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, - { "nvim-telescope/telescope-frecency.nvim", requires = "tami5/sqlite.lua" }, - }, - config = [[require('plugins/telescope')]], - } - - use { - "jose-elias-alvarez/null-ls.nvim", - requires = "nvim-lua/plenary.nvim", - config = [[require('plugins/null-ls')]] - } - - use { - "L3MON4D3/LuaSnip", - requires = "rafamadriz/friendly-snippets", - config = [[require('plugins/luasnip')]] - } - - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - requires = { - 'nvim-treesitter/nvim-treesitter-refactor', - 'RRethy/nvim-treesitter-textsubjects', - }, - config = [[require('plugins/treesitter')]] - } - - use { - "lukas-reineke/indent-blankline.nvim", - config = [[require('plugins/blankline')]] - } - - use "tpope/vim-eunuch" - - use { - "nvim-lualine/lualine.nvim", - requires = { - { "kyazdani42/nvim-web-devicons" }, - }, - config = [[require('plugins/lualine')]] - } - - use { - 'tpope/vim-fugitive', - cmd = { - 'Git', - 'Gstatus', - 'Gblame', - 'Gpush', - 'Gpull' - }, - disable = true - } - - use { - 'lewis6991/gitsigns.nvim', - requires = 'nvim-lua/plenary.nvim', - config = [[require('plugins/gitsigns')]], - } - - use { - 'TimUntersberger/neogit', - cmd = 'Neogit', - config = [[require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}]] - } - - use 'kdheepak/lazygit.nvim' - - use { - "f-person/git-blame.nvim", - config = [[require('plugins/git-blame')]] - } - - use { - 'mbbill/undotree', - cmd = 'UndotreeToggle', - config = [[vim.g.undotree_SetFocusWhenToggle = 1]], - } - - use { - "ThePrimeagen/git-worktree.nvim", - config = [[require('plugins/git-worktree')]] - } - - use { - 'ThePrimeagen/refactoring.nvim', - opt = true - } - - use { - "ahmedkhalf/project.nvim", - config = [[require('plugins/project')]] - } - - use { - "folke/which-key.nvim", - config = [[require('plugins/which-key')]] - } - - use { - 'mfussenegger/nvim-dap', - requires = { - "theHamsta/nvim-dap-virtual-text", - "rcarriga/nvim-dap-ui", - "Pocco81/DAPInstall.nvim", - }, - config = [[require('plugins/dap')]], - } - - use 'rcarriga/nvim-notify' - use "antoinemadec/FixCursorHold.nvim" - use "nacro90/numb.nvim" - use "Shatur/neovim-session-manager" - use 'ThePrimeagen/harpoon' - use "b0o/SchemaStore.nvim" - use 'windwp/nvim-spectre' - - use { - 'goolord/alpha-nvim', - config = [[require('plugins/alpha')]] - } - - use { - "filipdutescu/renamer.nvim", - config = [[require('plugins/renamer')]] - } - - use { - 'numToStr/Comment.nvim', - config = [[require('Comment').setup()]] - } - - use { - 'norcalli/nvim-colorizer.lua', - ft = { - 'css', - 'javascript', - 'vim', - 'html' - }, - config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], - } - - use { - 'akinsho/nvim-bufferline.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = [[require('plugins/bufferline')]], - } - - use "moll/vim-bbye" - use 'SmiteshP/nvim-gps' - - use { - "kyazdani42/nvim-tree.lua", - requires = { - { - 'yamatsum/nvim-nonicons', - requires = 'kyazdani42/nvim-web-devicons' - }, - }, - config = [[require('plugins/nvim-tree')]] - } - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if packer_bootstrap then - require('packer').sync() - end +return packer.startup(function(use) + -- My plugins here + + -- Have packer manage itself + + use("wbthomason/packer.nvim") + + use({ + "dstein64/vim-startuptime", + cmd = "StartupTime", + config = [[vim.g.startuptime_tries = 3]], + }) + + use("lewis6991/impatient.nvim") + use("andweeb/presence.nvim") + use("Mofiqul/vscode.nvim") -- vscode theme + + use({ + "rmagatti/auto-session", + config = [[require('auto-session').setup()]], + }) + + use({ + "tpope/vim-dispatch", + cmd = { + "Dispatch", + "Make", + "Focus", + "Start", + }, + }) + + use({ + "neovim/nvim-lspconfig", + config = [[require('plugins/lspconfig')]], + }) + + use({ + "williamboman/nvim-lsp-installer", + config = [[require('plugins/lsp-installer')]], + }) + + use("nvim-lua/lsp_extensions.nvim") + use("simrat39/rust-tools.nvim") + use("simrat39/symbols-outline.nvim") + + use({ + "folke/trouble.nvim", + cmd = "TroubleToggle", + }) + + use({ + "hrsh7th/nvim-cmp", + requires = { + { "onsails/lspkind-nvim", config = [[require('plugins/lspkind')]] }, -- vscode-like pictograms for cmp + "ray-x/lsp_signature.nvim", + "hrsh7th/cmp-nvim-lsp", -- nvim-cmp source for neovim builtin LSP client + "hrsh7th/cmp-nvim-lua", -- nvim-cmp source for nvim lua + "hrsh7th/cmp-buffer", -- nvim-cmp source for buffer words. + "hrsh7th/cmp-path", -- nvim-cmp source for filesystem paths. + "hrsh7th/cmp-calc", -- nvim-cmp source for math calculation. + "saadparwaiz1/cmp_luasnip", -- luasnip completion source for nvim-cmp + "hrsh7th/cmp-nvim-lsp-signature-help", -- luasnip completion source for lsp_signature + }, + config = [[require('plugins/cmp')]], + }) + + use({ + "nvim-telescope/telescope.nvim", + requires = { + "nvim-lua/plenary.nvim", + "BurntSushi/ripgrep", + "nvim-telescope/telescope-dap.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, + { "nvim-telescope/telescope-frecency.nvim", requires = "tami5/sqlite.lua" }, + }, + config = [[require('plugins/telescope')]], + }) + + use({ + "jose-elias-alvarez/null-ls.nvim", + requires = "nvim-lua/plenary.nvim", + config = [[require('plugins/null-ls')]], + }) + + use({ + "L3MON4D3/LuaSnip", + requires = "rafamadriz/friendly-snippets", + config = [[require('plugins/luasnip')]], + }) + + use({ + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + requires = { + "nvim-treesitter/nvim-treesitter-refactor", + "RRethy/nvim-treesitter-textsubjects", + }, + config = [[require('plugins/treesitter')]], + }) + + use({ + "lukas-reineke/indent-blankline.nvim", + config = [[require('plugins/blankline')]], + }) + + use("tpope/vim-eunuch") + + use({ + "nvim-lualine/lualine.nvim", + requires = { + { "kyazdani42/nvim-web-devicons" }, + }, + config = [[require('plugins/lualine')]], + }) + + use({ + "tpope/vim-fugitive", + cmd = { + "Git", + "Gstatus", + "Gblame", + "Gpush", + "Gpull", + }, + disable = true, + }) + + use({ + "lewis6991/gitsigns.nvim", + requires = "nvim-lua/plenary.nvim", + config = [[require('plugins/gitsigns')]], + }) + + use({ + "TimUntersberger/neogit", + cmd = "Neogit", + config = [[require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}]], + }) + + use("kdheepak/lazygit.nvim") + + use({ + "f-person/git-blame.nvim", + config = [[require('plugins/git-blame')]], + }) + + use({ + "mbbill/undotree", + cmd = "UndotreeToggle", + config = [[vim.g.undotree_SetFocusWhenToggle = 1]], + }) + + use({ + "ThePrimeagen/git-worktree.nvim", + config = [[require('plugins/git-worktree')]], + }) + + use({ + "ThePrimeagen/refactoring.nvim", + opt = true, + }) + + use({ + "ahmedkhalf/project.nvim", + config = [[require('plugins/project')]], + }) + + use({ + "folke/which-key.nvim", + config = [[require('plugins/which-key')]], + }) + + use({ + "mfussenegger/nvim-dap", + requires = { + "theHamsta/nvim-dap-virtual-text", + "rcarriga/nvim-dap-ui", + "Pocco81/DAPInstall.nvim", + }, + config = [[require('plugins/dap')]], + }) + + use("rcarriga/nvim-notify") + use("antoinemadec/FixCursorHold.nvim") + use("nacro90/numb.nvim") + use("Shatur/neovim-session-manager") + use("ThePrimeagen/harpoon") + use("b0o/SchemaStore.nvim") + use("windwp/nvim-spectre") + + use({ + "goolord/alpha-nvim", + config = [[require('plugins/alpha')]], + }) + + use({ + "filipdutescu/renamer.nvim", + config = [[require('plugins/renamer')]], + }) + + use("ur4ltz/surround.nvim") + + use({ + "numToStr/Comment.nvim", + config = [[require('Comment').setup()]], + }) + + use({ + "norcalli/nvim-colorizer.lua", + ft = { + "css", + "javascript", + "vim", + "html", + }, + config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], + }) + + use({ + "akinsho/nvim-bufferline.lua", + requires = "kyazdani42/nvim-web-devicons", + config = [[require('plugins/bufferline')]], + }) + + use("moll/vim-bbye") + use("SmiteshP/nvim-gps") + + use({ + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + requires = { + "nvim-lua/plenary.nvim", + "kyazdani42/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = [[require('plugins/neo-tree')]], + }) + + -- use({ + -- "kyazdani42/nvim-tree.lua", + -- requires = { + -- { + -- "yamatsum/nvim-nonicons", + -- requires = "kyazdani42/nvim-web-devicons", + -- }, + -- }, + -- config = [[require('plugins/nvim-tree')]], + -- }) + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require("packer").sync() + end end) diff --git a/nvim/.config/nvim/lua/plugins/neo-tree.lua b/nvim/.config/nvim/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..37512d9 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/neo-tree.lua @@ -0,0 +1,73 @@ +local status_ok, neo_tree = pcall(require, "neo-tree") +if not status_ok then + return +end + +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" }) +vim.fn.sign_define("DiagnosticSignWarn", { text = " ", texthl = "DiagnosticSignWarn" }) +vim.fn.sign_define("DiagnosticSignInfo", { text = " ", texthl = "DiagnosticSignInfo" }) +vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) + +neo_tree.setup({ + close_if_last_window = true, + window = { + mappings = { + [""] = "none", + ["<2-LeftMouse>"] = "none", + [""] = "none", + ["S"] = "none", + ["s"] = "none", + ["t"] = "none", + ["C"] = "none", + ["a"] = "none", + ["A"] = "none", + ["d"] = "none", + ["r"] = "none", + ["y"] = "none", + ["x"] = "none", + ["p"] = "none", + ["c"] = "none", + ["m"] = "none", + ["q"] = "none", + ["R"] = "none", + }, + }, + filesystem = { + filtered_items = { + hide_dotfiles = false, + }, + use_libuv_file_watcher = true, + window = { + mappings = { + [""] = "none", + ["."] = "none", + ["H"] = "none", + ["/"] = "none", + ["f"] = "none", + [""] = "none", + }, + }, + }, + buffers = { + mappings = { + ["bd"] = "none", + [""] = "none", + ["."] = "none", + }, + }, + git_status = { + window = { + mappings = { + ["A"] = "none", + ["gu"] = "none", + ["ga"] = "none", + ["gr"] = "none", + ["gc"] = "none", + ["gp"] = "none", + ["gg"] = "none", + }, + }, + }, +}) diff --git a/nvim/.config/nvim/lua/plugins/null-ls.lua b/nvim/.config/nvim/lua/plugins/null-ls.lua index e3aa45f..5cbaa21 100644 --- a/nvim/.config/nvim/lua/plugins/null-ls.lua +++ b/nvim/.config/nvim/lua/plugins/null-ls.lua @@ -8,40 +8,23 @@ local diagnostics = null_ls.builtins.diagnostics local formatting = null_ls.builtins.formatting null_ls.setup({ - sources = { - -- Code Actions - code_actions.gitsigns, - -- code_actions.shellcheck, + sources = { + -- Code Actions + code_actions.gitsigns, + code_actions.shellcheck, - -- Diagnostics - -- diagnostics.codespell, + -- Diagnostics + -- diagnostics.codespell, -- diagnostics.luacheck, -- diagnostics.markdownlint, - -- diagnostics.shellcheck, + diagnostics.shellcheck, - -- Formatting - formatting.prettier, - formatting.black, - formatting.latexindent, - formatting.markdownlint, - formatting.stylua, - formatting.rustfmt.with({ - extra_args = function(params) - local Path = require("plenary.path") - local cargo_toml = Path:new(params.root .. "/" .. "Cargo.toml") - - if cargo_toml:exists() and cargo_toml:is_file() then - for _, line in ipairs(cargo_toml:readlines()) do - local edition = line:match([[^edition%s*=%s*%"(%d+)%"]]) - if edition then - return { "--edition=" .. edition } - end - end - end - -- default edition when we don't find `Cargo.toml` or the `edition` in it. - return { "--edition=2021" } - end, - }), - formatting.shfmt, - }, + -- Formatting + formatting.prettier, + formatting.black, + formatting.latexindent, + formatting.markdownlint, + formatting.stylua, + formatting.shfmt, + }, }) diff --git a/nvim/.config/nvim/lua/plugins/which-key.lua b/nvim/.config/nvim/lua/plugins/which-key.lua index b30fd4d..0886853 100644 --- a/nvim/.config/nvim/lua/plugins/which-key.lua +++ b/nvim/.config/nvim/lua/plugins/which-key.lua @@ -31,4 +31,4 @@ local opts = { nowait = true, -- use `nowait` when creating keymaps } -which_key.setup(setup) \ No newline at end of file +which_key.setup(setup) diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 604d2e3..204382e 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -5,7 +5,8 @@ set -ga terminal-overrides ",alacritty:Tc" set -g detach-on-destroy off set -g prefix C-a -bind-key f run-shell "tmux neww -n sessionizer ~/.local/bin/tmux-sessionizer" +bind-key f run-shell ~/.local/bin/tmux-sessionizer +bind-key e new-window -Sn nvim nvim set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer index f43cea3..522441c 100755 --- a/tmux/.local/bin/tmux-sessionizer +++ b/tmux/.local/bin/tmux-sessionizer @@ -1,26 +1,26 @@ #!/usr/bin/env bash -if [[ $# -eq 1 ]]; then - selected=$1 +if [ "$#" -eq 1 ]; then + selected="$1" else - selected=$(cat <(fd . ~/src ~/dkr --exact-depth 1 -td) <(echo $HOME/.dotfiles) | sort | - fzf -d/ --with-nth 3.. --preview="tree -a -C -L 1 {}") + selected=$(find ~/src ~/.dotfiles -maxdepth 2 -type d -path '*/.git' -printf '%h\n' -prune | sort | + fzf-tmux -p -- -d/ --with-nth 3.. --preview="exa --tree --icons --git-ignore {}") fi -if [[ -z $selected ]]; then - exit 0 +if [ -z "$selected" ]; then + exit 0 fi selected_name=$(basename "$selected" | tr . _) tmux_running=$(pgrep tmux) if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then - tmux new-session -s $selected_name -c $selected - exit 0 + tmux new-session -s "$selected_name" -c "$selected" + exit 0 fi -if ! tmux has-session -t=$selected_name 2>/dev/null; then - tmux new-session -ds $selected_name -c $selected +if ! tmux has-session -t="$selected_name" 2>/dev/null; then + tmux new-session -ds "$selected_name" -c "$selected" fi -tmux switch-client -t $selected_name +tmux switch-client -t "$selected_name" -- cgit v1.2.3-70-g09d2