diff --git a/common/.config/nvim/init.lua b/common/.config/nvim/init.lua index e7a658a..6bae2cd 100644 --- a/common/.config/nvim/init.lua +++ b/common/.config/nvim/init.lua @@ -13,11 +13,20 @@ require("config") local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + lazyrepo, + lazypath, + }) if vim.v.shell_error ~= 0 then error("Error cloning lazy.nvim:\n" .. out) end -end ---@diagnostic disable-next-line: undefined-field +end + +---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) -- You can also configure plugins after the setup call, diff --git a/common/.config/nvim/lua/config/autocmd.lua b/common/.config/nvim/lua/config/autocmd.lua index e21e3f3..712b4fa 100644 --- a/common/.config/nvim/lua/config/autocmd.lua +++ b/common/.config/nvim/lua/config/autocmd.lua @@ -1,13 +1,17 @@ --- Auto reload existing session -vim.api.nvim_create_autocmd("VimEnter", { - group = vim.api.nvim_create_augroup("restore_session", { clear = true }), - callback = function() - -- If nvim started with arguments, do NOT restore - if vim.fn.argc() ~= 0 then return end - require("persistence").load() - end, - nested = true, -}) +if not vim.g.vscode then + -- Auto reload existing session + vim.api.nvim_create_autocmd("VimEnter", { + group = vim.api.nvim_create_augroup("restore_session", { clear = true }), + callback = function() + -- If nvim started with arguments, do NOT restore + if vim.fn.argc() ~= 0 then + return + end + require("persistence").load() + end, + nested = true, + }) +end -- Enable spell check on markdown and text files vim.api.nvim_create_autocmd("FileType", { diff --git a/common/.config/nvim/lua/plugins/ai.lua b/common/.config/nvim/lua/plugins/ai.lua index e0477e8..91d9147 100644 --- a/common/.config/nvim/lua/plugins/ai.lua +++ b/common/.config/nvim/lua/plugins/ai.lua @@ -1,3 +1,24 @@ return { - -- TODO: Use similar keymaps to Windsurf + -- codeium + { + "Exafunction/codeium.nvim", + cond = require("config.util").is_not_vscode(), + cmd = "Codeium", + build = ":Codeium Auth", + event = "InsertEnter", + opts = { + enable_cmp_source = vim.g.ai_cmp, + virtual_text = { + enabled = not vim.g.ai_cmp, + key_bindings = { + accept = false, -- handled by nvim-cmp / blink.cmp + next = "", + prev = "", + }, + }, + }, + config = function() + require("codeium").setup({}) + end, + }, } diff --git a/common/.config/nvim/lua/plugins/code-completion.lua b/common/.config/nvim/lua/plugins/code-completion.lua index 1675df6..e15e3ab 100644 --- a/common/.config/nvim/lua/plugins/code-completion.lua +++ b/common/.config/nvim/lua/plugins/code-completion.lua @@ -1,7 +1,4 @@ return { - - -- TODO: Figureout how to add custom snippets - { -- Autocompletion "hrsh7th/nvim-cmp", @@ -41,12 +38,14 @@ return { "hrsh7th/cmp-vsnip", "hrsh7th/vim-vsnip", + "Exafunction/codeium", }, config = function() -- See `:help cmp` local cmp = require("cmp") local defaults = require("cmp.config.default")() local luasnip = require("luasnip") + require("luasnip.loaders.from_vscode").lazy_load() luasnip.config.setup({}) @@ -57,6 +56,13 @@ return { -- hl_group = "CmpGhostText", -- }, -- }, + sources = { + { name = "nvim_lsp" }, + { name = "codeium" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) @@ -97,12 +103,6 @@ return { end end, { "i", "s" }), }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }, sorting = defaults.sorting, }) end, diff --git a/common/.config/nvim/lua/plugins/code-formatting.lua b/common/.config/nvim/lua/plugins/code-formatting.lua index e551ef2..1c9c679 100644 --- a/common/.config/nvim/lua/plugins/code-formatting.lua +++ b/common/.config/nvim/lua/plugins/code-formatting.lua @@ -1,7 +1,7 @@ return { { "stevearc/conform.nvim", - -- cond = require("config.util").is_not_vscode(), + cond = require("config.util").is_not_vscode(), lazy = true, event = { "BufWritePre" }, opts = { @@ -31,9 +31,9 @@ return { local disable_filetypes = { c = true, cpp = true } local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' + lsp_format_opt = "never" else - lsp_format_opt = 'fallback' + lsp_format_opt = "fallback" end return { quiet = false, @@ -60,6 +60,6 @@ return { }, }, }, - } + }, }, } diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index 83862ad..c328996 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -1,7 +1,4 @@ return { - - -- TODO: - -- Reduce noice timeout { "tpope/vim-repeat" }, -- Better code folding @@ -168,6 +165,7 @@ return { { "RRethy/vim-illuminate", lazy = false, + cond = require("config.util").is_not_vscode(), opts = { delay = 200, large_file_cutoff = 2000, @@ -206,10 +204,23 @@ return { -- Finds and lists all of the TODO, HACK, BUG, etc comment { "folke/todo-comments.nvim", + cond = require("config.util").is_not_vscode(), event = "VimEnter", dependencies = { "nvim-lua/plenary.nvim" }, config = true, opts = { + search = { + command = "rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--hidden", -- include hidden files + "--glob=!.git", -- exclude .git directory + }, + }, signs = false, keywords = { HACK = { alt = { "TIP" } }, @@ -231,15 +242,19 @@ return { desc = "Previous todo comment", }, - -- TODO: Include hidden files - { "fT", "TodoTelescope", desc = "List Todo/Fix/Fixme" }, - { "ft", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "List Todo" }, + { "df", "TodoTelescope keywords=FIX,FIXME", desc = "TODO: FIXME Tags" }, + { "dt", "TodoTelescope keywords=TODO", desc = "TODO: Project Todos" }, + { "dT", "TodoTelescope", desc = "TODO: All" }, }, }, -- better diagnostics list and others { "folke/trouble.nvim", + lazy = false, + cmd = "Trouble", + cond = require("config.util").is_not_vscode(), + dependencies = { "nvim-tree/nvim-web-devicons" }, opts = { -- Default: Preview in a split preview = { @@ -249,12 +264,11 @@ return { size = 0.6, }, modes = { - -- Show only the most severe diagnostics; once resolved, less severe will be shown - most_severe = { + project_warnings = { mode = "diagnostics", -- inherit from diagnostics mode filter = function(items) - local severity = vim.diagnostic.severity.HINT + local severity = vim.diagnostic.severity.WARN for _, item in ipairs(items) do severity = math.min(severity, item.severity) end @@ -265,13 +279,13 @@ return { }, -- Diagnostics from buffer + Errors from current project - project_errors = { + file_hints = { mode = "diagnostics", -- inherit from diagnostics mode filter = { any = { buf = 0, -- current buffer { - severity = vim.diagnostic.severity.ERROR, + severity = vim.diagnostic.severity.INFO, -- limit to files in the current project function(item) return item.filename:find((vim.loop or vim.uv).cwd(), 1, true) @@ -283,11 +297,10 @@ return { }, }, keys = { - { "dd", "Trouble project_errors toggle focus=true", desc = "Trouble: Document Diagnostics" }, - { "dw", "Trouble most_severe toggle focus=true", desc = "Trouble: List Project Diagnostics" }, - { "dl", "Trouble loclist toggle focus=true", desc = "Trouble: Location List" }, + { "dd", "Trouble file_hints toggle focus=true", desc = "Trouble: File Diagnostics" }, + { "dw", "Trouble project_warnings toggle focus=true", desc = "Trouble: List Project Diagnostics" }, { "dq", "Trouble quickfix toggle focus=true", desc = "Trouble: Quickfix List" }, - { "gr", "Trouble lsp_references toggle focus=true", desc = "Code: List References" }, + { "gr", "Trouble lsp_references toggle focus=true", desc = "Goto References" }, { "[q", function() @@ -306,6 +319,7 @@ return { "]q", function() if require("trouble").is_open() then + ---@diagnostic disable-next-line: missing-parameter, missing-fields require("trouble").next({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cnext) @@ -349,6 +363,7 @@ return { -- Search and jump around symbols in the buffer { "SmiteshP/nvim-navbuddy", + cond = require("config.util").is_not_vscode(), dependencies = { "SmiteshP/nvim-navic", "MunifTanjim/nui.nvim", @@ -472,12 +487,22 @@ return { -- See `:help nvim-treesitter` -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' vim.defer_fn(function() + ---@diagnostic disable-next-line: missing-fields require("nvim-treesitter.configs").setup({ ensure_installed = { -- These 2 are required for cmdline "regex", "markdown", "markdown_inline", + "lua", + "rust", + "typescript", + "javascript", + "bash", + "html", + "css", + "json", + "yaml", }, auto_install = true, @@ -538,10 +563,6 @@ return { enable = true, border = "none", floating_preview_opts = {}, - -- peek_definition_code = { - -- ["cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" }, - -- ["cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" }, - -- }, }, }, }) diff --git a/common/.config/nvim/lua/plugins/code-git.lua b/common/.config/nvim/lua/plugins/code-git.lua index 027b41f..5770857 100644 --- a/common/.config/nvim/lua/plugins/code-git.lua +++ b/common/.config/nvim/lua/plugins/code-git.lua @@ -10,19 +10,20 @@ return { }, config = true, keys = { - { "gg", "Neogit", desc = "Git: Open Neogit", mode = { "n" } }, - { "gL", "Neogit log", desc = "Git: Open Log", mode = { "n" } }, + { "gg", "Neogit", desc = "Git: Open Neogit", mode = { "n" } }, + { "gL", "Neogit log", desc = "Git: Open Log", mode = { "n" } }, }, }, -- Git Diffview { "sindrets/diffview.nvim", + cond = require("config.util").is_not_vscode(), keys = { - { "gd", "DiffviewOpen", desc = "Git: Open Diffview", mode = { "n" } }, - { "gD", "DiffviewOpen", desc = "Git: Open Diffview against master", mode = { "n" } }, - { "gh", "DiffviewFileHistory", desc = "Git: Show file history", mode = { "n" } }, + { "gd", "DiffviewOpen", desc = "Git: Open Diffview", mode = { "n" } }, + { "gD", "DiffviewOpen", desc = "Git: Open Diffview against master", mode = { "n" } }, + { "gh", "DiffviewFileHistory", desc = "Git: Show file history", mode = { "n" } }, }, -- TODO: -- Toggle Diffview keymap diff --git a/common/.config/nvim/lua/plugins/code-lsp.lua b/common/.config/nvim/lua/plugins/code-lsp.lua index 80bff5b..3555dfc 100644 --- a/common/.config/nvim/lua/plugins/code-lsp.lua +++ b/common/.config/nvim/lua/plugins/code-lsp.lua @@ -1,9 +1,8 @@ return { { - -- TODO: Disable it for VSCode - -- -- Main LSP Configuration "neovim/nvim-lspconfig", + cond = require("config.util").is_not_vscode(), dependencies = { { "williamboman/mason.nvim", config = true }, -- NOTE: Must be loaded before dependants "williamboman/mason-lspconfig.nvim", @@ -47,7 +46,7 @@ return { map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + -- map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") -- Fuzzy find all the symbols in your current document. diff --git a/common/.config/nvim/lua/plugins/navigate-files.lua b/common/.config/nvim/lua/plugins/navigate-files.lua index f7ab711..078416d 100644 --- a/common/.config/nvim/lua/plugins/navigate-files.lua +++ b/common/.config/nvim/lua/plugins/navigate-files.lua @@ -161,22 +161,21 @@ return { -- Keymaps for LSP Things -> In code-lsp.lua - -- Grep things -> Search - vim.keymap.set("n", "sb", function() + -- Buffer + vim.keymap.set("n", "bs", function() require("telescope.builtin").live_grep({ grep_open_files = true, prompt_title = "Live Grep in Open Files", }) - end, { desc = "Search Open Buffers" }) - vim.keymap.set("n", "sg", require("telescope.builtin").live_grep, { desc = "Search/LiveGrep the Project" }) + end, { desc = "Live Grep Open Buffers" }) + vim.keymap.set("n", "bl", require("telescope.builtin").buffers, { desc = "List Buffers" }) + vim.keymap.set("n", "", require("telescope.builtin").live_grep, { desc = "Search/LiveGrep the Project" }) vim.keymap.set("n", "sw", require("telescope.builtin").grep_string, { desc = "Search current Word in Project" }) -- List - vim.keymap.set("n", "fb", require("telescope.builtin").buffers, { desc = "List Buffers" }) vim.keymap.set("n", "", require("telescope.builtin").find_files, { desc = "List & Search Files" }) - vim.keymap.set("n", "ff", require("telescope.builtin").find_files, { desc = "List & Search Files" }) - vim.keymap.set("n", "fq", require("telescope.builtin").quickfixhistory, { desc = "List Quickfix History" }) + vim.keymap.set("n", "dQ", require("telescope.builtin").quickfixhistory, { desc = "List Quickfix History" }) -- Git vim.keymap.set("n", "gfb", require("telescope.builtin").git_branches, { desc = "List Git Branches" }) diff --git a/common/.config/nvim/lua/plugins/ui.lua b/common/.config/nvim/lua/plugins/ui.lua index 0b957c7..363d379 100644 --- a/common/.config/nvim/lua/plugins/ui.lua +++ b/common/.config/nvim/lua/plugins/ui.lua @@ -35,7 +35,7 @@ return { "akinsho/bufferline.nvim", cond = require("config.util").is_not_vscode(), dependencies = { - { "echasnovski/mini.bufremove", version = "*" }, + "echasnovski/mini.bufremove", }, event = "VeryLazy", keys = { @@ -71,13 +71,19 @@ return { -- ... to switch to a buffer for i = 1, 9 do - vim.keymap.set("n", string.format("", i), string.format("BufferLineGoToBuffer %s", i), { noremap = true, silent = true }) + vim.keymap.set( + { "n", "v" }, + string.format("", i), + string.format("BufferLineGoToBuffer %s", i), + { noremap = true, silent = true } + ) end -- Fix bufferline when restoring a session vim.api.nvim_create_autocmd("BufAdd", { callback = function() vim.schedule(function() + ---@diagnostic disable-next-line: param-type-mismatch pcall(buf_line) end) end, @@ -107,7 +113,7 @@ return { }, opts = { render = "wrapped-compact", -- Smaller popups - timeout = 2500, + timeout = 2000, max_height = function() return math.floor(vim.o.lines * 0.25) end, @@ -163,7 +169,7 @@ return { { find = "; after #%d+" }, { find = "; before #%d+" }, - -- Display delete, yank, jump notifications at bottom + -- When message contains following { find = "yanked" }, { find = "fewer lines" }, { find = "more lines" }, diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index c1db786..eae34d7 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -108,24 +108,20 @@ return { }, { - "folke/lazydev.nvim", - ft = "lua", -- only load on lua files + "epwalsh/obsidian.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + }, + cond = require("config.util").is_not_vscode(), + ft = "markdown", opts = { - library = { - -- See the configuration section for more details - -- Load luvit types when the `vim.uv` word is found - { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + workspaces = { + { name = "personal", path = "~/Code/Notes" }, + }, + completion = { + nvim_cmp = true, }, }, }, - { - "hrsh7th/nvim-cmp", - opts = function(_, opts) - opts.sources = opts.sources or {} - table.insert(opts.sources, { - name = "lazydev", - group_index = 0, -- set group index to 0 to skip loading LuaLS completions - }) - end, - }, }