From 6cdf9123c04fcea5bfad9f07ac57833e742461da Mon Sep 17 00:00:00 2001 From: Italo Borrelli Date: Sun, 16 Nov 2025 16:37:55 -0800 Subject: [PATCH] Clean up nvim and add new lsp, use vim mode in zsh, reorganize tmux --- .config/nvim/.luarc.jsonc | 25 +- .config/nvim/init.lua | 1 + .config/nvim/lua/config/lazy.lua | 1 + .config/nvim/lua/jdtls/jdtls_setup.lua | 210 +++---- .config/nvim/lua/jdtls/keymaps.lua | 104 ---- .config/nvim/lua/keybindings.lua | 6 +- .../lua/{plugins/util => }/nvim-notify.lua | 0 .../lua/plugins/file_navigation/harpoon.lua | 73 +++ .../lua/plugins/file_navigation/neo-tree.lua | 62 -- .../nvim/lua/plugins/file_navigation/oil.lua | 38 ++ .../lua/plugins/file_navigation/telescope.lua | 37 +- .config/nvim/lua/plugins/git/diffview.lua | 3 + .config/nvim/lua/plugins/git/fugitive.lua | 3 + .../nvim/lua/plugins/{util => git}/neogit.lua | 7 +- .../lua/plugins/language_support/conform.lua | 1 - .../lua/plugins/language_support/gradle.lua | 2 +- .../lua/plugins/language_support/nvim-cmp.lua | 80 ++- .config/nvim/lua/plugins/lsp/mason.lua | 3 +- .../nvim/lua/plugins/lsp/nvim-lspconfig.lua | 61 +- .config/nvim/lua/plugins/theme.lua | 2 +- .config/nvim/lua/plugins/ui/barbar.lua | 61 -- .config/nvim/lua/plugins/ui/dressing.lua | 172 ------ .config/nvim/lua/plugins/ui/snacks.lua | 555 ++++++++++++++++++ .../nvim/lua/plugins/util/auto-session.lua | 14 +- .config/nvim/lua/plugins/util/oil.lua | 15 - .../nvim/lua/plugins/util/todo-comments.lua | 21 +- .config/nvim/lua/plugins/util/undotree.lua | 3 + .config/nvim/lua/plugins/util/util.lua | 14 - .config/nvim/lua/plugins/util/vim-suda.lua | 9 + .config/nvim/lua/plugins/util/which-key.lua | 6 +- .config/nvim/lua/utils.lua | 36 ++ .config/tmux/catppuccin.conf | 35 -- .config/tmux/scripts/cal.sh | 132 +++++ .config/tmux/tmux.conf | 114 ++-- .config/tmux/tmux.keybindings.conf | 52 ++ .config/tmux/tmux.plugins.conf | 73 +++ .config/tmux/tmux.reset.conf | 40 ++ .zinit.zsh | 63 +- .zshrc | 51 +- .zstyle.zsh | 79 +-- 40 files changed, 1397 insertions(+), 867 deletions(-) delete mode 100644 .config/nvim/lua/jdtls/keymaps.lua rename .config/nvim/lua/{plugins/util => }/nvim-notify.lua (100%) create mode 100644 .config/nvim/lua/plugins/file_navigation/harpoon.lua delete mode 100644 .config/nvim/lua/plugins/file_navigation/neo-tree.lua create mode 100644 .config/nvim/lua/plugins/file_navigation/oil.lua create mode 100644 .config/nvim/lua/plugins/git/diffview.lua create mode 100644 .config/nvim/lua/plugins/git/fugitive.lua rename .config/nvim/lua/plugins/{util => git}/neogit.lua (50%) delete mode 100644 .config/nvim/lua/plugins/ui/barbar.lua delete mode 100644 .config/nvim/lua/plugins/ui/dressing.lua create mode 100644 .config/nvim/lua/plugins/ui/snacks.lua delete mode 100644 .config/nvim/lua/plugins/util/oil.lua create mode 100644 .config/nvim/lua/plugins/util/undotree.lua delete mode 100644 .config/nvim/lua/plugins/util/util.lua create mode 100644 .config/nvim/lua/plugins/util/vim-suda.lua delete mode 100644 .config/tmux/catppuccin.conf create mode 100755 .config/tmux/scripts/cal.sh create mode 100644 .config/tmux/tmux.keybindings.conf create mode 100644 .config/tmux/tmux.plugins.conf create mode 100644 .config/tmux/tmux.reset.conf diff --git a/.config/nvim/.luarc.jsonc b/.config/nvim/.luarc.jsonc index 0967ef4..d01ee0f 100644 --- a/.config/nvim/.luarc.jsonc +++ b/.config/nvim/.luarc.jsonc @@ -1 +1,24 @@ -{} +{ + "runtime": { + "version": "LuaJIT", + "path": [ + "lua/?.lua", + "lua/?/init.lua" + ] + }, + "diagnostics": { + "globals": ["vim", "Snacks"] + }, + "workspace": { + "checkThirdParty": false, + "library": [ + "${3rd}/luv/library", + "~/.local/share/nvim/lazy/oil.nvim/lua", + "~/.local/share/nvim/lazy/snacks.nvim/lua" + ] + }, + "telemetry": { + "enable": false + } +} + diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 0665bd6..02ef088 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,6 +1,7 @@ -- Setup leader keys before loading lazy.nvim vim.g.mapleader = " " vim.g.maplocalleader = "\\" +vim.opt.termguicolors = true -- Initialize lazy.nvim require("config.lazy") diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index 5b7c0ce..1dfb9e6 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -22,6 +22,7 @@ require("lazy").setup({ -- import your plugins { import = "plugins" }, { import = "plugins.file_navigation" }, + { import = "plugins.git" }, { import = "plugins.language_support" }, { import = "plugins.lsp" }, { import = "plugins.ui" }, diff --git a/.config/nvim/lua/jdtls/jdtls_setup.lua b/.config/nvim/lua/jdtls/jdtls_setup.lua index 5000760..ed672b3 100644 --- a/.config/nvim/lua/jdtls/jdtls_setup.lua +++ b/.config/nvim/lua/jdtls/jdtls_setup.lua @@ -15,7 +15,7 @@ function M.setup() local workspace_dir = home .. "/.cache/jdtls/workspace/" .. project_name local path_to_nvim_packages = home .. "/.local/share/nvim" - local path_to_mason_packages = home .. "/.local/share/nvim/mason/packages" + local path_to_mason_packages = path_to_nvim_packages .. "/mason/packages" local path_to_jdtls = path_to_mason_packages .. "/jdtls" local path_to_java_dap = path_to_mason_packages .. "/java-debug-adapter" @@ -27,7 +27,7 @@ function M.setup() local path_to_jar = vim.fn.glob(path_to_jdtls .. "/plugins/org.eclipse.equinox.launcher_*.jar", true) local bundles = { - -- vim.fn.glob(path_to_java_dap .. "/extension/server/com.microsoft.java.debug.plugin-*.jar", true), + vim.fn.glob(path_to_java_dap .. "/extension/server/com.microsoft.java.debug.plugin-*.jar", true), vim.fn.glob( path_to_nvim_packages .. "/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar" @@ -35,61 +35,40 @@ function M.setup() } vim.list_extend(bundles, vim.split(vim.fn.glob(path_to_nvim_packages .. "/vscode-java-test/server/*.jar"), "\n")) - -- vim.list_extend(bundles, vim.split(vim.fn.glob(path_to_jtest .. "/extension/server/*.jar", true), "\n")) + vim.list_extend(bundles, vim.split(vim.fn.glob(path_to_jtest .. "/extension/server/*.jar", true), "\n")) - local on_attach = function(_, bufnr) - -- Regular Neovim LSP client keymappings - local opts = { noremap = true, silent = true, buffer = bufnr } - local telescope = require("telescope.builtin") - utils.nmapkey("gR", telescope.lsp_references, "Go to references", opts) - utils.nmapkey("gD", jdtls.declaration, "Go to declaration", opts) - utils.nmapkey("K", jdtls.hover, "Hover text", opts) - utils.nmapkey("gd", jdtls.definition, "Go to definition", opts) - utils.nmapkey("gi", jdtls.implementation, "Go to implementation", opts) - utils.nmapkey("gt", telescope.lsp_type_definitions, "Show LSP type definitions", opts) - utils.nmapkey("", jdtls.signature_help, "Show signature", opts) + local on_attach = function(ev, bufnr) + local opts = { buffer = ev.buf, silent = true } + utils.common_mappings(opts) - utils.nmapkey("wa", jdtls.add_workspace_folder, "Add workspace folder", opts) - utils.nmapkey("wr", jdtls.remove_workspace_folder, "Remove workspace folder", opts) - utils.nmapkey("wl", function() - print(vim.inspect(jdtls.list_workspace_folders())) - end, "List workspace folders", opts) - - utils.nmapkey("D", telescope.diagnostics({ bufnr = 0 }), "Show buffer diagnostics", opts) -- show diagnostics for file - utils.nmapkey("d", vim.diagnostic.open_float, "Show line diagnostics", opts) -- show diagnostics for line - utils.nmapkey("[d", function() - vim.diagnostic.jump({ count = -1, float = true }) - end, "Go to previous diagnostic", opts) -- jump to previous diagnostic in buffer - utils.nmapkey("]d", function() - vim.diagnostic.jump({ count = 1, float = true }) - end, "Go to next diagnostic", opts) -- jump to next diagnostic in buffer - utils.nmapkey("rs", "LspRestart", "Restart LSP", opts) -- mapping to restart lsp if necessary - - -- Java extensions provided by jdtls + -- Java specific utils.nmapkey("di", jdtls.organize_imports, "Organize imports", opts) utils.nmapkey("dt", jdtls.test_class, "Test class", opts) utils.nmapkey("dn", jdtls.test_nearest_method, "Test nearest method", opts) + utils.nvmapkey("dm", jdtls.extract_method, "Extract method", opts) + utils.nvmapkey("dv", jdtls.extract_variable, "Extract variable", opts) + utils.nvmapkey("dc", jdtls.extract_constant, "Extract constant", opts) + jdtls.setup_dap({ hotcodereplace = "auto" }) + jdtls_dap.setup_dap_main_class_configs() + jdtls_setup.add_commands() - utils.nmapkey("cf", jdtls.formatting, "LSP Format", opts) + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) + vim.lsp.buf.format() + end, { desc = "Format current buffer with LSP" }) - utils.nmapkey("", jdtls.organize_imports, "Organize imports", opts) - utils.mapkey({ "n", "v" }, "ev", jdtls.extract_variable, "Extract variable", opts) - utils.mapkey({ "n", "v" }, "ec", jdtls.extract_constant, "Extract constant", opts) - utils.mapkey({ "n", "v" }, "em", jdtls.extract_variable, "Extract method", opts) + require("lsp_signature").on_attach({ + bind = true, + padding = "", + handler_opts = { + border = "rounded", + }, + hint_prefix = "󱄑 ", + }, bufnr) end - local config = { - init_options = { - bundles = vim.split(vim.fn.glob("/home/iborrelli/pde/extension/server/*.jar"), "\n"), - }, - flags = { - allow_incremental_sync = true, - }, - on_attach = on_attach, -- We pass our on_attach keybindings to the configuration map - } - - config.cmd = { - "/usr/lib/jvm/java-21-openjdk/bin/java", + local cmd = { + "/usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java", "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", @@ -113,29 +92,28 @@ function M.setup() "-data", workspace_dir, } - -- print(table.concat(config.cmd, " ")) - -- print(vim.inspect(config.cmd)) - config.settings = { + local settings = { java = { references = { includeDecompiledSources = true, }, - -- format = { - -- enabled = true, - -- settings = { - -- url = vim.fn.stdpath("config") .. "/lang_servers/intellij-java-google-style.xml", - -- profile = "GoogleStyle", - -- }, - -- }, + -- TODO: enable + format = { + enabled = false, + settings = { + url = vim.fn.stdpath("config") .. "/lang_servers/intellij-java-google-style.xml", + profile = "GoogleStyle", + }, + }, eclipse = { downloadSources = true, }, maven = { downloadSources = true, }, - -- signatureHelp = { enabled = true }, - -- contentProvider = { preferred = "fernflower" }, + signatureHelp = { enabled = true }, + contentProvider = { preferred = "fernflower" }, implementationsCodeLens = { enabled = true, }, @@ -176,89 +154,77 @@ function M.setup() staticStarThreshold = 9999, }, }, - -- codeGeneration = { - -- toString = { - -- template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}", - -- -- flags = { - -- -- allow_incremental_sync = true, - -- -- }, - -- }, - -- useBlocks = true, - -- }, + codeGeneration = { + toString = { + template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}", + }, + useBlocks = true, + }, configuration = { updateBuildConfiguration = "automatic", runtimes = { { name = "JavaSE-17", - path = "/usr/lib/jvm/java-17-openjdk/", + path = os.getenv("JAVA_17_HOME"), }, { name = "JavaSE-21", - path = "/usr/lib/jvm/java-21-openjdk/", + path = os.getenv("JAVA_21_HOME"), }, }, }, - -- project = { - -- referencedLibraries = { - -- "**/lib/*.jar", - -- }, - -- }, - }, - } - -- -- LSP settings for Java. - -- local on_attach = function(_, bufnr) - -- jdtls.setup_dap({ hotcodereplace = "auto" }) - -- jdtls_dap.setup_dap_main_class_configs() - -- jdtls_setup.add_commands() - -- - -- -- Create a command `:Format` local to the LSP buffer - -- vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) - -- vim.lsp.buf.format() - -- end, { desc = "Format current buffer with LSP" }) - -- - -- require("lsp_signature").on_attach({ - -- bind = true, - -- padding = "", - -- handler_opts = { - -- border = "rounded", - -- }, - -- hint_prefix = "󱄑 ", - -- }, bufnr) - -- - -- -- NOTE: comment out if you don't use Lspsaga - -- -- require("lspsaga").init_lsp_saga() - -- end - - local capabilities = { - workspace = { - configuration = true, - }, - textDocument = { - completion = { - completionItem = { - snippetSupport = true, + project = { + referencedLibraries = { + "**/lib/*.jar", }, }, }, } - config.on_attach = on_attach - config.capabilities = capabilities - config.on_init = function(client, _) - client.notify("workspace/didChangeConfiguration", { settings = config.settings }) - end - - local extendedClientCapabilities = require("jdtls").extendedClientCapabilities + local extendedClientCapabilities = jdtls.extendedClientCapabilities extendedClientCapabilities.resolveAdditionalTextEditsSupport = true - config.init_options = { - extendedClientCapabilities = extendedClientCapabilities, + local config = { + flags = { + allow_incremental_sync = true, + }, + init_options = { + bundles = vim.split(vim.fn.glob("/home/iborrelli/pde/extension/server/*.jar"), "\n"), + extendedClientCapabilities = extendedClientCapabilities, + }, + on_init = function(client) + client.notify("workspace/didChangeConfiguration", { settings = settings }) + end, + settings = settings, + + cmd = cmd, + on_attach = on_attach, + capabilities = { + workspace = { + configuration = true, + }, + textDocument = { + completion = { + completionItem = { + snippetSupport = true, + }, + }, + }, + }, } -- Start Server - require("jdtls").start_or_attach(config) + jdtls.start_or_attach(config) - -- -- Set Java Specific Keymaps - -- require("jdtls.keymaps") + vim.cmd( + "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" + ) + vim.cmd( + "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" + ) + vim.cmd("command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()") + vim.cmd("command! -buffer JdtJol lua require('jdtls').jol()") + vim.cmd("command! -buffer JdtBytecode lua require('jdtls').javap()") + vim.cmd("command! -buffer JdtJshell lua require('jdtls').jshell()") end return M diff --git a/.config/nvim/lua/jdtls/keymaps.lua b/.config/nvim/lua/jdtls/keymaps.lua deleted file mode 100644 index 3229f1a..0000000 --- a/.config/nvim/lua/jdtls/keymaps.lua +++ /dev/null @@ -1,104 +0,0 @@ --- NOTE: Java specific keymaps with which key -vim.cmd( - "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" -) -vim.cmd( - "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" -) -vim.cmd("command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()") -vim.cmd("command! -buffer JdtJol lua require('jdtls').jol()") -vim.cmd("command! -buffer JdtBytecode lua require('jdtls').javap()") -vim.cmd("command! -buffer JdtJshell lua require('jdtls').jshell()") - -local status_ok, which_key = pcall(require, "which-key") -if not status_ok then - return -end - -local opts = { - mode = "n", -- NORMAL mode - prefix = "", - 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 vopts = { - mode = "v", -- VISUAL mode - prefix = "", - 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 mappings = { - J = { - name = "Java", - o = { "lua require'jdtls'.organize_imports()", "Organize Imports" }, - v = { "lua require('jdtls').extract_variable()", "Extract Variable" }, - c = { "lua require('jdtls').extract_constant()", "Extract Constant" }, - t = { "lua require'jdtls'.test_nearest_method()", "Test Method" }, - T = { "lua require'jdtls'.test_class()", "Test Class" }, - u = { "JdtUpdateConfig", "Update Config" }, - }, -} - -local vmappings = { - J = { - name = "Java", - v = { "lua require('jdtls').extract_variable(true)", "Extract Variable" }, - c = { "lua require('jdtls').extract_constant(true)", "Extract Constant" }, - m = { "lua require('jdtls').extract_method(true)", "Extract Method" }, - }, -} - -which_key.register(mappings, opts) -which_key.register(vmappings, vopts) - --- If you want you can add here Old School Mappings. Me I setup Telescope, LSP and Lspsaga mapping somewhere else and I just reuse them - --- vim.keymap.set("gI", vim.lsp.buf.implementation,{ desc = "[G]oto [I]mplementation" }) --- vim.keymap.set("D", vim.lsp.buf.type_definition,{ desc = "Type [D]definition" }) --- vim.keymap.set("hh", vim.lsp.buf.signature_help,{ desc = "Signature [H][H]elp Documentation" }) - --- vim.keymap.set("gD", vim.lsp.buf.declaration,{ desc = "[G]oto [D]eclaration" }) --- vim.keymap.set("wa", vim.lsp.buf.add_workspace_folder,{ desc = "[W]orkspace [A]dd Folder" }) --- vim.keymap.set("wr", vim.lsp.buf.remove_workspace_folder,{ desc = "[W]orkspace [R]emove Folder" }) --- vim.keymap.set("wl", function() --- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) --- end, "[W]orkspace [L]ist Folders") - --- Create a command `:Format` local to the LSP buffer --- vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) --- vim.lsp.buf.format() --- end, { desc = "Format current buffer with LSP" }) - --- vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "[G]oto [R]eferences - Java", expr = true, silent = true }) -vim.keymap.set("n", "gr", require("telescope.builtin").lsp_references, { desc = "[G]oto [R]eferences" }) -vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "" }) -vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "" }) -vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "" }) -vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "" }) -vim.keymap.set('n', '', vim.lsp.buf.signature_help, { desc = "" }) -vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, { desc = "" }) -vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, { desc = "" }) -vim.keymap.set('n', 'wl', print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', { desc = "" }) -vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, { desc = "" }) -vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = "" }) -vim.keymap.set('n', 'gr', vim.lsp.buf.references() && vim.cmd("copen")', { desc = "" }) -vim.keymap.set('n', 'e', vim.lsp.diagnostic.show_line_diagnostics, { desc = "" }) -vim.keymap.set('n', '[d', vim.lsp.diagnostic.goto_prev, { desc = "" }) -vim.keymap.set('n', ']d', vim.lsp.diagnostic.goto_next, { desc = "" }) -vim.keymap.set('n', 'q', vim.lsp.diagnostic.set_loclist, { desc = "" }) - --- Java specific -vim.keymap.set("n", "di", "lua require'jdtls'.organize_imports()", { desc = "" }) -vim.keymap.set("n", "dt", "lua require'jdtls'.test_class()", { desc = "" }) -vim.keymap.set("n", "dn", "lua require'jdtls'.test_nearest_method()", { desc = "" }) -vim.keymap.set("v", "de", "lua require('jdtls').extract_variable(true)", { desc = "" }) -vim.keymap.set("n", "de", "lua require('jdtls').extract_variable()", { desc = "" }) -vim.keymap.set("v", "dm", "lua require('jdtls').extract_method(true)", { desc = "" }) - -vim.keymap.set("n", "cf", "lua vim.lsp.buf.formatting()", { desc = "" }) diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua index c900a4c..d2ef0b9 100644 --- a/.config/nvim/lua/keybindings.lua +++ b/.config/nvim/lua/keybindings.lua @@ -13,8 +13,8 @@ map("n", "k", "k", opts) opts.desc = "Navigate window right" map("n", "l", "l", opts) -opts.desc = "Save session, write all buffers and quit" -map("n", "qqq", ':lua require("auto-session").SaveSession():wqa', opts) +opts.desc = "Visual copy" +map("v", "", '"+y', opts) opts.desc = "Visual copy" -map("v", "", '"*y', opts) +map("v", "", '"+y', opts) diff --git a/.config/nvim/lua/plugins/util/nvim-notify.lua b/.config/nvim/lua/nvim-notify.lua similarity index 100% rename from .config/nvim/lua/plugins/util/nvim-notify.lua rename to .config/nvim/lua/nvim-notify.lua diff --git a/.config/nvim/lua/plugins/file_navigation/harpoon.lua b/.config/nvim/lua/plugins/file_navigation/harpoon.lua new file mode 100644 index 0000000..4e2f009 --- /dev/null +++ b/.config/nvim/lua/plugins/file_navigation/harpoon.lua @@ -0,0 +1,73 @@ +local utils = require("utils") +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + + config = function() + local harpoon = require("harpoon") + harpoon:setup() + local list = harpoon:list() + + utils.nmapkey("a", function() + list:add() + end, "Add to harpoon buffers") + + utils.nmapkey("", function() + list:select(1) + end, "Navigate to harpoon buffer 1") + utils.nmapkey("", function() + list:select(2) + end, "Navigate to harpoon buffer 2") + utils.nmapkey("", function() + list:select(3) + end, "Navigate to harpoon buffer 3") + utils.nmapkey("", function() + list:select(4) + end, "Navigate to harpoon buffer 1") + + -- Toggle previous & next buffers stored within Harpoon list + utils.nmapkey("", function() + list:prev() + end, "Go to previous harpoon buffer") + utils.nmapkey("", function() + list:next() + end, "Go to next harpoon buffer") + + -- Remove current buffer from list + utils.nmapkey("", function() + list:remove() + end, "Remove current buffer from harpoon list") + + -- Reset buffer + utils.nmapkey("", function() + for _, item in ipairs(list.items) do + list:remove(item) + end + end, "Reset harpoon list") + + -- basic telescope configuration + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers") + .new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() + end + + utils.nmapkey("", function() + toggle_telescope(list) + end, "Open harpoon window") + end, +} diff --git a/.config/nvim/lua/plugins/file_navigation/neo-tree.lua b/.config/nvim/lua/plugins/file_navigation/neo-tree.lua deleted file mode 100644 index 2591c7c..0000000 --- a/.config/nvim/lua/plugins/file_navigation/neo-tree.lua +++ /dev/null @@ -1,62 +0,0 @@ -local utils = require("utils") -return { - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v2.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - opts = { - window = { position = "current" }, - }, - config = function() - require("neo-tree").setup({ - filesystem = { - filtered_items = { - visible = true, -- Show files and folders starting with a dot `.` - hide_dotfiles = false, - hide_gitignored = false, - }, - }, - }) - - local keymap = vim.keymap - local opts = { noremap = true, silent = true } - utils.nmapkey("e", function() - require("neo-tree.command").execute({ - position = "left", - action = "toggle", - }) - end, "Toggle Neotree", opts) - utils.nmapkey("ee", function() - require("neo-tree.command").execute({ - position = "left", - focus = "true", - }) - end, "Open Neotree", opts) - utils.nmapkey("qe", function() - require("neo-tree.command").execute({ - position = "left", - action = "close", - focus = "true", - }) - end, "Close Neotree", opts) - - utils.mapkey({ "n", "v" }, "|", "Neotree reveal", "Reveal file in Neotree", opts) - utils.nmapkey( - "eb", - "Neotree toggle show buffers right", - "Show buffers (Neotree)", - { noremap = true, silent = true } - ) - utils.nmapkey( - "gs", - "Neotree float git_status", - "Show git status (Neotree)", - { noremap = true, silent = true } - ) - end, - }, -} diff --git a/.config/nvim/lua/plugins/file_navigation/oil.lua b/.config/nvim/lua/plugins/file_navigation/oil.lua new file mode 100644 index 0000000..5aef83e --- /dev/null +++ b/.config/nvim/lua/plugins/file_navigation/oil.lua @@ -0,0 +1,38 @@ +return { + { + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + lazy = false, + config = function() + require("oil").setup({ + delete_to_trash = true, + keymaps = { + [""] = { "actions.close", mode = "n" }, + }, + win_options = { + signcolumn = "yes:2", + }, + }) + local utils = require("utils") + utils.nmapkey("-", "Oil --float", "Open parent directory") + end, + }, + { + "JezerM/oil-lsp-diagnostics.nvim", + dependencies = { "stevearc/oil.nvim" }, + }, + { + "benomahony/oil-git.nvim", + dependencies = { "stevearc/oil.nvim" }, + }, + { + "refractalize/oil-git-status.nvim", + dependencies = { + "stevearc/oil.nvim", + }, + config = true, + }, +} diff --git a/.config/nvim/lua/plugins/file_navigation/telescope.lua b/.config/nvim/lua/plugins/file_navigation/telescope.lua index 8eef14d..a6ac40d 100644 --- a/.config/nvim/lua/plugins/file_navigation/telescope.lua +++ b/.config/nvim/lua/plugins/file_navigation/telescope.lua @@ -1,3 +1,4 @@ +local utils = require("utils") return { "nvim-telescope/telescope.nvim", tag = "0.1.8", @@ -5,7 +6,7 @@ return { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", "folke/todo-comments.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, -- fuzzy search + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, }, config = function() local telescope = require("telescope") @@ -13,11 +14,10 @@ return { local actions = require("telescope.actions") local open_with_trouble = trouble_telescope.open - -- Use this to add more results without clearing the trouble list - local add_to_trouble = require("trouble.sources.telescope").add - telescope.setup({ defaults = { + layout_strategy = "center", + layout_config = { width = 120 }, mappings = { i = { [""] = actions.move_selection_previous, @@ -26,29 +26,22 @@ return { [""] = actions.preview_scrolling_down, [""] = open_with_trouble, }, - n = { [""] = open_with_trouble }, }, }, }) telescope.load_extension("fzf") -- Set keymaps to load pickers - local keymap = vim.keymap - keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd (Telescope)" }) - keymap.set( - "n", - "fr", - "Telescope oldfiles cwd_only=true", - { desc = "Fuzzy find recent files (Telescope)" } - ) - keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd (Telescope)" }) - keymap.set("v", "fs", "Telescope live_grep", { desc = "Find string in cwd (Telescope)" }) - keymap.set( - "n", - "fc", - "Telescope grep_string", - { desc = "Find string under cursor in cwd (Telescope)" } - ) - keymap.set("n", "ft", "TodoTelescope", { desc = "Find todos (Telescope)" }) + local builtin = require("telescope.builtin") + utils.nmapkey("ff", function() + builtin.find_files(require("telescope.themes").get_dropdown({})) + end, "Telescope [f]ind [f]iles in cwd") + utils.nmapkey("fr", function() + builtin.oldfiles({ cwd_only = true }) + end, "Telescope [f]ind [r]ecent files") + utils.nmapkey("fs", builtin.live_grep, "Telescope [f]ind [s]tring in cwd") + utils.nmapkey("fc", builtin.grep_string, "Telescope [f]ind string under [c]ursor in cwd") + utils.nmapkey("ft", "TodoTelescope", "Telescope [f]ind [t]odos") + utils.nmapkey("fb", builtin.buffers, "Telescope [f]ind [b]uffer") end, } diff --git a/.config/nvim/lua/plugins/git/diffview.lua b/.config/nvim/lua/plugins/git/diffview.lua new file mode 100644 index 0000000..e4a3402 --- /dev/null +++ b/.config/nvim/lua/plugins/git/diffview.lua @@ -0,0 +1,3 @@ +return { + "sindrets/diffview.nvim", +} diff --git a/.config/nvim/lua/plugins/git/fugitive.lua b/.config/nvim/lua/plugins/git/fugitive.lua new file mode 100644 index 0000000..2b2edd0 --- /dev/null +++ b/.config/nvim/lua/plugins/git/fugitive.lua @@ -0,0 +1,3 @@ +return { + "tpope/vim-fugitive", +} diff --git a/.config/nvim/lua/plugins/util/neogit.lua b/.config/nvim/lua/plugins/git/neogit.lua similarity index 50% rename from .config/nvim/lua/plugins/util/neogit.lua rename to .config/nvim/lua/plugins/git/neogit.lua index 7b73b1d..9c522a6 100644 --- a/.config/nvim/lua/plugins/util/neogit.lua +++ b/.config/nvim/lua/plugins/git/neogit.lua @@ -4,9 +4,8 @@ return { "nvim-lua/plenary.nvim", "sindrets/diffview.nvim", "nvim-telescope/telescope.nvim", + "ibhagwan/fzf-lua", + "echasnovski/mini.pick", + "folke/snacks.nvim", }, - keys = { { "gg", "Neogit", desc = "Open Neogit (Neogit)" } }, - config = function() - local neogit = require("neogit") - end, } diff --git a/.config/nvim/lua/plugins/language_support/conform.lua b/.config/nvim/lua/plugins/language_support/conform.lua index 30a0f36..b0272c0 100644 --- a/.config/nvim/lua/plugins/language_support/conform.lua +++ b/.config/nvim/lua/plugins/language_support/conform.lua @@ -48,7 +48,6 @@ return { typescriptreact = { decide_js_formatter() }, yaml = { "yamlfmt" }, xml = { "xmlformatter" }, - ["*"] = { "codespell" }, }, formatters = { diff --git a/.config/nvim/lua/plugins/language_support/gradle.lua b/.config/nvim/lua/plugins/language_support/gradle.lua index 457d500..40b87b2 100644 --- a/.config/nvim/lua/plugins/language_support/gradle.lua +++ b/.config/nvim/lua/plugins/language_support/gradle.lua @@ -6,5 +6,5 @@ return { "MunifTanjim/nui.nvim", }, opts = {}, -- options, see default configuration - keys = { { "G", "Gradle", desc = "Gradle" } }, + keys = { { "lg", "Gradle", desc = "Gradle" } }, } diff --git a/.config/nvim/lua/plugins/language_support/nvim-cmp.lua b/.config/nvim/lua/plugins/language_support/nvim-cmp.lua index ff9783a..9cf0f1d 100644 --- a/.config/nvim/lua/plugins/language_support/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/language_support/nvim-cmp.lua @@ -24,9 +24,53 @@ return { -- Loads vscode style snippets from installed plugins (e.g. friendly-snippets) require("luasnip.loaders.from_vscode").lazy_load() + local mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), -- scroll down in docs + [""] = cmp.mapping.scroll_docs(4), -- scroll up in docs + [""] = cmp.mapping.scroll_docs(-4), -- scroll down in docs + [""] = cmp.mapping.scroll_docs(4), -- scroll up in docs + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + + -- On CR, insert selected snippet or completion + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), + + -- On tab with completion open, go to next option + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s", "c" }), + + -- On shift tab with completion open, go to prev option + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s", "c" }), + }) + -- `/` cmdline setup. cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), + mapping = mapping, sources = { { name = "buffer" }, }, @@ -34,7 +78,10 @@ return { -- `:` cmdline setup. cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + mapping = mapping, sources = cmp.config.sources({ { name = "path" }, }, { @@ -55,7 +102,7 @@ return { -- preview: preview window explaining the offered completion -- select: select an option automatically (noselect is the reverse) completion = { - completeopt = "menu,menuone,preview,select", + completeopt = "menu,menuone,preview,noselect", }, -- Configure how nvim-cmp interacts with snippet engine snippet = { @@ -63,15 +110,8 @@ return { luasnip.lsp_expand(args.body) end, }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), -- previous suggestion - [""] = cmp.mapping.select_next_item(), -- next suggestion - [""] = cmp.mapping.scroll_docs(-4), -- scroll down in docs - [""] = cmp.mapping.scroll_docs(4), -- scroll up in docs - [""] = cmp.mapping.scroll_docs(-4), -- scroll down in docs - [""] = cmp.mapping.scroll_docs(4), -- scroll up in docs - [""] = cmp.mapping.complete(), -- show completion suggestions - [""] = cmp.mapping.abort(), -- close completion window + + mapping = mapping.insert({ [""] = cmp.mapping.complete({ config = { sources = { { name = "nvim_lsp" }, @@ -82,22 +122,6 @@ return { { name = "luasnip" }, } }, }), -- show only snippet completions - - -- On CR, insert selected snippet or completion - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), - -- On tab with completion open, go to next option [""] = cmp.mapping(function(fallback) if cmp.visible() then diff --git a/.config/nvim/lua/plugins/lsp/mason.lua b/.config/nvim/lua/plugins/lsp/mason.lua index 0f7a13a..abd9f6c 100644 --- a/.config/nvim/lua/plugins/lsp/mason.lua +++ b/.config/nvim/lua/plugins/lsp/mason.lua @@ -29,6 +29,7 @@ return { "emmet_ls", "eslint", "groovyls", + "hls", "html", "jdtls", "jsonls", @@ -51,13 +52,13 @@ return { "black", "checkstyle", "chrome-debug-adapter", - "codespell", "eslint_d", "firefox-debug-adapter", "flake8", "fourmolu", "isort", "java-debug-adapter", + "java-test", "jq", "markdownlint", "matlab-language-server", diff --git a/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua index b2348b9..8874243 100644 --- a/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua +++ b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua @@ -24,25 +24,7 @@ return { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) local opts = { buffer = ev.buf, silent = true } - local telescope = require("telescope.builtin") - - utils.nmapkey("gR", telescope.lsp_references, "Show LSP references", opts) -- show definition, references - utils.nmapkey("gD", vim.lsp.buf.declaration, "Go to declaration", opts) -- go to declaration - utils.nmapkey("K", vim.lsp.buf.hover, "Show documentation for what is under cursor", opts) -- show documentation for what is under cursor - utils.nmapkey("gd", telescope.lsp_definitions, "Show LSP definitions", opts) - utils.nmapkey("gi", telescope.lsp_implementations, "Show LSP implementations", opts) - utils.nmapkey("gt", telescope.lsp_type_definitions, "Show LSP type definitions", opts) - utils.mapkey({ "n", "v" }, "ca", vim.lsp.buf.code_action, "See available code actions", opts) -- see available code actions - utils.nmapkey("rn", vim.lsp.buf.rename, "Smart rename", opts) -- smart rename - utils.nmapkey("D", telescope.diagnostics, "Show buffer diagnostics", opts) -- show diagnostics for file - utils.nmapkey("d", vim.diagnostic.open_float, "Show line diagnostics", opts) -- show diagnostics for line - utils.nmapkey("[d", function() - vim.diagnostic.jump({ count = -1, float = true }) - end, "Go to previous diagnostic", opts) -- jump to previous diagnostic in buffer - utils.nmapkey("]d", function() - vim.diagnostic.jump({ count = 1, float = true }) - end, "Go to next diagnostic", opts) -- jump to next diagnostic in buffer - utils.nmapkey("rs", "LspRestart", "Restart LSP", opts) -- mapping to restart lsp if necessary + utils.common_mappings(opts) end, }) @@ -50,46 +32,25 @@ return { local capabilities = require("cmp_nvim_lsp").default_capabilities() -- Configure for language servers - -- lua_ls vim.lsp.config("lua_ls", { + settings = { + Lua = { + capabilities = capabilities, + }, + }, on_init = function(client) - print(client.root_dir) if client.workspace_folders then local path = client.workspace_folders[1].name - print(path) if path ~= vim.fn.stdpath("config") and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) then - print(path) return end end - - client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { - runtime = { - version = "LuaJIT", - -- Tell the language server how to find Lua modules same way as Neovim - -- (see `:h lua-module-load`) - path = { - "lua/?.lua", - "lua/?/init.lua", - }, - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME, - "${3rd}/luv/library", - }, - }, - capabilities = capabilities, - }) end, }) - -- ts_ls vim.lsp.config("ts_ls", { on_attach = function(client) -- Disable formatting capability for tsserver (see conform.lua and nvim-lint.lua) @@ -141,5 +102,15 @@ return { }, capabilities = capabilities, }) + + vim.lsp.config("hls", { + capabilities = capabilities, + filetypes = { "haskell", "lhaskell", "cabal" }, + settings = { + haskell = { + formattingProvider = "fourmolu", + }, + }, + }) end, } diff --git a/.config/nvim/lua/plugins/theme.lua b/.config/nvim/lua/plugins/theme.lua index 7860a3a..7073f35 100644 --- a/.config/nvim/lua/plugins/theme.lua +++ b/.config/nvim/lua/plugins/theme.lua @@ -60,7 +60,7 @@ return { themery.setup({ -- List of swappable colorschemes. themes = { - "cuddlefish", + "cuddlefish", "deeper-night", "onedark_dark", "dracula", diff --git a/.config/nvim/lua/plugins/ui/barbar.lua b/.config/nvim/lua/plugins/ui/barbar.lua deleted file mode 100644 index ca6446f..0000000 --- a/.config/nvim/lua/plugins/ui/barbar.lua +++ /dev/null @@ -1,61 +0,0 @@ -return { - "romgrk/barbar.nvim", - dependencies = { - "lewis6991/gitsigns.nvim", - "nvim-tree/nvim-web-devicons", - }, - init = function() - vim.g.barbar_auto_setup = false - end, - config = function() - require("barbar").setup({ - animation = true, - auto_hide = true, - clickable = true, - }) - - local map = vim.api.nvim_set_keymap - local opts = { noremap = true, silent = true } - - -- Move to previous/next - map("n", ",", "BufferPrevious", opts) - map("n", ".", "BufferNext", opts) - map("n", "", "BufferPrevious", opts) - map("n", "", "BufferNext", opts) - - -- Re-order to previous/next - map("n", "<", "BufferMovePrevious", opts) - map("n", ">", "BufferMoveNext", opts) - - -- Goto buffer in position... - map("n", "1", "BufferGoto 1", opts) - map("n", "2", "BufferGoto 2", opts) - map("n", "3", "BufferGoto 3", opts) - map("n", "4", "BufferGoto 4", opts) - map("n", "5", "BufferGoto 5", opts) - map("n", "6", "BufferGoto 6", opts) - map("n", "7", "BufferGoto 7", opts) - map("n", "8", "BufferGoto 8", opts) - map("n", "9", "BufferGoto 9", opts) - map("n", "0", "BufferLast", opts) - - -- Pin/unpin buffer - map("n", "p", "BufferPin", opts) - - -- Close buffer - map("n", "c", "BufferClose", opts) - - -- Magic buffer-picking mode - map("n", "", "BufferPick", opts) - map("n", "", "BufferPickDelete", opts) - - -- Sort automatically by... - map("n", "bb", "BufferOrderByBufferNumber", opts) - map("n", "bn", "BufferOrderByName", opts) - map("n", "bd", "BufferOrderByDirectory", opts) - -- - -- Wipeout buffer - map("n", "bl", "BufferOrderByLanguage", opts) - map("n", "bw", "BufferOrderByWindowNumber", opts) - end, -} diff --git a/.config/nvim/lua/plugins/ui/dressing.lua b/.config/nvim/lua/plugins/ui/dressing.lua deleted file mode 100644 index a6f822a..0000000 --- a/.config/nvim/lua/plugins/ui/dressing.lua +++ /dev/null @@ -1,172 +0,0 @@ -return { - "stevearc/dressing.nvim", - event = "VeryLazy", - config = function() - require("dressing").setup({ - input = { - -- Set to false to disable the vim.ui.input implementation - enabled = true, - - -- Default prompt string - default_prompt = "Input", - - -- Trim trailing `:` from prompt - trim_prompt = true, - - -- Can be 'left', 'right', or 'center' - title_pos = "left", - - -- The initial mode when the window opens (insert|normal|visual|select). - start_mode = "insert", - - -- These are passed to nvim_open_win - border = "rounded", - -- 'editor' and 'win' will default to being centered - relative = "cursor", - - -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - prefer_width = 40, - width = nil, - -- min_width and max_width can be a list of mixed types. - -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total" - max_width = { 140, 0.9 }, - min_width = { 20, 0.2 }, - - buf_options = {}, - win_options = { - -- Disable line wrapping - wrap = false, - -- Indicator for when text exceeds window - list = true, - listchars = "precedes:…,extends:…", - -- Increase this for more context when text scrolls off the window - sidescrolloff = 0, - }, - - -- Set to `false` to disable - mappings = { - n = { - [""] = "Close", - [""] = "Confirm", - }, - i = { - [""] = "Close", - [""] = "Confirm", - [""] = "HistoryPrev", - [""] = "HistoryNext", - }, - }, - - override = function(conf) - -- This is the config that will be passed to nvim_open_win. - -- Change values here to customize the layout - return conf - end, - - -- see :help dressing_get_config - get_config = nil, - }, - select = { - -- Set to false to disable the vim.ui.select implementation - enabled = true, - - -- Priority list of preferred vim.select implementations - backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" }, - - -- Trim trailing `:` from prompt - trim_prompt = true, - - -- Options for telescope selector - -- These are passed into the telescope picker directly. Can be used like: - -- telescope = require('telescope.themes').get_ivy({...}) - telescope = nil, - - -- Options for fzf selector - fzf = { - window = { - width = 0.5, - height = 0.4, - }, - }, - - -- Options for fzf-lua - fzf_lua = { - -- winopts = { - -- height = 0.5, - -- width = 0.5, - -- }, - }, - - -- Options for nui Menu - nui = { - position = "50%", - size = nil, - relative = "editor", - border = { - style = "rounded", - }, - buf_options = { - swapfile = false, - filetype = "DressingSelect", - }, - win_options = { - winblend = 0, - }, - max_width = 80, - max_height = 40, - min_width = 40, - min_height = 10, - }, - - -- Options for built-in selector - builtin = { - -- Display numbers for options and set up keymaps - show_numbers = true, - -- These are passed to nvim_open_win - border = "rounded", - -- 'editor' and 'win' will default to being centered - relative = "editor", - - buf_options = {}, - win_options = { - cursorline = true, - cursorlineopt = "both", - -- disable highlighting for the brackets around the numbers - winhighlight = "MatchParen:", - -- adds padding at the left border - statuscolumn = " ", - }, - - -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - -- the min_ and max_ options can be a list of mixed types. - -- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total" - width = nil, - max_width = { 140, 0.8 }, - min_width = { 40, 0.2 }, - height = nil, - max_height = 0.9, - min_height = { 10, 0.2 }, - - -- Set to `false` to disable - mappings = { - [""] = "Close", - [""] = "Close", - [""] = "Confirm", - }, - - override = function(conf) - -- This is the config that will be passed to nvim_open_win. - -- Change values here to customize the layout - return conf - end, - }, - - -- Used to override format_item. See :help dressing-format - format_item_override = {}, - - -- see :help dressing_get_config - get_config = nil, - }, - }) - end, -} diff --git a/.config/nvim/lua/plugins/ui/snacks.lua b/.config/nvim/lua/plugins/ui/snacks.lua new file mode 100644 index 0000000..1bceeb0 --- /dev/null +++ b/.config/nvim/lua/plugins/ui/snacks.lua @@ -0,0 +1,555 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + dashboard = { enabled = true }, + explorer = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + }, + picker = { enabled = true }, + quickfile = { enabled = true }, + scope = { enabled = true }, + scroll = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + -- wo = { wrap = true } -- Wrap notifications + }, + }, + }, + keys = { + -- Top Pickers & Explorer + { + "", + function() + Snacks.picker.smart() + end, + desc = "Smart Find Files", + }, + { + ",", + function() + Snacks.picker.buffers() + end, + desc = "Buffers", + }, + { + "/", + function() + Snacks.picker.grep() + end, + desc = "Grep", + }, + { + ":", + function() + Snacks.picker.command_history() + end, + desc = "Command History", + }, + { + "n", + function() + Snacks.picker.notifications() + end, + desc = "Notification History", + }, + { + "e", + function() + Snacks.explorer() + end, + desc = "File Explorer", + }, + -- find + { + "fb", + function() + Snacks.picker.buffers() + end, + desc = "Buffers", + }, + { + "fc", + function() + Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) + end, + desc = "Find Config File", + }, + { + "ff", + function() + Snacks.picker.files() + end, + desc = "Find Files", + }, + { + "fg", + function() + Snacks.picker.git_files() + end, + desc = "Find Git Files", + }, + { + "fp", + function() + Snacks.picker.projects() + end, + desc = "Projects", + }, + { + "fr", + function() + Snacks.picker.recent() + end, + desc = "Recent", + }, + -- git + { + "gb", + function() + Snacks.picker.git_branches() + end, + desc = "Git Branches", + }, + { + "gl", + function() + Snacks.picker.git_log() + end, + desc = "Git Log", + }, + { + "gL", + function() + Snacks.picker.git_log_line() + end, + desc = "Git Log Line", + }, + { + "gs", + function() + Snacks.picker.git_status() + end, + desc = "Git Status", + }, + { + "gS", + function() + Snacks.picker.git_stash() + end, + desc = "Git Stash", + }, + { + "gd", + function() + Snacks.picker.git_diff() + end, + desc = "Git Diff (Hunks)", + }, + { + "gf", + function() + Snacks.picker.git_log_file() + end, + desc = "Git Log File", + }, + -- Grep + { + "sb", + function() + Snacks.picker.lines() + end, + desc = "Buffer Lines", + }, + { + "sB", + function() + Snacks.picker.grep_buffers() + end, + desc = "Grep Open Buffers", + }, + { + "sg", + function() + Snacks.picker.grep() + end, + desc = "Grep", + }, + { + "sw", + function() + Snacks.picker.grep_word() + end, + desc = "Visual selection or word", + mode = { "n", "x" }, + }, + -- search + { + 's"', + function() + Snacks.picker.registers() + end, + desc = "Registers", + }, + { + "s/", + function() + Snacks.picker.search_history() + end, + desc = "Search History", + }, + { + "sa", + function() + Snacks.picker.autocmds() + end, + desc = "Autocmds", + }, + { + "sb", + function() + Snacks.picker.lines() + end, + desc = "Buffer Lines", + }, + { + "sc", + function() + Snacks.picker.command_history() + end, + desc = "Command History", + }, + { + "sC", + function() + Snacks.picker.commands() + end, + desc = "Commands", + }, + { + "sd", + function() + Snacks.picker.diagnostics() + end, + desc = "Diagnostics", + }, + { + "sD", + function() + Snacks.picker.diagnostics_buffer() + end, + desc = "Buffer Diagnostics", + }, + { + "sh", + function() + Snacks.picker.help() + end, + desc = "Help Pages", + }, + { + "sH", + function() + Snacks.picker.highlights() + end, + desc = "Highlights", + }, + { + "si", + function() + Snacks.picker.icons() + end, + desc = "Icons", + }, + { + "sj", + function() + Snacks.picker.jumps() + end, + desc = "Jumps", + }, + { + "sk", + function() + Snacks.picker.keymaps() + end, + desc = "Keymaps", + }, + { + "sl", + function() + Snacks.picker.loclist() + end, + desc = "Location List", + }, + { + "sm", + function() + Snacks.picker.marks() + end, + desc = "Marks", + }, + { + "sM", + function() + Snacks.picker.man() + end, + desc = "Man Pages", + }, + { + "sp", + function() + Snacks.picker.lazy() + end, + desc = "Search for Plugin Spec", + }, + { + "sq", + function() + Snacks.picker.qflist() + end, + desc = "Quickfix List", + }, + { + "sR", + function() + Snacks.picker.resume() + end, + desc = "Resume", + }, + { + "su", + function() + Snacks.picker.undo() + end, + desc = "Undo History", + }, + { + "uC", + function() + Snacks.picker.colorschemes() + end, + desc = "Colorschemes", + }, + -- LSP + { + "gd", + function() + Snacks.picker.lsp_definitions() + end, + desc = "Goto Definition", + }, + { + "gD", + function() + Snacks.picker.lsp_declarations() + end, + desc = "Goto Declaration", + }, + { + "gr", + function() + Snacks.picker.lsp_references() + end, + nowait = true, + desc = "References", + }, + { + "gI", + function() + Snacks.picker.lsp_implementations() + end, + desc = "Goto Implementation", + }, + { + "gy", + function() + Snacks.picker.lsp_type_definitions() + end, + desc = "Goto T[y]pe Definition", + }, + { + "ss", + function() + Snacks.picker.lsp_symbols() + end, + desc = "LSP Symbols", + }, + { + "sS", + function() + Snacks.picker.lsp_workspace_symbols() + end, + desc = "LSP Workspace Symbols", + }, + -- Other + { + "z", + function() + Snacks.zen() + end, + desc = "Toggle Zen Mode", + }, + { + "Z", + function() + Snacks.zen.zoom() + end, + desc = "Toggle Zoom", + }, + { + ".", + function() + Snacks.scratch() + end, + desc = "Toggle Scratch Buffer", + }, + { + "S", + function() + Snacks.scratch.select() + end, + desc = "Select Scratch Buffer", + }, + { + "n", + function() + Snacks.notifier.show_history() + end, + desc = "Notification History", + }, + { + "bd", + function() + Snacks.bufdelete() + end, + desc = "Delete Buffer", + }, + { + "cR", + function() + Snacks.rename.rename_file() + end, + desc = "Rename File", + }, + { + "gB", + function() + Snacks.gitbrowse() + end, + desc = "Git Browse", + mode = { "n", "v" }, + }, + { + "gg", + function() + Snacks.lazygit() + end, + desc = "Lazygit", + }, + { + "un", + function() + Snacks.notifier.hide() + end, + desc = "Dismiss All Notifications", + }, + { + "", + function() + Snacks.terminal() + end, + desc = "Toggle Terminal", + }, + { + "", + function() + Snacks.terminal() + end, + desc = "which_key_ignore", + }, + { + "]]", + function() + Snacks.words.jump(vim.v.count1) + end, + desc = "Next Reference", + mode = { "n", "t" }, + }, + { + "[[", + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = "Prev Reference", + mode = { "n", "t" }, + }, + { + "N", + desc = "Neovim News", + function() + Snacks.win({ + file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = "yes", + statuscolumn = " ", + conceallevel = 3, + }, + }) + end, + }, + }, + init = function() + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + + -- Override print to use snacks for `:=` command + if vim.fn.has("nvim-0.11") == 1 then + vim._print = function(_, ...) + dd(...) + end + else + vim.print = _G.dd + end + + -- Create some toggle mappings + Snacks.toggle.option("spell", { name = "Spelling" }):map("us") + Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") + Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") + Snacks.toggle.diagnostics():map("ud") + Snacks.toggle.line_number():map("ul") + Snacks.toggle + .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) + :map("uc") + Snacks.toggle.treesitter():map("uT") + Snacks.toggle + .option("background", { off = "light", on = "dark", name = "Dark Background" }) + :map("ub") + Snacks.toggle.inlay_hints():map("uh") + Snacks.toggle.indent():map("ug") + Snacks.toggle.dim():map("uD") + end, + }) + end, +} diff --git a/.config/nvim/lua/plugins/util/auto-session.lua b/.config/nvim/lua/plugins/util/auto-session.lua index 7a4c73f..098fb42 100644 --- a/.config/nvim/lua/plugins/util/auto-session.lua +++ b/.config/nvim/lua/plugins/util/auto-session.lua @@ -1,21 +1,9 @@ return { "rmagatti/auto-session", config = function() - local auto_session = require("auto-session") - - auto_session.setup({ + require("auto-session").setup({ auto_restore_enabled = true, auto_session_suppress_dirs = { "~/", "~/Code/", "~/Downloads", "~/Documents", "~/Desktop/" }, }) - - local keymap = vim.keymap - - keymap.set("n", "wr", "SessionRestore", { desc = "Restore session for cwd (auto-session)" }) -- restore last workspace session for current directory - keymap.set( - "n", - "ws", - "SessionSave", - { desc = "Save session for auto session root dir (auto-session)" } - ) end, } diff --git a/.config/nvim/lua/plugins/util/oil.lua b/.config/nvim/lua/plugins/util/oil.lua deleted file mode 100644 index 2ce3d90..0000000 --- a/.config/nvim/lua/plugins/util/oil.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "stevearc/oil.nvim", - ---@module 'oil' - ---@type oil.SetupOpts - opts = {}, - -- Optional dependencies - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons - -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. - lazy = false, - config = function() - require("oil").setup() - vim.keymap.set("n", "-", "Oil --float", { desc = "Open parent directory" }) - end, -} diff --git a/.config/nvim/lua/plugins/util/todo-comments.lua b/.config/nvim/lua/plugins/util/todo-comments.lua index e93c877..c166519 100644 --- a/.config/nvim/lua/plugins/util/todo-comments.lua +++ b/.config/nvim/lua/plugins/util/todo-comments.lua @@ -1,21 +1,16 @@ --- TODO Get todo-comments working +local utils = require("utils") return { "folke/todo-comments.nvim", event = { "BufReadPre", "BufNewFile" }, dependencies = { "nvim-lua/plenary.nvim" }, config = function() - local todo_comments = require("todo-comments") + utils.nmapkey("]t", function() + require("todo-comments").jump_next() + end, "Next todo comment (todo-comments)") + utils.nmapkey("[t", function() + require("todo-comments").jump_previous() + end, "Previous todo comment (todo-comments)") - -- Set keymaps - local keymap = vim.keymap - keymap.set("n", "]t", function() - todo_comments.jump_next() - end, { desc = "Next todo comment (todo-comments)" }) - - keymap.set("n", "[t", function() - todo_comments.jump_prev() - end, { desc = "Previous todo comment (todo-comments)" }) - - todo_comments.setup() + require("todo-comments").setup() end, } diff --git a/.config/nvim/lua/plugins/util/undotree.lua b/.config/nvim/lua/plugins/util/undotree.lua new file mode 100644 index 0000000..97cd0c2 --- /dev/null +++ b/.config/nvim/lua/plugins/util/undotree.lua @@ -0,0 +1,3 @@ +return { + "mbbill/undotree", +} diff --git a/.config/nvim/lua/plugins/util/util.lua b/.config/nvim/lua/plugins/util/util.lua deleted file mode 100644 index 495f327..0000000 --- a/.config/nvim/lua/plugins/util/util.lua +++ /dev/null @@ -1,14 +0,0 @@ --- Other utilities -return { - { - "lambdalisue/vim-suda", - config = function() - vim.keymap.set( - "n", - "sw", - "SudaWrite", - { desc = "Write the current file with sudo (vim-suda)" } - ) - end, - }, -} diff --git a/.config/nvim/lua/plugins/util/vim-suda.lua b/.config/nvim/lua/plugins/util/vim-suda.lua new file mode 100644 index 0000000..3c446dc --- /dev/null +++ b/.config/nvim/lua/plugins/util/vim-suda.lua @@ -0,0 +1,9 @@ +local utils = require("utils") +return { + { + "lambdalisue/vim-suda", + config = function() + utils.nmapkey("ws", "SudaWrite", "Write the current file with sudo (vim-suda)") + end, + }, +} diff --git a/.config/nvim/lua/plugins/util/which-key.lua b/.config/nvim/lua/plugins/util/which-key.lua index f438875..771de3e 100644 --- a/.config/nvim/lua/plugins/util/which-key.lua +++ b/.config/nvim/lua/plugins/util/which-key.lua @@ -2,11 +2,7 @@ return { { "folke/which-key.nvim", event = "VeryLazy", - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, + opts = {}, keys = { { "!", diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua index d9c636a..7cd50ff 100644 --- a/.config/nvim/lua/utils.lua +++ b/.config/nvim/lua/utils.lua @@ -32,4 +32,40 @@ function M.vmapkey(lhs, rhs, desc, bufopts) M.mapkey("v", lhs, rhs, desc, bufopts) end +--- Sets a non-recursive keymap for normal and visual mode. +---@param lhs string Left-hand side of the keymap. +---@param rhs string|function Right-hand side of the keymap. +---@param desc string|nil Description for the keymap. +---@param bufopts table|nil Additional options for the keymap. +function M.nvmapkey(lhs, rhs, desc, bufopts) + M.mapkey({ "n", "v" }, lhs, rhs, desc, bufopts) +end + +function M.common_mappings(opts) + local telescope = require("telescope.builtin") + M.nmapkey("gr", telescope.lsp_references, "[g]et [r]eferences", opts) + M.nmapkey("gd", telescope.lsp_definitions, "[g]et [d]definitions", opts) + M.nmapkey("gi", telescope.lsp_implementations, "[g]et [i]mplementations", opts) + M.nmapkey("gt", telescope.lsp_type_definitions, "[g]et [t]ype definitions", opts) + M.nmapkey("gD", vim.lsp.buf.declaration, "[g]o to [D]eclaration", opts) + M.nmapkey("K", vim.lsp.buf.hover, "Show do[K]umentation for what is under cursor", opts) + M.nmapkey("hh", vim.lsp.buf.signature_help, "Signature [hh]elp", opts) + + M.nmapkey("wa", vim.lsp.buf.add_workspace_folder, "[w]orkspace [a]dd folder", opts) + M.nmapkey("wr", vim.lsp.buf.remove_workspace_folder, "[w]orkspace [r]emove folder", opts) + M.nmapkey("wl", vim.lsp.buf.list_workspace_folders, "[w]orkspace [l]ist folder", opts) + M.nvmapkey("ca", vim.lsp.buf.code_action, "See available [c]ode [a]ctions", opts) + M.nmapkey("rn", vim.lsp.buf.rename, "Smart [r]e[n]ame", opts) + M.nmapkey("d", vim.diagnostic.open_float, "Show line [d]iagnostics", opts) + M.nmapkey("D", telescope.diagnostics, "Show buffer [D]iagnostics", opts) + M.nmapkey("[d", function() + vim.diagnostic.jump({ count = -1, float = true }) + end, "Go to previous diagnostic", opts) + M.nmapkey("]d", function() + vim.diagnostic.jump({ count = 1, float = true }) + end, "Go to next diagnostic", opts) + M.nmapkey("q", vim.diagnostic.setloclist, "Add buffer diagnostics to location list", opts) + M.nmapkey("rs", "LspRestart", "Restart LSP", opts) +end + return M diff --git a/.config/tmux/catppuccin.conf b/.config/tmux/catppuccin.conf deleted file mode 100644 index cc0136c..0000000 --- a/.config/tmux/catppuccin.conf +++ /dev/null @@ -1,35 +0,0 @@ -################## -### CATPPUCCIN ### -################## - -set -g @catppuccin_flavor "frappe" - -set -g status-right-length 100 -set -g status-left-length 100 - -# Window -set -g @catppuccin_window_status_style "rounded" - -run ~/.config/tmux/plugins/tmux/catppuccin.tmux - -## Window global/default configuration -set -g @catppuccin_window_text " #W" -set -g @catppuccin_window_status "icon" -set -g @catppuccin_window_default_fill "number" -set -g @catppuccin_window_number_position "left" - -## Window current configuration -set -g @catppuccin_window_current_text " #W" -set -g @catppuccin_window_current_fill "all" -set -g @catppuccin_window_current_number_color "#{@thm_maroon}" - -set -g @catppuccin_window_text_color "#{@thm_surface_0}" -set -g @catppuccin_window_number_color "#{@thm_rosewater}" - -# Status -set -gF status-left "" -set -gF status-right "#{@catppuccin_status_session}" -set -agF status-right "#{@catppuccin_status_directory}" -set -agF status-right "#{@catppuccin_status_user}" -set -agF status-right "#{@catppuccin_status_host}" -set -agF status-right "#{E:@catppuccin_status_date_time}" diff --git a/.config/tmux/scripts/cal.sh b/.config/tmux/scripts/cal.sh new file mode 100755 index 0000000..7ad23ad --- /dev/null +++ b/.config/tmux/scripts/cal.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +ALERT_IF_IN_NEXT_MINUTES=10 +ALERT_POPUP_BEFORE_SECONDS=10 +NERD_FONT_FREE="󱁕 " +NERD_FONT_MEETING="󰤙" + +get_attendees() { + attendees=$( + icalBuddy \ + --includeEventProps "attendees" \ + --propertyOrder "datetime,title" \ + --noCalendarNames \ + --dateFormat "%A" \ + --includeOnlyEventsFromNowOn \ + --limitItems 1 \ + --excludeAllDayEvents \ + --separateByDate \ + --excludeEndDates \ + --bullet "" \ + --excludeCals "training,omerxx@gmail.com" \ + eventsToday + ) +} + +parse_attendees() { + attendees_array=() + for line in $attendees; do + attendees_array+=("$line") + done + number_of_attendees=$((${#attendees_array[@]} - 3)) +} + +get_next_meeting() { + next_meeting=$(icalBuddy \ + --includeEventProps "title,datetime" \ + --propertyOrder "datetime,title" \ + --noCalendarNames \ + --dateFormat "%A" \ + --includeOnlyEventsFromNowOn \ + --limitItems 1 \ + --excludeAllDayEvents \ + --separateByDate \ + --bullet "" \ + --excludeCals "training,omerxx@gmail.com" \ + eventsToday) +} + +get_next_next_meeting() { + end_timestamp=$(date +"%Y-%m-%d ${end_time}:01 %z") + tonight=$(date +"%Y-%m-%d 23:59:00 %z") + next_next_meeting=$( + icalBuddy \ + --includeEventProps "title,datetime" \ + --propertyOrder "datetime,title" \ + --noCalendarNames \ + --dateFormat "%A" \ + --limitItems 1 \ + --excludeAllDayEvents \ + --separateByDate \ + --bullet "" \ + --excludeCals "training,omerxx@gmail.com" \ + eventsFrom:"${end_timestamp}" to:"${tonight}" + ) +} + +parse_result() { + array=() + for line in $1; do + array+=("$line") + done + time="${array[2]}" + end_time="${array[4]}" + title="${array[*]:5:30}" +} + +calculate_times() { + epoc_meeting=$(date -j -f "%T" "$time:00" +%s) + epoc_now=$(date +%s) + epoc_diff=$((epoc_meeting - epoc_now)) + minutes_till_meeting=$((epoc_diff / 60)) +} + +display_popup() { + tmux display-popup \ + -S "fg=#eba0ac" \ + -w50% \ + -h50% \ + -d '#{pane_current_path}' \ + -T meeting \ + icalBuddy \ + --propertyOrder "datetime,title" \ + --noCalendarNames \ + --formatOutput \ + --includeEventProps "title,datetime,notes,url,attendees" \ + --includeOnlyEventsFromNowOn \ + --limitItems 1 \ + --excludeAllDayEvents \ + --excludeCals "training" \ + eventsToday +} + +print_tmux_status() { + if [[ $minutes_till_meeting -lt $ALERT_IF_IN_NEXT_MINUTES && + $minutes_till_meeting -gt -60 ]]; then + echo "$NERD_FONT_MEETING \ + $time $title ($minutes_till_meeting minutes)" + else + echo "$NERD_FONT_FREE" + fi + + if [[ $epoc_diff -gt $ALERT_POPUP_BEFORE_SECONDS && epoc_diff -lt $ALERT_POPUP_BEFORE_SECONDS+10 ]]; then + display_popup + fi +} + +main() { + get_attendees + parse_attendees + get_next_meeting + parse_result "$next_meeting" + calculate_times + if [[ "$next_meeting" != "" && $number_of_attendees -lt 2 ]]; then + get_next_next_meeting + parse_result "$next_next_meeting" + calculate_times + fi + print_tmux_status + # echo "$minutes_till_meeting | $number_of_attendees" +} + +main diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 00da689..2b535be 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -1,81 +1,26 @@ -############### -### PLUGINS ### -############### - -set -g default-terminal "tmux-256color" - -set -g @plugin 'catppuccin/tmux#v2.1.3' -set -g @plugin 'tmux-plugins/tmux-sensible' -set -g @plugin 'tmux-plugins/tpm' - - -################ -### BINDINGS ### -################ - -### PREFIXED ### - -# r : RELOAD -bind r source-file ~/.config/tmux/tmux.conf - -# | : HORIZONTAL SPLIT -bind | split-window -h - -# - : VERTICAL SPLIT -bind - split-window -v - -# X : KILL PANE -bind X kill-pane - -# Alt-arrow : RESIZE 1 ROW -bind M-Left resize-pane -L 1 \; switch-client -T prefix -bind M-Down resize-pane -D 1 \; switch-client -T prefix -bind M-Up resize-pane -U 1 \; switch-client -T prefix -bind M-Right resize-pane -R 1 \; switch-client -T prefix - -# C-arrow : RESIZE 5 ROWS -bind C-Left resize-pane -L 5 \; switch-client -T prefix -bind C-Down resize-pane -D 5 \; switch-client -T prefix -bind C-Up resize-pane -U 5 \; switch-client -T prefix -bind C-Right resize-pane -R 5 \; switch-client -T prefix - -# Alt-c : CHANGE SESSION ROOT DIR -bind M-c attach-session -c "#{pane_current_path}" - - -### UNPREFIXED ### - -# Alt-arrow : SWITCH PANES -bind -n M-Left select-pane -L -bind -n M-Down select-pane -D -bind -n M-Up select-pane -U -bind -n M-Right select-pane -R - -# Alt-hjkl : SWITCH PANES -bind -n M-h select-pane -L -bind -n M-j select-pane -D -bind -n M-k select-pane -U -bind -n M-l select-pane -R - -# Alt-z : FULL SCREEN -bind -n M-z resize-pane -Z - - ################ ### SETTINGS ### ################ -# Enable mouse +set -g default-terminal "screen-256color" +set -g terminal-overrides ",xterm-256color:RGB" + +set -g prefix ^B +set -g base-index 1 # start indexing windows at 1 instead of 0 +set -g detach-on-destroy off # don't exit from tmux when closing a session +set -g escape-time 0 # zero-out escape time delay +set -g history-limit 1000000 # increase history size (from 2,000) +set -g renumber-windows on # renumber all windows when any window is closed +set -g set-clipboard on # use system clipboard +set -g status-position top # macOS / darwin style +set -g default-terminal "${TERM}" +set -g pane-active-border-style "fg=magenta,bg=default" +set -g pane-border-style "fg=brightblack,bg=default" + set -g mouse on - -# Don't rename windows automatically -set-option -g allow-rename off - -# Don't do anything when a 'bell' rings +set -g allow-rename off set -g visual-activity off -set -g visual-bell off set -g visual-silence off -setw -g monitor-activity off set -g bell-action none @@ -83,27 +28,34 @@ set -g bell-action none ### VI MODE COPYING ### ####################### -# Enable Vi keybindings in copy mode -set-window-option -g mode-keys vi +setw -g mode-keys vi -# Bind 'v' to start selection in copy mode +# Bind "v" to start selection (unchanged) bind-key -T copy-mode-vi v send -X begin-selection -# Bind 'y' to copy the selection to the system clipboard -bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel +# Bind "y" to copy selection to system clipboard (xclip) +bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -in -selection clipboard" -# Bind 'Y' to copy the entire buffer to the system clipboard -bind-key -T copy-mode-vi Y send -X copy-pipe-and-cancel +# Bind "Y" to copy entire visible buffer to system clipboard +bind-key -T copy-mode-vi Y send -X copy-pipe-and-cancel "xclip -in -selection clipboard" +# Bind "Enter" to copy selection (like "y") and exit copy mode +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard" + +# Optional: Bind "p" to paste from system clipboard into tmux +bind-key p run-shell "xclip -out -selection clipboard | tmux load-buffer - && tmux paste-buffer" ############ ### LOAD ### ############ -# Catppuccin conf -source-file ~/.config/tmux/catppuccin.conf +# Load plugins & plugin settings +source-file ~/.config/tmux/tmux.plugins.conf -# Local conf if using +# Load keybindings +source-file ~/.config/tmux/tmux.keybindings.conf + +# Load local configuration if given if-shell "[ -f ~/.config/tmux/local.tmux.conf ]" "source-file ~/.config/tmux/local.tmux.conf" # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) diff --git a/.config/tmux/tmux.keybindings.conf b/.config/tmux/tmux.keybindings.conf new file mode 100644 index 0000000..dbf9622 --- /dev/null +++ b/.config/tmux/tmux.keybindings.conf @@ -0,0 +1,52 @@ +################ +### PREFIXED ### +################ + +bind R source-file ~/.config/tmux/tmux.conf + +bind "\"" split-window -v -c "#{pane_current_path}" +bind - split-window -v -l 12 -c "#{pane_current_path}" +bind | split-window -h -l 60 -c "#{pane_current_path}" + +bind C command-prompt 'neww -n %%' +bind a command-prompt "new-session -A -s %%" + +bind r command-prompt "rename-window %%" +bind e command-prompt "rename-session %%" + +bind X kill-pane + +# C-arrow : RESIZE 20 ROWS +bind C-Left resize-pane -L 10 \; switch-client +bind C-Down resize-pane -D 10 \; switch-client +bind C-Up resize-pane -U 10 \; switch-client +bind C-Right resize-pane -R 10 \; switch-client + +# Alt-arrow : RESIZE 7 ROWS +bind M-Left resize-pane -L 7 \; switch-client +bind M-Down resize-pane -D 7 \; switch-client +bind M-Up resize-pane -U 7 \; switch-client +bind M-Right resize-pane -R 7 \; switch-client + +# Alt-c : CHANGE SESSION ROOT DIR +bind M-c attach-session -c "#{pane_current_path}" + + +################## +### UNPREFIXED ### +################## + +# Alt-arrow : SWITCH PANES +bind -n M-Left select-pane -L +bind -n M-Down select-pane -D +bind -n M-Up select-pane -U +bind -n M-Right select-pane -R + +# Alt-hjkl : SWITCH PANES +bind -n M-h select-pane -L +bind -n M-j select-pane -D +bind -n M-k select-pane -U +bind -n M-l select-pane -R + +# Alt-z : FULL SCREEN +bind -n M-z resize-pane -Z diff --git a/.config/tmux/tmux.plugins.conf b/.config/tmux/tmux.plugins.conf new file mode 100644 index 0000000..22a2b62 --- /dev/null +++ b/.config/tmux/tmux.plugins.conf @@ -0,0 +1,73 @@ + +set -g @fzf-url-fzf-options '-p 60%,30% --prompt=" " --border-label=" Open URL "' +set -g @fzf-url-history-limit "2000" + +set -g @floax-width "80%" +set -g @floax-height "80%" +set -g @floax-border-color "magenta" +set -g @floax-text-color "blue" +set -g @floax-bind "p" +set -g @floax-change-path "true" + +set -g @continuum-restore "on" +set -g @resurrect-strategy-nvim "session" + +################## +### CATPPUCCIN ### +################## + +set -g @catppuccin_flavor "frappe" + +set -g status-right-length 100 +set -g status-left-length 100 + +# Window +set -g @catppuccin_window_status_style "rounded" +set -g @catppuccin_window_status "icon" + +set -g @catppuccin_window_current_fill "all" +set -g @catppuccin_window_current_number_color "#{@thm_blue}" + +set -g @catppuccin_window_text_color "#{@thm_surface_0}" +set -g @catppuccin_window_number_color "#{@thm_overlay_0}" + +set -g @catppuccin_window_text "#W" +set -g @catppuccin_window_number_position "right" +set -g @catppuccin_window_default_fill "number" +set -g @catppuccin_window_default_text "#W" +set -g @catppuccin_window_current_fill "number" +set -g @catppuccin_window_current_text "#{?window_zoomed_flag, ,}#W" + +set -g @catppuccin_status_fill "icon" +set -g @catppuccin_date_time_text " %a %d %b %Y %H:%M %Z" +set -g @catppuccin_directory_text " #{b:pane_current_path}" +set -gF status-left "  " +set -gF status-right "#{@catppuccin_status_session}" +set -agF status-right "#{@catppuccin_status_directory}" +set -agF status-right "#{@catppuccin_status_user}" +set -agF status-right "#{@catppuccin_status_host}" +set -agF status-right "#{E:@catppuccin_status_date_time}" + +set -g @catppuccin_meetings_text "#($HOME/.config/tmux/scripts/cal.sh)" + +############### +### PLUGINS ### +############### + +set -g @plugin "catppuccin/tmux#v2.1.3" +set -g @plugin "tmux-plugins/tpm" +set -g @plugin "tmux-plugins/tmux-sensible" +set -g @plugin "tmux-plugins/tmux-yank" +set -g @plugin "tmux-plugins/tmux-resurrect" +set -g @plugin "tmux-plugins/tmux-continuum" +# set -g @plugin "fcsonline/tmux-thumbs" +# set -g @plugin "sainnhe/tmux-fzf" +# set -g @plugin "wfxr/tmux-fzf-url" +# set -g @plugin "omerxx/tmux-floax" +# set -g @plugin "ThePrimeagen/tmux-sessionizer" +# +# bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer" +# bind-key -r M-h run-shell "tmux neww tmux-sessionizer -s 0" +# bind-key -r M-t run-shell "tmux neww tmux-sessionizer -s 1" +# bind-key -r M-n run-shell "tmux neww tmux-sessionizer -s 2" +# bind-key -r M-s run-shell "tmux neww tmux-sessionizer -s 3" diff --git a/.config/tmux/tmux.reset.conf b/.config/tmux/tmux.reset.conf new file mode 100644 index 0000000..783e24c --- /dev/null +++ b/.config/tmux/tmux.reset.conf @@ -0,0 +1,40 @@ +# First remove *all* keybindings +# unbind-key -a +# Now reinsert all the regular tmux keys +# bind ^X lock-server +# bind ^C new-window -c "$HOME" +# bind ^D detach +# bind * list-clients +# +# bind H previous-window +# bind L next-window +# +# bind r command-prompt "rename-window %%" +# bind R source-file ~/.config/tmux/tmux.conf +# bind ^A last-window +# bind ^W list-windows +# bind w list-windows +# bind z resize-pane -Z +# bind ^L refresh-client +# bind l refresh-client +# bind | split-window +# bind s split-window -v -c "#{pane_current_path}" +# bind v split-window -h -c "#{pane_current_path}" +# bind '"' choose-window +# bind h select-pane -L +# bind j select-pane -D +# bind k select-pane -U +# bind l select-pane -R +# bind -r -T prefix , resize-pane -L 20 +# bind -r -T prefix . resize-pane -R 20 +# bind -r -T prefix - resize-pane -D 7 +# bind -r -T prefix = resize-pane -U 7 +# bind : command-prompt +# bind * setw synchronize-panes +# bind P set pane-border-status +# bind c kill-pane +# bind x swap-pane -D +# bind S choose-session +# bind R source-file ~/.config/tmux/tmux.conf +# bind K send-keys "clear"\; send-keys "Enter" +# bind-key -T copy-mode-vi v send-keys -X begin-selection diff --git a/.zinit.zsh b/.zinit.zsh index dbde73f..222f5f1 100644 --- a/.zinit.zsh +++ b/.zinit.zsh @@ -2,10 +2,12 @@ ### INSTALL ZINIT ### ##################### -if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" + +if [[ ! -f "${ZINIT_HOME}/zinit.zsh" ]]; then print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" - command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" - command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ + command mkdir -p "$(dirname $ZINIT_HOME)" && command chmod g-rwX "$(dirname $ZINIT_HOME)" + command git clone https://github.com/zdharma-continuum/zinit "$ZINIT_HOME" && \ print -P "%F{33} %F{34}Installation successful.%f%b" || \ print -P "%F{160} The clone has failed.%f%b" fi @@ -28,6 +30,19 @@ zinit ice depth=1; zinit light romkatv/powerlevel10k ### PLUGINS ### ############### +# AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD +ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 +zinit ice wait"0a" lucid atload"_zsh_autosuggest_start" +zinit light zsh-users/zsh-autosuggestions + +#SYNTAX HIGHLIGHTING +zinit ice wait"0c" lucid atinit"zpcompinit;zpcdreplay" +zinit light zdharma-continuum/fast-syntax-highlighting + +# TAB COMPLETIONS +zinit ice wait"0b" lucid blockf +zinit light zsh-users/zsh-completions + # FZF zinit ice from"gh-r" as"command" bpick"*linux_amd64*" zinit light junegunn/fzf @@ -44,24 +59,38 @@ zinit light junegunn/fzf zinit ice wait="1" lucid zinit light Aloxaf/fzf-tab -# AUTOSUGGESTIONS, TRIGGER PRECMD HOOK UPON LOAD -ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 -zinit ice wait"0a" lucid atload"_zsh_autosuggest_start;bindkey \"^[[A\" history-search-backward;bindkey \"^[[B\" history-search-forward" -zinit light zsh-users/zsh-autosuggestions - -# # ENHANCED +# ENHANCD zinit ice wait="0b" lucid -zinit light b4b4r07/enhanced +zinit light babarot/enhancd export ENHANCD_FILTER=fzf:fzy:peco -#SYNTAX HIGHLIGHTING -zinit ice wait"0c" lucid atinit"zpcompinit;zpcdreplay" -zinit light zdharma-continuum/fast-syntax-highlighting - # ZOXIDE zinit ice wait"0a" lucid from"gh-r" as"program" pick"zoxide-*/zoxide -> zoxide" cp"zoxide-*/completions/_zoxide -> _zoxide" atclone"./zoxide init zsh > init.zsh" atpull"%atclone" src"init.zsh" zinit light ajeetdsouza/zoxide -# TAB COMPLETIONS -zinit ice wait="0b" lucid blockf -zinit light zsh-users/zsh-completions +# EZA +zinit ice wait lucid from'gh-r' id-as as'completion' bpick'man-*' atpull'%atclone' atclone' + local VERSION=$(ls target | sed "s/man-//") + if [[ "$(uname -s)" = "Darwin"* ]]; then + local -A ICE=(ver eza-$VERSION) + .zinit-get-latest-gh-r-url-part cargo-bins cargo-quickinstall + else + local -A ICE=(bpick "eza*") + .zinit-get-latest-gh-r-url-part eza-community eza + fi + [ -n "$reply" ] && wget https://github.com/$reply -O eza.tar.gz && tar -xzf eza.tar.gz && rm -f eza.tar.gz && ln -svf $PWD/eza $ZPFX/bin + wget https://raw.githubusercontent.com/eza-community/eza/main/completions/zsh/_eza -O _eza + for man in $PWD/target/*/*.1; do ln -svf $man $ZPFX/man/man1; done + for man in $PWD/target/*/*.5; do ln -svf $man $ZPFX/man/man5; done' +zinit light eza-community/eza + +################ +### SNIPPETS ### +################ + +zinit snippet OMZP::git +zinit snippet OMZP::sudo +zinit snippet OMZP::command-not-found + +# replay cached completions +zinit cdreplay -q diff --git a/.zshrc b/.zshrc index 0e92f15..d15d050 100644 --- a/.zshrc +++ b/.zshrc @@ -1,7 +1,3 @@ -if [[ ! $(tmux ls) ]] 2> /dev/null; then - tmux new -s λ -fi - ############ ### P10K ### ############ @@ -23,10 +19,16 @@ source ~/.zstyle.zsh ### PATHS ### ############# +# local bin +export PATH=$HOME/.local/bin:$PATH + # n export N_PREFIX=$HOME/.n export PATH=$N_PREFIX/bin:$PATH +# ghcup-env +[ -f "/home/iborrelli/.ghcup/env" ] && . "/home/iborrelli/.ghcup/env" + ##################### ### ENV VARIABLES ### ##################### @@ -35,25 +37,60 @@ export SUDO_EDITOR="nvim" export EDITOR="nvim" export VISUAL="nvim" +############### +### HISTORY ### +############### + HISTSIZE=10000 SAVEHIST=50000 HISTFILE=${XDG_STATE_HOME:-$HOME/.local/state}/.zsh_history +HISTDUP=erase +setopt appendhistory +setopt sharehistory +setopt hist_ignore_space +setopt hist_ignore_all_dups +setopt hist_save_no_dups +setopt hist_ignore_all_dups +setopt hist_find_no_dups ############### ### ALIASES ### ############### alias svim="sudo -E -s nvim" -alias dots='/usr/bin/git --git-dir=$HOME/.git/ --work-tree=$HOME' +alias dots="/usr/bin/git --git-dir=$HOME/.git/ --work-tree=$HOME" alias vim="nvim" alias vi="nvim" alias python="python3" +alias ls="ls --color" +alias c="clear" +alias bat=batcat +alias cat=bat + +################### +### KEYBINDINGS ### +################### + +bindkey -v # If wsl.conf exists we're probably in WSL and need some changes for terminal commands to work correctly [[ ! -f /etc/wsl.conf ]] || source ~/.wslrc.zsh +[[ $(uname -a) =~ 'Ubuntu' ]] && source ~/.ubunturc.zsh [[ ! -f ~/.localrc.zsh ]] || source ~/.localrc.zsh -eval $(thefuck --alias) +# >>> conda initialize >>> +# !! Contents within this block are managed by 'conda init' !! +__conda_setup="$('/home/iborrelli/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" +if [ $? -eq 0 ]; then + eval "$__conda_setup" +else + if [ -f "/home/iborrelli/miniconda3/etc/profile.d/conda.sh" ]; then + . "/home/iborrelli/miniconda3/etc/profile.d/conda.sh" + else + export PATH="/home/iborrelli/miniconda3/bin:$PATH" + fi +fi +unset __conda_setup +# <<< conda initialize <<< -[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh diff --git a/.zstyle.zsh b/.zstyle.zsh index 3852d66..3d4efa6 100644 --- a/.zstyle.zsh +++ b/.zstyle.zsh @@ -2,65 +2,66 @@ ### COMPLETIONS ### ################### -compctl -g '~/.teamocil/*(:t:r)' teamocil +# man zshcompsys # Specify the order of completers to use: # - `_expand`: Expand variables and globs. # - `_complete`: Standard completion. # - `_ignored`: Ignore certain completions. # - `_approximate`: Approximate matching for fuzzy completions. -zstyle ':completion:*' completer _expand _complete _ignored _approximate +zstyle ":completion:*" completer _expand _complete _ignored _approximate # Enable case-insensitive matching -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' +zstyle ":completion:*" matcher-list "m:{a-z}={A-Z}" -# Disable the menu selection feature (automatically select the first match) +# Wrap descriptions in square brackets. + zstyle ":completion:*:descriptions" format "[%d]" -# Customize the prompt shown when scrolling through completions -# - `%SScrolling active: current selection at %p%s`: Shows a message indicating that scrolling is active and the current selection. -zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' +# List processes for the current user when completing process names. +zstyle ":completion:*:processes" command "ps -au$USER" -# Format descriptions in completion lists -# - `[%d]`: Wrap descriptions in square brackets. - zstyle ':completion:*:descriptions' format '[%d]' - -# Specify the command to use for completing process names -# - `ps -au$USER`: List processes for the current user. -zstyle ':completion:*:processes' command 'ps -au$USER' - -# Specify the command to use for completing process names with fzf-tab -# - `ps -u $USER -o pid,user,comm,cmd -w -w`: List processes with detailed information. -zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w" - -# Disable sorting of completion options -zstyle ':completion:complete:*:options' sort false +# List processes with detailed information when completing processes with fzf-tab. +zstyle ":completion:*:*:*:*:processes" command "ps -u $USER -o pid,user,comm,cmd -w -w" # Apply LS_COLORS to completion lists for colored output -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS} + +zstyle ":completion:*:matches" group "yes" +zstyle ":completion:*:corrections" format "%U%F{red}-- %d (errors: %e) --%f%u" +zstyle ":completion:*:descriptions" format "%U%F{yellow}-- %d --%f%u" +zstyle ":completion:*:messages" format "%F{purple} -- %d --%f" +zstyle ":completion:*:warnings" format "%F{red} -- no matches found --%f" + +# Disable sorting of completion options +zstyle ":completion:complete:*:options" sort false +zstyle ":completion:*:options" description "yes" +zstyle ":completion:*:options" auto-description "%d" + +######################### +### FZF TAB BEHAVIOUR ### +######################### + +# Use default fzf options for fzf-tab +zstyle ":fzf-tab:*" use-fzf-default-opts yes -zstyle ':completion:*:matches' group 'yes' -zstyle ':completion:*:options' description 'yes' -zstyle ':completion:*:options' auto-description '%d' -zstyle ':completion:*:corrections' format '%U%F{red}-- %d (errors: %e) --%f%u' -zstyle ':completion:*:descriptions' format '%U%F{yellow}-- %d --%f%u' -zstyle ':completion:*:messages' format '%F{purple} -- %d --%f' -zstyle ':completion:*:warnings' format '%F{red} -- no matches found --%f' -# -# Configure fzf-tab behavior # Use the input string as the query string for _zlua completions -zstyle ':fzf-tab:complete:_zlua:*' query-string input +zstyle ":fzf-tab:complete:_zlua:*" query-string input # Customize the kill command completion with fzf-tab # - `extra-opts`: Additional options for fzf, including a preview window showing the command of the selected process. -zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap +zstyle ":fzf-tab:complete:kill:argument-rest" extra-opts --preview=$extract"ps --pid=$in[(w)1] -o cmd --no-headers -w -w" --preview-window=down:3:wrap # Customize the cd command completion with fzf-tab -# - `fzf-preview`: Show a preview of directories using `eza` (a modern replacement for `ls`). -zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' +zstyle ":fzf-tab:complete:cd:*" fzf-preview "eza -1 --color $realpath" # Customize the z command completion with fzf-tab -# - `fzf-preview`: Show a preview of directories using `eza`. -zstyle ':fzf-tab:complete:z:*' fzf-preview 'eza -1 --color=always $realpath' +zstyle ":fzf-tab:complete:z:*" fzf-preview "eza -1 --color $realpath" + +########################## +### CUSTOM COMPLETIONS ### +########################## + +# man zshcompctl + +compctl -g "~/.teamocil/*(:t:r)" teamocil -# Use default fzf options for fzf-tab -zstyle ':fzf-tab:*' use-fzf-default-opts yes