From f9ab04cd0a35c9b9c04be3cd20cc83a0476af104 Mon Sep 17 00:00:00 2001 From: ItaloBorrelli Date: Wed, 21 May 2025 16:25:20 -0700 Subject: [PATCH] Update nvim --- .config/nvim/init.lua | 6 + .config/nvim/lua/config/lazy.lua | 4 +- .config/nvim/lua/keybindings.lua | 3 + .../lua/plugins/file_navigation/neo-tree.lua | 42 +++++ .../lua/plugins/file_navigation/telescope.lua | 46 +++++ .../lua/plugins/language_support/conform.lua | 38 ++++ .../lua/plugins/language_support/neotest.lua | 17 ++ .../lua/plugins/language_support/nvim-cmp.lua | 142 +++++++++++++++ .../language_support/nvim-treesitter.lua | 47 +++++ .config/nvim/lua/plugins/lsp/mason.lua | 56 ++++++ .config/nvim/lua/plugins/lsp/nvim-jdtls.lua | 3 + .../nvim/lua/plugins/lsp/nvim-lspconfig.lua | 148 +++++++++++++++ .config/nvim/lua/plugins/theme.lua | 30 ++- .config/nvim/lua/plugins/ui/barbar.lua | 61 +++++++ .config/nvim/lua/plugins/ui/dressing.lua | 172 ++++++++++++++++++ .config/nvim/lua/plugins/ui/lualine.lua | 29 +++ .../nvim/lua/plugins/util/auto-session.lua | 21 +++ .../nvim/lua/plugins/util/mini.surround.lua | 7 + .config/nvim/lua/plugins/util/neogit.lua | 12 ++ .config/nvim/lua/plugins/util/nvim-notify.lua | 7 + .config/nvim/lua/plugins/util/oil.lua | 15 ++ .../nvim/lua/plugins/util/todo-comments.lua | 21 +++ .config/nvim/lua/plugins/util/trouble.lua | 39 ++++ .config/nvim/lua/plugins/util/util.lua | 14 ++ .../nvim/lua/plugins/util/vim-maximizer.lua | 6 + .config/nvim/lua/plugins/util/which-key.lua | 27 +++ .config/nvim/lua/settings.lua | 5 +- .gitignore | 2 +- .zshrc | 2 +- 29 files changed, 1008 insertions(+), 14 deletions(-) create mode 100644 .config/nvim/lua/plugins/file_navigation/neo-tree.lua create mode 100644 .config/nvim/lua/plugins/file_navigation/telescope.lua create mode 100644 .config/nvim/lua/plugins/language_support/conform.lua create mode 100644 .config/nvim/lua/plugins/language_support/neotest.lua create mode 100644 .config/nvim/lua/plugins/language_support/nvim-cmp.lua create mode 100644 .config/nvim/lua/plugins/language_support/nvim-treesitter.lua create mode 100644 .config/nvim/lua/plugins/lsp/mason.lua create mode 100644 .config/nvim/lua/plugins/lsp/nvim-jdtls.lua create mode 100644 .config/nvim/lua/plugins/lsp/nvim-lspconfig.lua create mode 100644 .config/nvim/lua/plugins/ui/barbar.lua create mode 100644 .config/nvim/lua/plugins/ui/dressing.lua create mode 100644 .config/nvim/lua/plugins/ui/lualine.lua create mode 100644 .config/nvim/lua/plugins/util/auto-session.lua create mode 100644 .config/nvim/lua/plugins/util/mini.surround.lua create mode 100644 .config/nvim/lua/plugins/util/neogit.lua create mode 100644 .config/nvim/lua/plugins/util/nvim-notify.lua create mode 100644 .config/nvim/lua/plugins/util/oil.lua create mode 100644 .config/nvim/lua/plugins/util/todo-comments.lua create mode 100644 .config/nvim/lua/plugins/util/trouble.lua create mode 100644 .config/nvim/lua/plugins/util/util.lua create mode 100644 .config/nvim/lua/plugins/util/vim-maximizer.lua create mode 100644 .config/nvim/lua/plugins/util/which-key.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 3b5b3d3..15a794f 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -4,6 +4,12 @@ vim.g.maplocalleader = "\\" -- Initialize lazy.nvim require("config.lazy") +-- vim.cmd([[ +-- augroup jdtls_lsp +-- autocmd! +-- autocmd FileType java lua require'jdtls.jdtls_setup'.setup() +-- augroup end +-- ]]) -- Source other configuration files require("keybindings") diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index e3211f5..5b7c0ce 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -30,8 +30,8 @@ require("lazy").setup({ -- colorscheme that will be used when installing plugins. install = { colorscheme = { "habamax" } }, - -- automatically check for plugin updates - checker = { enabled = true }, + -- automatically check for plugin updates, but don't notify during startup + checker = { enabled = true, notify = false }, -- don't notify on changes to configs change_detection = { enabled = false }, }) diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua index 9d055d0..c95a8c3 100644 --- a/.config/nvim/lua/keybindings.lua +++ b/.config/nvim/lua/keybindings.lua @@ -12,3 +12,6 @@ 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) diff --git a/.config/nvim/lua/plugins/file_navigation/neo-tree.lua b/.config/nvim/lua/plugins/file_navigation/neo-tree.lua new file mode 100644 index 0000000..57dd27d --- /dev/null +++ b/.config/nvim/lua/plugins/file_navigation/neo-tree.lua @@ -0,0 +1,42 @@ +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + 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 + keymap.set( + "n", + "ee", + "Neotree focus", + { desc = "Open and focus Neotree", noremap = true, silent = true } + ) + keymap.set( + "n", + "e", + "Neotree toggle", + { desc = "Toggle Neotree", noremap = true, silent = true } + ) + keymap.set( + "n", + "eq", + "Neotree close", + { desc = "Close Neotree", noremap = true, silent = true } + ) + end, + }, +} diff --git a/.config/nvim/lua/plugins/file_navigation/telescope.lua b/.config/nvim/lua/plugins/file_navigation/telescope.lua new file mode 100644 index 0000000..229806f --- /dev/null +++ b/.config/nvim/lua/plugins/file_navigation/telescope.lua @@ -0,0 +1,46 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "folke/todo-comments.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, -- fuzzy search + }, + config = function() + local telescope = require("telescope") + local trouble_telescope = require("trouble.sources.telescope") + local actions = require("telescope.actions") + local open_with_trouble = require("trouble.sources.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 = { + mappings = { + i = { + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = trouble_telescope.open, + }, + 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", { desc = "Fuzzy find recent files (Telescope)" }) + keymap.set("n", "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)" }) + end, +} diff --git a/.config/nvim/lua/plugins/language_support/conform.lua b/.config/nvim/lua/plugins/language_support/conform.lua new file mode 100644 index 0000000..dbcd951 --- /dev/null +++ b/.config/nvim/lua/plugins/language_support/conform.lua @@ -0,0 +1,38 @@ +return { + "stevearc/conform.nvim", + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + lua = { "stylua" }, + nginx = { "nginxfmt" }, + python = { "black" }, + yaml = { "yamlfix" }, + -- Use the "*" filetype to run formatters on all filetypes. + -- ["*"] = { "codespell" }, + }, + + default_format_opts = { + lsp_format = "fallback", + }, + format_on_save = { + lua = true, + nginx = true, + yaml = true, + lsp_format = "fallback", + timeout_ms = 500, + }, + format_after_save = { + lsp_format = "fallback", + timeout_ms = 500, + }, + -- Set the log level. Use `:ConformInfo` to see the location of the log file. + log_level = vim.log.levels.ERROR, + -- Conform will notify you when a formatter errors + notify_on_error = true, + -- Conform will notify you when no formatters are available for the buffer + notify_no_formatters = true, + }) + end, +} diff --git a/.config/nvim/lua/plugins/language_support/neotest.lua b/.config/nvim/lua/plugins/language_support/neotest.lua new file mode 100644 index 0000000..c701fa2 --- /dev/null +++ b/.config/nvim/lua/plugins/language_support/neotest.lua @@ -0,0 +1,17 @@ +return { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", + "rcasia/neotest-java", + }, + config = function() + require("neotest").setup({ + adapters = { + require("neotest-java"), + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/language_support/nvim-cmp.lua b/.config/nvim/lua/plugins/language_support/nvim-cmp.lua new file mode 100644 index 0000000..ff9783a --- /dev/null +++ b/.config/nvim/lua/plugins/language_support/nvim-cmp.lua @@ -0,0 +1,142 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "hrsh7th/cmp-cmdline", -- source for command mode + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + { + "L3MON4D3/LuaSnip", + -- follow latest release of given major + version = "v2.*", + -- install jsregexp + build = "make install_jsregexp", + }, -- snippet engine + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + -- Loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + -- `/` cmdline setup. + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- `:` cmdline setup. + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { + name = "cmdline", + option = { + ignore_cmds = { "Man", "!" }, + }, + }, + }), + }) + + -- Setup completion options and snippets and mappings + cmp.setup({ + -- Configure how the completion menu behaves + -- menu: show menu + -- menuone: show menu even when there is only one option + -- preview: preview window explaining the offered completion + -- select: select an option automatically (noselect is the reverse) + completion = { + completeopt = "menu,menuone,preview,select", + }, + -- Configure how nvim-cmp interacts with snippet engine + snippet = { + expand = function(args) + 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 + [""] = cmp.mapping.complete({ + config = { sources = { + { name = "nvim_lsp" }, + } }, + }), -- show only lsp completions + [""] = 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() + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + 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() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s", "c" }), + }), + + -- Sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- lsp suggestions + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + + -- Configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + show_labelDetails = true, + }), + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/language_support/nvim-treesitter.lua b/.config/nvim/lua/plugins/language_support/nvim-treesitter.lua new file mode 100644 index 0000000..e4ba229 --- /dev/null +++ b/.config/nvim/lua/plugins/language_support/nvim-treesitter.lua @@ -0,0 +1,47 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "css", + "dockerfile", + "html", + "javascript", + "json", + "lua", + "make", + "pug", + "scss", + "typescript", + "vim", + "vimdoc", + "vue", + "yaml", + }, + modules = {}, + auto_install = false, + ignore_install = {}, + highlight = { enable = true }, + indent = { enable = true }, + sync_install = false, + }) + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "java", + }, + modules = {}, + auto_install = false, + ignore_install = {}, + highlight = { enable = true }, + indent = { enable = true }, + sync_install = false, + custom_captures = { + -- Highlight @Test annotations + ["annotation.identifier"] = "TSAnnotation", + }, + }) + end, + }, +} diff --git a/.config/nvim/lua/plugins/lsp/mason.lua b/.config/nvim/lua/plugins/lsp/mason.lua new file mode 100644 index 0000000..80003c3 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp/mason.lua @@ -0,0 +1,56 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "WhoIsSethDaniel/mason-tool-installer.nvim", + "williamboman/mason-lspconfig.nvim", + }, + config = function() + -- enable mason and configure icons + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + require("mason-lspconfig").setup({ + ensure_installed = { + "cssls", + "dockerls", + "emmet_ls", + "html", + "jdtls", + "jsonls", + "lua_ls", + "pylsp", + "ts_ls", + "vimls", + "yamlls", + }, + }) + + -- formatters, linters and debug adapters for mason to install + require("mason-tool-installer").setup({ + ensure_installed = { + "biome", + "black", + "checkstyle", + "chrome-debug-adapter", + "codespell", + "eslint_d", + "firefox-debug-adapter", + "flake8", + "java-debug-adapter", + "jq", + "nginx-config-formatter", + "prettierd", + "stylua", + "yamlfix", + "yamllint", + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/lsp/nvim-jdtls.lua b/.config/nvim/lua/plugins/lsp/nvim-jdtls.lua new file mode 100644 index 0000000..e8e72d1 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp/nvim-jdtls.lua @@ -0,0 +1,3 @@ +return { + "mfussenegger/nvim-jdtls", +} diff --git a/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua new file mode 100644 index 0000000..2a09ef2 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp/nvim-lspconfig.lua @@ -0,0 +1,148 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + { "folke/neodev.nvim", opts = {} }, + }, + config = function() + -- Replace symbols to use for diagnostics + vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.HINT] = "󰠠 ", + [vim.diagnostic.severity.INFO] = " ", + }, + }, + }) + -- + -- Create keymaps when using an LSP + local keymap = vim.keymap + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local opts = { buffer = ev.buf, silent = true } + + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", function() + vim.diagnostic.jump({ count = -1, float = true }) + end, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", function() + vim.diagnostic.jump({ count = 1, float = true }) + end, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary + end, + }) + + -- Enable autocompletion capabilities + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + -- Configure for language servers + -- lua_ls + vim.lsp.config("lua_ls", { + 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", + }, + }, + -- Add the default completion capabilities + capabilities = capabilities, + }) + end, + settings = { + Lua = {}, + }, + }) + + -- ts_ls + vim.lsp.config("ts_ls", { + on_attach = function(client) + -- Disable formatting capability for tsserver + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + end, + filetypes = { + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + }, + root_markers = { "tsconfig.json", "jsconfig.json", "package.json" }, + }) + + vim.lsp.config("pylsp", { + on_attach = function(client) + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + end, + filetypes = { + "python", + }, + root_markers = { "requirements.txt" }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/theme.lua b/.config/nvim/lua/plugins/theme.lua index 2d94aa3..7860a3a 100644 --- a/.config/nvim/lua/plugins/theme.lua +++ b/.config/nvim/lua/plugins/theme.lua @@ -1,6 +1,8 @@ return { { "comfysage/cuddlefish.nvim", + lazy = false, + priority = 1000, config = function() require("cuddlefish").setup({ theme = { @@ -18,32 +20,43 @@ return { comment = { "italic" }, }, }) + vim.cmd("colorscheme cuddlefish") end, }, - { "maxmx03/dracula.nvim" }, + { "maxmx03/dracula.nvim", lazy = false, priority = 1000 }, { "rebelot/kanagawa.nvim", + lazy = false, + priority = 1000, + }, + { + "2giosangmitom/nightfall.nvim", + lazy = false, + priority = 1000, }, - { "2giosangmitom/nightfall.nvim" }, { "olimorris/onedarkpro.nvim", + lazy = false, + priority = 1000, }, - { "pauchiner/pastelnight.nvim" }, - { "numToStr/Sakura.nvim" }, + { "pauchiner/pastelnight.nvim", lazy = false, priority = 1000 }, + { "numToStr/Sakura.nvim", lazy = false, priority = 1000 }, { "folke/tokyonight.nvim", + lazy = false, + priority = 1000, }, { "yorumicolors/yorumi.nvim", + lazy = false, + priority = 1000, }, { "zaldih/themery.nvim", lazy = false, - priority = 1000, + priority = 999, config = function() - vim.cmd("colorscheme deeper-night") local themery = require("themery") - themery.setup({ -- List of swappable colorschemes. themes = { @@ -61,7 +74,7 @@ return { livePreview = true, -- Apply theme while picking. Default to true. }) - themery.setThemeByIndex(1, true) + --themery.setThemeByName("deeper-night", true) vim.keymap.set("n", "tt", function() local numberOfThemes = #themery.getAvailableThemes() @@ -69,6 +82,7 @@ return { local nextThemeIndex = (currentThemeIndex % numberOfThemes) + 1 themery.setThemeByIndex(nextThemeIndex, true) end, { noremap = true }) + vim.keymap.set("n", "th", "Themery", { noremap = true }) end, }, } diff --git a/.config/nvim/lua/plugins/ui/barbar.lua b/.config/nvim/lua/plugins/ui/barbar.lua new file mode 100644 index 0000000..ca6446f --- /dev/null +++ b/.config/nvim/lua/plugins/ui/barbar.lua @@ -0,0 +1,61 @@ +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 new file mode 100644 index 0000000..a6f822a --- /dev/null +++ b/.config/nvim/lua/plugins/ui/dressing.lua @@ -0,0 +1,172 @@ +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/lualine.lua b/.config/nvim/lua/plugins/ui/lualine.lua new file mode 100644 index 0000000..a04b6c6 --- /dev/null +++ b/.config/nvim/lua/plugins/ui/lualine.lua @@ -0,0 +1,29 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup({ + options = { + theme = "deeper-night", + section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype", "lsp_status" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/util/auto-session.lua b/.config/nvim/lua/plugins/util/auto-session.lua new file mode 100644 index 0000000..83edf16 --- /dev/null +++ b/.config/nvim/lua/plugins/util/auto-session.lua @@ -0,0 +1,21 @@ +return { + "rmagatti/auto-session", + config = function() + local auto_session = require("auto-session") + + auto_session.setup({ + auto_restore_enabled = false, + 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)" } + ) -- save workspace session for current working directory + end, +} diff --git a/.config/nvim/lua/plugins/util/mini.surround.lua b/.config/nvim/lua/plugins/util/mini.surround.lua new file mode 100644 index 0000000..139369a --- /dev/null +++ b/.config/nvim/lua/plugins/util/mini.surround.lua @@ -0,0 +1,7 @@ +return { + "echasnovski/mini.surround", + version = "*", + config = function() + require("mini.surround").setup() + end, +} diff --git a/.config/nvim/lua/plugins/util/neogit.lua b/.config/nvim/lua/plugins/util/neogit.lua new file mode 100644 index 0000000..7b73b1d --- /dev/null +++ b/.config/nvim/lua/plugins/util/neogit.lua @@ -0,0 +1,12 @@ +return { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "sindrets/diffview.nvim", + "nvim-telescope/telescope.nvim", + }, + keys = { { "gg", "Neogit", desc = "Open Neogit (Neogit)" } }, + config = function() + local neogit = require("neogit") + end, +} diff --git a/.config/nvim/lua/plugins/util/nvim-notify.lua b/.config/nvim/lua/plugins/util/nvim-notify.lua new file mode 100644 index 0000000..fde6ed5 --- /dev/null +++ b/.config/nvim/lua/plugins/util/nvim-notify.lua @@ -0,0 +1,7 @@ +return { + "rcarriga/nvim-notify", + config = function() + -- Replace vim.notify with this nvim-notify popups + vim.notify = require("notify") + end, +} diff --git a/.config/nvim/lua/plugins/util/oil.lua b/.config/nvim/lua/plugins/util/oil.lua new file mode 100644 index 0000000..2ce3d90 --- /dev/null +++ b/.config/nvim/lua/plugins/util/oil.lua @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..e93c877 --- /dev/null +++ b/.config/nvim/lua/plugins/util/todo-comments.lua @@ -0,0 +1,21 @@ +-- TODO Get todo-comments working +return { + "folke/todo-comments.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local todo_comments = require("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() + end, +} diff --git a/.config/nvim/lua/plugins/util/trouble.lua b/.config/nvim/lua/plugins/util/trouble.lua new file mode 100644 index 0000000..54d2472 --- /dev/null +++ b/.config/nvim/lua/plugins/util/trouble.lua @@ -0,0 +1,39 @@ +return { + "folke/trouble.nvim", + dependencies = { "folke/todo-comments.nvim", "nvim-tree/nvim-web-devicons" }, + opts = { focus = true }, + cmd = "Trouble", + keys = { + { + "xx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "xX", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "cs", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "cl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "xL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "xQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + { "xt", "Trouble todo toggle", desc = "Open todos (Trouble)" }, + }, +} diff --git a/.config/nvim/lua/plugins/util/util.lua b/.config/nvim/lua/plugins/util/util.lua new file mode 100644 index 0000000..495f327 --- /dev/null +++ b/.config/nvim/lua/plugins/util/util.lua @@ -0,0 +1,14 @@ +-- 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-maximizer.lua b/.config/nvim/lua/plugins/util/vim-maximizer.lua new file mode 100644 index 0000000..715e2f7 --- /dev/null +++ b/.config/nvim/lua/plugins/util/vim-maximizer.lua @@ -0,0 +1,6 @@ +return { + "szw/vim-maximizer", + keys = { + { "sm", "MaximizerToggle", desc = "Maximize/minimize a split (vim-maximizer)" }, + }, +} diff --git a/.config/nvim/lua/plugins/util/which-key.lua b/.config/nvim/lua/plugins/util/which-key.lua new file mode 100644 index 0000000..f438875 --- /dev/null +++ b/.config/nvim/lua/plugins/util/which-key.lua @@ -0,0 +1,27 @@ +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 + }, + keys = { + { + "!", + function() + require("which-key").show({ global = true }) + end, + desc = "Buffer All Keymaps (which-key)", + }, + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, + }, +} diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 0d58d9f..24828b7 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -1,10 +1,11 @@ -- Set basic options vim.o.number = true -- Show line numbers vim.o.relativenumber = true -- Show relative line numbers -vim.o.tabstop = 4 -- Number of spaces tabs count for -vim.o.shiftwidth = 4 -- Number of spaces to use for each step of (auto)indent vim.o.expandtab = true -- Convert tabs to spaces vim.o.smartindent = true -- Insert indents automatically +vim.o.tabstop = 4 -- Number of spaces that a tab in the file counts for +vim.o.shiftwidth = 4 -- Number of spaces to use for each step of (auto)indent +vim.o.softtabstop = 4 -- Number of spaces that a tab counts for while performing editing operations vim.filetype.add({ pattern = { diff --git a/.gitignore b/.gitignore index 59857a4..463afa1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ !.config/neofetch/* !.config/nvim/init.lua -!.config/nvim/lua/* +!.config/nvim/lua/** !.config/tmux/tmux.conf !.config/tmux/catppuccin.conf diff --git a/.zshrc b/.zshrc index 7c4fc8b..aaa6f82 100644 --- a/.zshrc +++ b/.zshrc @@ -47,6 +47,6 @@ alias svim="sudo -E -s nvim" alias dots='/usr/bin/git --git-dir=$HOME/.git/ --work-tree=$HOME' alias vim="nvim" alias vi="nvim" -alias team="teamocil" +alias python="python3" [[ ! -f ~/.localrc.zsh ]] || source ~/.localrc.zsh