#!/usr/bin/env bash # a collection of addition plugins for neovim with lazy DEST=${1:-/etc/skel} LAZY_DEST=${DEST}/.config/nvim/lua/plugins # conf-print() { # cat <<-EOF # # EOF # } # conf_print > ${DEST} # nvim-dap Debug Adapter Protocol client # https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ # nvim-dap-python An extension for nvim-dap for python debug, test methods or classes. conf_print_nvim-dap() { cat <<-EOF return { { "mfussenegger/nvim-dap", optional = true, dependencies = { "mfussenegger/nvim-dap-python", keys = { { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" }, { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, }, config = function() local path = require("mason-registry").get_package("debugpy"):get_install_path() require("dap-python").setup(path .. "/venv/bin/python") end, }, } } EOF } conf_print_nvim-dap >"${LAZY_DEST}/nvim-dap-python.lua" # https://github.com/folke/lazy.nvim conf-print-nvim-lazygit() { cat <<-EOF require("lazy").setup({ { "kdheepak/lazygit.nvim", cmd = { "LazyGit", "LazyGitConfig", "LazyGitCurrentFile", "LazyGitFilter", "LazyGitFilterCurrentFile", }, -- optional for floating window border decoration dependencies = { "nvim-lua/plenary.nvim", }, -- setting the keybinding for LazyGit with 'keys' is recommended in -- order to load the plugin when the command is run for the first time keys = { { "lg", "LazyGit", desc = "LazyGit" } } }, }) EOF conf_print_nvim-lazygit >"${LAZY_DEST}/nvim-lazygit.lua" # FIXME: Not sure where we put these settingsm assuming nvim.conf conf_print_nvim-lazygit_map() { cat <<-EOF let g:lazygit_floating_window_winblend = 0 " transparency of floating window let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window let g:lazygit_floating_window_border_chars = ['╭','─', '╮', '│', '╯','─', '╰', '│'] " customize lazygit popup window border characters let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available let g:lazygit_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed let g:lazygit_use_custom_config_file_path = 0 " config file path is evaluated if this value is 1 let g:lazygit_config_file_path = '' " custom config file path " OR let g:lazygit_config_file_path = [] " list of custom config file paths " setup mapping to call :LazyGit nnoremap gg :LazyGit EOF } # conf_print_nvim-lazygit_map > "${LAZY_DEST}"/ # https://sw.kovidgoyal.net/kitty/overview/ # https://github.com/mikesmithgh/kitty-scrollback.nvim/wiki/kitty_scrollback_nvim # https://github.com/mikesmithgh/kitty-scrollback.nvim?tab=readme-ov-file#-installation conf_print_nvim-kitty-scrollback() { cat <<-EOF { 'mikesmithgh/kitty-scrollback.nvim', enabled = true, lazy = true, cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth' }, event = { 'User KittyScrollbackLaunch' }, -- version = '*', -- latest stable version, may have breaking changes if major version changed -- version = '^4.0.0', -- pin major version, include fixes and features that do not have breaking changes config = function() require('kitty-scrollback').setup() end, } EOF } conf_print_nvim-kitty-scrollback >"${LAZY_DEST}/nvim-kitty-scrollback.lua" # https://github.com/rcarriga/nvim-dap-ui conf_print_nvim-dap-ui() { cat <<-EOF { "rcarriga/nvim-dap-ui", dependencies = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"} } EOF } # the command 'Codeium Chat' will start a chat session with the default browser # the indexing seems not to work but it is new 02-04-2024 conf_print_nvim-codeium_enable-chat() { cat <<-EOF -- ~/.config/nvim/lua/plugins/nvim-codeium_enable-chat.lua -- Assuming you want to configure the codeium plugin return { "Exafunction/codeium.nvim", config = function() -- Require the codeium module local codeium = require("codeium.config") -- Modify the options to enable chat, local search, and index service codeium.options = { enable_chat = true, enable_local_search = true, enable_index_service = true, } -- Call the setup function with the modified options codeium.setup(codeium.options) end, } EOF } conf_print_nvim-codeium_enable-chat >"${LAZY_DEST}/nvim-codeium_enable-chat.lua" # the key for codeium sometimes gets wiped, put it back CODEIUM_KEY_HOME=/home/default/.cache/nvim/codeium/config.json conf_print_nvim-codeium-key() { cat <<-EOF {"api_key": "c8cbca7c-fabb-42bb-95e2-1c86fe71bd45"} EOF } conf_print_nvim-codeium-key >"${CODEIUM_KEY_HOME}" # an example of allowing fix on save conf_print_nvim-lint-markdownlint() { cat <<-EOF return { { "mfussenegger/nvim-lint", opts = { linters = { markdownlint = { args = { "--fix" }, }, }, }, }, } EOF } # conf_print_nvim-lint-markdownlint >"${LAZY_DEST}"/nvim-lint-markdownlint.lua # Turn off .vscode import in neoconf # neoconf settings are found in ~/.config/nvim/neoconf.json # defaults are in lua/neoconf/config.lua conf_print_neoconf_json() { cat < ~/.config/nvim/neoconf.json.tmp mv ~/.config/nvim/neoconf.json.tmp ~/.config/nvim/neoconf.json else # If the file does not exist, create it with the new JSON snippet conf_print_neoconf_json > ~/.config/nvim/neoconf.json fi #============================================================================== # vim-tmux-navigator.lua within the plugins folder of Lazyvim: conf_print_tmux_navigator() { cat <", "TmuxNavigatePrevious", desc = "Go to the previous pane" }, { "", "TmuxNavigateLeft", desc = "Got to the left pane" }, { "", "TmuxNavigateDown", desc = "Got to the down pane" }, { "", "TmuxNavigateUp", desc = "Got to the up pane" }, { "", "TmuxNavigateRight", desc = "Got to the right pane" }, }, } EOF } conf_print_tmux_navigator | tee "${LAZY_DEST}/ns/vim-tmux-navigator.lua" #============================================================================== # Example with keymap override. # LazyVim overrides the keymaps, so only adding the keymaps in the # plugin folder did not work and I had to explicitly add the keymaps outside the # plugins in keymaps.lua. # (e.g vim.keymap.set("n", "", ":TmuxNavigateDown", { silent = true })) conf_print_nvim-tmux() { cat <", "NvimTmuxNavigateLeft", { silent = true }) vim.keymap.set("n", "", "NvimTmuxNavigateDown", { silent = true }) vim.keymap.set("n", "", "NvimTmuxNavigateUp", { silent = true }) vim.keymap.set("n", "", "NvimTmuxNavigateRight", { silent = true }) vim.keymap.set("n", "", "NvimTmuxNavigateLastActive", { silent = true }) vim.keymap.set("n", "", "NvimTmuxNavigateNavigateNext", { silent = true }) EOF } conf_print_nvim-tmux-keymap | tee -a "${LAZY_DEST}"/.config/nvim/lua/config/keymaps.lua ~/.tmux.conf conf_print_tmux_conf() { cat <= 3.0" | bc)" = 1 ]' \ "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+' bind-key -T copy-mode-vi 'C-h' select-pane -L bind-key -T copy-mode-vi 'C-j' select-pane -D bind-key -T copy-mode-vi 'C-k' select-pane -U bind-key -T copy-mode-vi 'C-l' select-pane -R bind-key -T copy-mode-vi 'C-\' select-pane -l bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+ # END FANCY STUFF <--------- set -g @plugin 'jimeh/tmux-themepack' set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes set -g @themepack 'powerline/default/cyan' set -g @resurrect-capture-pane-contents 'on' set -g @continuum-restore 'on' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm' EOF } # conf_print_tmux_conf | tee ${DEST}/.config/tmux/tmux.conf #============================================================================== # write a lazyvim spec for diffview # do not lazy load, it's a library # https://github.com/sindrets/diffview. # https://github.com/nvim-lua/plenary.nvim # https://github.com/nvim-tree/nvim-web-devicons # return { -- add symbols-outline { "sindrets/diffview.nvim", cmd = "diffview", keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, opts = { -- add your options that should be passed to the setup() function here position = "right", }, }, } require("lazy").setup({ { "sindrets/diffview.nvim", cmd = { 'DiffviewOpen', 'DiffviewFileHistory', 'DiffviewClose', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh' }, dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", }, keys = { { "dv", "DiffviewOpen", desc = "Open Diffview" }, { "df", "DiffviewFileHistory", desc = "Show file history" }, { "dc", "DiffviewClose", desc = "Close Diffview" }, { "dt", "DiffviewToggleFiles", desc = "Toggle file list" }, { "df", "DiffviewFocusFiles", desc = "Focus on file list" }, { "dr", "DiffviewRefresh", desc = "Refresh Diffview" } -- Add other keybindings as needed } config = function() require("config.diffview") end, }, }) use { "sindrets/diffview.nvim", requires = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", }, after = "plenary.nvim", } # packer ui['sindrets/diffview.nvim'] = { config = conf.diffview, requires = { {'nvim-lua/plenary.nvim'}, {'nvim-tree/nvim-web-devicons'}, }. after='plenary.nvim', cmd = { 'DiffviewOpen', 'DiffviewFileHistory', 'DiffviewClose', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh' } } config = function() -- Lua local cb = require'diffview.config'.diffview_callback require'diffview'.setup { diff_binaries = false, -- Show diffs for binaries enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' use_icons = true, -- Requires nvim-web-devicons icons = { -- Only applies when use_icons is true. folder_closed = "", folder_open = "", }, signs = { fold_closed = "", fold_open = "", }, file_panel = { position = "left", -- One of 'left', 'right', 'top', 'bottom' width = 35, -- Only applies when position is 'left' or 'right' height = 10, -- Only applies when position is 'top' or 'bottom' listing_style = "tree", -- One of 'list' or 'tree' tree_options = { -- Only applies when listing_style is 'tree' flatten_dirs = true, -- Flatten dirs that only contain one single dir folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'. }, }, file_history_panel = { position = "bottom", width = 35, height = 16, log_options = { max_count = 256, -- Limit the number of commits follow = false, -- Follow renames (only for single file) all = false, -- Include all refs under 'refs/' including HEAD merges = false, -- List only merge commits no_merges = false, -- List no merge commits reverse = false, -- List commits in reverse order }, }, default_args = { -- Default args prepended to the arg-list for the listed commands DiffviewOpen = {}, DiffviewFileHistory = {}, }, hooks = {}, -- See ':h diffview-config-hooks' key_bindings = { disable_defaults = false, -- Disable the default key bindings -- The `view` bindings are active in the diff buffers, only when the current -- tabpage is a Diffview. view = { [""] = cb("select_next_entry"), -- Open the diff for the next file [""] = cb("select_prev_entry"), -- Open the diff for the previous file ["gf"] = cb("goto_file"), -- Open the file in a new split in previous tabpage [""] = cb("goto_file_split"), -- Open the file in a new split ["gf"] = cb("goto_file_tab"), -- Open the file in a new tabpage ["e"] = cb("focus_files"), -- Bring focus to the files panel ["b"] = cb("toggle_files"), -- Toggle the files panel. }, file_panel = { ["j"] = cb("next_entry"), -- Bring the cursor to the next file entry [""] = cb("next_entry"), ["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry. [""] = cb("prev_entry"), [""] = cb("select_entry"), -- Open the diff for the selected entry. ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), ["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry. ["S"] = cb("stage_all"), -- Stage all entries. ["U"] = cb("unstage_all"), -- Unstage all entries. ["X"] = cb("restore_entry"), -- Restore entry to the state on the left side. ["R"] = cb("refresh_files"), -- Update stats and entries in the file list. [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["i"] = cb("listing_style"), -- Toggle between 'list' and 'tree' views ["f"] = cb("toggle_flatten_dirs"), -- Flatten empty subdirectories in tree listing style. ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, file_history_panel = { ["g!"] = cb("options"), -- Open the option panel [""] = cb("open_in_diffview"), -- Open the entry under the cursor in a diffview ["y"] = cb("copy_hash"), -- Copy the commit hash of the entry under the cursor ["zR"] = cb("open_all_folds"), ["zM"] = cb("close_all_folds"), ["j"] = cb("next_entry"), [""] = cb("next_entry"), ["k"] = cb("prev_entry"), [""] = cb("prev_entry"), [""] = cb("select_entry"), ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, option_panel = { [""] = cb("select"), ["q"] = cb("close"), }, }, } end } #============================================================================== # To combine the Packer configuration for sindrets/diffview.nvim with the # provided Lua configuration for diffview, #============================================================================== use { 'sindrets/diffview.nvim', config = function() -- Lua local cb = require'diffview.config'.diffview_callback require'diffview'.setup { diff_binaries = false, -- Show diffs for binaries enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' use_icons = true, -- Requires nvim-web-devicons icons = { -- Only applies when use_icons is true. folder_closed = "", folder_open = "", }, signs = { fold_closed = "", fold_open = "", }, file_panel = { position = "left", -- One of 'left', 'right', 'top', 'bottom' width = 35, -- Only applies when position is 'left' or 'right' height = 10, -- Only applies when position is 'top' or 'bottom' listing_style = "tree", -- One of 'list' or 'tree' tree_options = { -- Only applies when listing_style is 'tree' flatten_dirs = true, -- Flatten dirs that only contain one single dir folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'. }, }, file_history_panel = { position = "bottom", width = 35, height = 16, log_options = { max_count = 256, -- Limit the number of commits follow = false, -- Follow renames (only for single file) all = false, -- Include all refs under 'refs/' including HEAD merges = false, -- List only merge commits no_merges = false, -- List no merge commits reverse = false, -- List commits in reverse order }, }, default_args = { -- Default args prepended to the arg-list for the listed commands DiffviewOpen = {}, DiffviewFileHistory = {}, }, hooks = {}, -- See ':h diffview-config-hooks' key_bindings = { disable_defaults = false, -- Disable the default key bindings -- The `view` bindings are active in the diff buffers, only when the current -- tabpage is a Diffview. view = { [""] = cb("select_next_entry"), -- Open the diff for the next file [""] = cb("select_prev_entry"), -- Open the diff for the previous file ["gf"] = cb("goto_file"), -- Open the file in a new split in previous tabpage [""] = cb("goto_file_split"), -- Open the file in a new split ["gf"] = cb("goto_file_tab"), -- Open the file in a new tabpage ["e"] = cb("focus_files"), -- Bring focus to the files panel ["b"] = cb("toggle_files"), -- Toggle the files panel. }, file_panel = { ["j"] = cb("next_entry"), -- Bring the cursor to the next file entry [""] = cb("next_entry"), ["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry. [""] = cb("prev_entry"), [""] = cb("select_entry"), -- Open the diff for the selected entry. ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), ["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry. ["S"] = cb("stage_all"), -- Stage all entries. ["U"] = cb("unstage_all"), -- Unstage all entries. ["X"] = cb("restore_entry"), -- Restore entry to the state on the left side. ["R"] = cb("refresh_files"), -- Update stats and entries in the file list. [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["i"] = cb("listing_style"), -- Toggle between 'list' and 'tree' views ["f"] = cb("toggle_flatten_dirs"), -- Flatten empty subdirectories in tree listing style. ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, file_history_panel = { ["g!"] = cb("options"), -- Open the option panel [""] = cb("open_in_diffview"), -- Open the entry under the cursor in a diffview ["y"] = cb("copy_hash"), -- Copy the commit hash of the entry under the cursor ["zR"] = cb("open_all_folds"), ["zM"] = cb("close_all_folds"), ["j"] = cb("next_entry"), [""] = cb("next_entry"), ["k"] = cb("prev_entry"), [""] = cb("prev_entry"), [""] = cb("select_entry"), ["o"] = cb("select_entry"), ["<2-LeftMouse>"] = cb("select_entry"), [""] = cb("select_next_entry"), [""] = cb("select_prev_entry"), ["gf"] = cb("goto_file"), [""] = cb("goto_file_split"), ["gf"] = cb("goto_file_tab"), ["e"] = cb("focus_files"), ["b"] = cb("toggle_files"), }, option_panel = { [""] = cb("select"), ["q"] = cb("close"), }, }, } end, requires = { {'nvim-lua/plenary.nvim'}, {'nvim-tree/nvim-web-devicons'}, }, after='plenary.nvim', cmd = { 'DiffviewOpen', 'DiffviewFileHistory', 'DiffviewClose', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh' } } #============================================================================== local diffview = require('diffview') local custom_diff_view = diffview.CDiffView({ git_toplevel = '/path/to/git/repo', left = 'HEAD', right = 'HEAD~1', files = { working = { {path = 'file1.txt', status = 'M'}, {path = 'file2.txt', status = 'A'}, }, }, }) -- Example command to open the options panel vim.api.nvim_set_keymap('n', 'o', 'DiffviewOpenOptions', {noremap = true, silent = true}) -- Example command to navigate to the next conflict vim.api.nvim_set_keymap('n', 'c', 'DiffviewNextConflict', {noremap = true, silent = true}) -- Example help command vim.api.nvim_set_keymap('n', 'h', 'DiffviewHelp', {noremap = true, silent = true})