From 074c895e53e7d14a61cbe717c432ee29730f1a7c Mon Sep 17 00:00:00 2001 From: sudacode Date: Thu, 31 Jul 2025 20:17:08 -0700 Subject: [PATCH] update nvim config --- .config/nvim/lua/core/keymaps.lua | 89 +++++++++++++--------- .config/nvim/lua/plugins/image.lua | 2 +- .config/nvim/lua/plugins/obsidian.lua | 102 -------------------------- .config/nvim/lua/plugins/odis.lua | 52 ------------- 4 files changed, 54 insertions(+), 191 deletions(-) delete mode 100644 .config/nvim/lua/plugins/obsidian.lua delete mode 100644 .config/nvim/lua/plugins/odis.lua diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index 9b4c887..f4c2875 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -160,7 +160,7 @@ local lsp_mappings = { { mode = "n", key = "ch", cmd = ":lua vim.lsp.buf.signature_help()", group = "Signature Help" }, { mode = "n", key = "cR", cmd = ":lua vim.lsp.buf.rename()", group = "Rename" }, { mode = "n", key = "cr", cmd = ":Telescope lsp_references", group = "LSP References" }, - { mode = "n", key = "cs", cmd = ":Telescope lsp_document_symbols", group = "LsP Document Symbols" }, + { mode = "n", key = "cs", cmd = ":Telescope lsp_document_symbols", group = "LSP Document Symbols" }, { mode = "n", key = "ct", cmd = ":Telescope lsp_type_definitions", group = "LSP Definitions" }, { mode = "n", @@ -465,32 +465,28 @@ local diffview_mappings = { --{{{ Custom Terminals local programs_map = { - gg = { cmd = "lazygit", display_name = "lazygit", direction = "tab", hidden = true, group = "Lazygit" }, - op = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true, group = "Ipython" }, + gg = { cmd = "lazygit", display_name = "lazygit", direction = "tab", hidden = true }, + op = { cmd = "ipython", display_name = "ipython", direction = "vertical", hidden = true }, oP = { cmd = "ipython", display_name = "ipython-full", direction = "tab", hidden = true, - group = "Ipython Fullscreen", }, - oi = { cmd = "sudo iotop", display_name = "ncmpcpp", direction = "tab", hidden = true, group = "Ncmpcpp" }, - on = { cmd = "ncmpcpp", display_name = "ncmpcpp", direction = "tab", hidden = true, group = "Ncmpcpp" }, - oN = { cmd = "nvtop", display_name = "nvtop", direction = "tab", hidden = true, group = "Nvtop" }, - ob = { cmd = "/usr/bin/btop", display_name = "btop", direction = "tab", hidden = true, group = "Btop" }, - od = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true, group = "Lazydocker" }, + oi = { cmd = "sudo iotop", display_name = "iotop", direction = "tab", hidden = true }, + on = { cmd = "rmpc", display_name = "rmpc", direction = "tab", hidden = true }, + oN = { cmd = "nvtop", display_name = "nvtop", direction = "tab", hidden = true }, + ob = { cmd = "/usr/bin/btop", display_name = "btop", direction = "tab", hidden = true }, + od = { cmd = "lazydocker", display_name = "lazydocker", direction = "tab", hidden = true }, } -for key, value in pairs(programs_map) do - map("n", "" .. key, function() - term_toggle(term_factory(value)) - end, opts) -end - +local temp local tbl = {} for key, value in pairs(programs_map) do - local temp = { - cmd = value.cmd, + temp = { + cmd = function() + term_toggle(term_factory(value)) + end, key = "" .. key, group = value.group, mode = "n", @@ -509,6 +505,25 @@ end vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") --}}} +-- {{{ NVIM-IMAGE +local image_mappings = { + { + + mode = "n", + key = "id", + cmd = ":lua require('image').disable()", + desc = "Disable image rendering", + }, + { + + mode = "n", + key = "ie", + cmd = ":lua require('image').enable()", + desc = "Enable image rendering", + }, +} +-- }}} + --{{{ Groups add_to_whichkey(nil, { key = "a", group = "AnyJump" }) add_to_whichkey(nil, { key = "b", group = "Buffers" }) @@ -519,16 +534,11 @@ add_to_whichkey(nil, { key = "d", group = "ODIS" }) add_to_whichkey(nil, { key = "f", group = "Find" }) add_to_whichkey(nil, { key = "g", group = "Git" }) add_to_whichkey(nil, { key = "gd", group = "DiffView" }) -add_to_whichkey(nil, { key = "gg", group = "Lazygit" }) add_to_whichkey(nil, { key = "h", group = "Help" }) +add_to_whichkey(nil, { key = "i", group = "Image" }) add_to_whichkey(nil, { key = "j", group = "AnyJump" }) add_to_whichkey(nil, { key = "N", group = "Noice" }) -- add_to_whichkey(nil, { key = "o", group = "Open" }) -add_to_whichkey(nil, { key = "ob", group = "Btop" }) -add_to_whichkey(nil, { key = "on", group = "Ncmpcpp" }) -add_to_whichkey(nil, { key = "od", group = "Lazydocker" }) -add_to_whichkey(nil, { key = "op", group = "Ipython" }) -add_to_whichkey(nil, { key = "oP", group = "Ipython Full" }) add_to_whichkey(nil, { key = "p", group = "Paste in Place" }) add_to_whichkey(nil, { key = "s", group = "Search" }) add_to_whichkey(nil, { key = "t", group = "Terminal" }) @@ -540,18 +550,25 @@ add_to_whichkey(nil, { key = "0", group = "Horizontal Terminal" }) --}}} --{{{ Whichkey Mappings -add_to_whichkey(map_from_table(basic_mappings)) -add_to_whichkey(map_from_table(buffer_navigation_mappings)) -add_to_whichkey(map_from_table(terminal_mappings)) -add_to_whichkey(map_from_table(lsp_mappings)) -add_to_whichkey(map_from_table(code_companion_mappings)) -add_to_whichkey(map_from_table(telescope_mappings)) -add_to_whichkey(map_from_table(file_explorer_mappings)) -add_to_whichkey(map_from_table(misc_utilities_mappings)) -add_to_whichkey(map_from_table(goto_preview_mappings)) -add_to_whichkey(map_from_table(workspace_management_mappings)) -add_to_whichkey(map_from_table(noice_mappings)) -add_to_whichkey(map_from_table(odis_mappings)) -add_to_whichkey(map_from_table(diffview_mappings)) +local mappings_tables = { + basic_mappings, + buffer_navigation_mappings, + terminal_mappings, + lsp_mappings, + code_companion_mappings, + telescope_mappings, + file_explorer_mappings, + misc_utilities_mappings, + goto_preview_mappings, + workspace_management_mappings, + noice_mappings, + odis_mappings, + diffview_mappings, + image_mappings, +} + +for _, mapping in ipairs(mappings_tables) do + add_to_whichkey(map_from_table(mapping)) +end add_to_whichkey(nil, { key = "dc", group = "Close" }) --}}} diff --git a/.config/nvim/lua/plugins/image.lua b/.config/nvim/lua/plugins/image.lua index 2ec625d..da16caa 100644 --- a/.config/nvim/lua/plugins/image.lua +++ b/.config/nvim/lua/plugins/image.lua @@ -7,7 +7,7 @@ return { integrations = { markdown = { enabled = true, - clear_in_insert_mode = false, + clear_in_insert_mode = true, download_remote_images = true, only_render_image_at_cursor = false, floating_windows = false, -- if true, images will be rendered in floating markdown windows diff --git a/.config/nvim/lua/plugins/obsidian.lua b/.config/nvim/lua/plugins/obsidian.lua deleted file mode 100644 index 9e653f5..0000000 --- a/.config/nvim/lua/plugins/obsidian.lua +++ /dev/null @@ -1,102 +0,0 @@ -vim.notify = require("notify") -return { - "epwalsh/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit - lazy = true, - ft = "markdown", - -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: - -- event = { - -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. - -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/*.md" - -- -- refer to `:h file-pattern` for more examples - -- "BufReadPre path/to/my-vault/*.md", - -- "BufNewFile path/to/my-vault/*.md", - -- }, - dependencies = { - -- Required. - "nvim-lua/plenary.nvim", - - -- see below for full list of optional dependencies 👇 - }, - opts = { - workspaces = { - { - name = "vault", - path = "~/S/obsidian/Vault", - }, - -- { - -- name = "work", - -- path = "~/vaults/work", - -- }, - }, - completion = { - -- Set to false to disable completion. - nvim_cmp = true, - -- Trigger completion at 2 chars. - min_chars = 2, - }, - -- Optional, configure additional syntax highlighting / extmarks. - -- This requires you have `conceallevel` set to 1 or 2. See `:help conceallevel` for more details. - ui = { - enable = true, -- set to false to disable all additional syntax features - update_debounce = 200, -- update delay after a text change (in milliseconds) - max_file_length = 5000, -- disable UI features for files with more than this many lines - -- Define how various check-boxes are displayed - checkboxes = { - -- NOTE: the 'char' value has to be a single character, and the highlight groups are defined below. - [" "] = { char = "󰄱", hl_group = "ObsidianTodo" }, - ["x"] = { char = "", hl_group = "ObsidianDone" }, - [">"] = { char = "", hl_group = "ObsidianRightArrow" }, - ["~"] = { char = "󰰱", hl_group = "ObsidianTilde" }, - ["!"] = { char = "", hl_group = "ObsidianImportant" }, - -- Replace the above with this if you don't have a patched font: - -- [" "] = { char = "☐", hl_group = "ObsidianTodo" }, - -- ["x"] = { char = "✔", hl_group = "ObsidianDone" }, - - -- You can also add more custom ones... - }, - }, - attachments = { - -- The default folder to place images in via `:ObsidianPasteImg`. - -- If this is a relative path it will be interpreted as relative to the vault root. - -- You can always override this per image by passing a full path to the command instead of just a filename. - img_folder = "screenshots", -- This is the default - - -- Optional, customize the default name or prefix when pasting images via `:ObsidianPasteImg`. - ---@return string - img_name_func = function() - -- Prefix image names with timestamp. - return string.format("%s-", os.time()) - end, - - -- A function that determines the text to insert in the note when pasting an image. - -- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file. - -- This is the default implementation. - ---@param client obsidian.Client - ---@param path obsidian.Path the absolute path to the image file - ---@return string - img_text_func = function(client, path) - path = client:vault_relative_path(path) or path - return string.format("![%s](%s)", path.name, path) - end, - }, - -- Optional, by default when you use `:ObsidianFollowLink` on a link to an external - -- URL it will be ignored but you can customize this behavior here. - ---@param url string - follow_url_func = function(url) - -- Open the URL in the default web browser. - vim.fn.jobstart({ "open", url }) -- Mac OS - -- vim.fn.jobstart({"xdg-open", url}) -- linux - -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows - -- vim.ui.open(url) -- need Neovim 0.10.0+ - end, - -- Optional, by default when you use `:ObsidianFollowLink` on a link to an image - -- file it will be ignored but you can customize this behavior here. - ---@param img string - follow_img_func = function(url) - -- vim.fn.jobstart({ "qlmanage", "-p", img }) -- Mac OS quick look preview - vim.fn.jobstart({ "xdg-open", url }) -- linux - -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows - end, - }, -} diff --git a/.config/nvim/lua/plugins/odis.lua b/.config/nvim/lua/plugins/odis.lua deleted file mode 100644 index af5e990..0000000 --- a/.config/nvim/lua/plugins/odis.lua +++ /dev/null @@ -1,52 +0,0 @@ -return { - url = "https://gitea.suda.codes/sudacode/odis", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "neovim/nvim-lspconfig", - }, - opts = { - opts = { - display = { - default_mode = "vsplit", - picker = true, - float = { - maxwidth = 80, - maxheight = 40, - border = "rounded", - title = true, - style = "minimal", - auto_focus = true, - anchor = "bottom_right", - offset = { row = -2, col = -2 }, - }, - window = { - width = 0.4, - height = 0.25, - position = "bottom|right", - floating = false, - border = "none", - }, - }, - integrations = { - treesitter = { - enabled = true, -- Enable Treesitter integration - highlight = true, -- Enable syntax highlighting - langs = { -- Language mapping for different doc types - lsp = "markdown", - man = "man", - help = "vimdoc", - }, - }, - }, - sources = { - lsp = { enabled = true }, - vim = { enabled = true }, - man = { enabled = true }, - }, - priority = { "LSP", "Vim", "Man" }, - mappings = { - close = "dc", - }, - }, - }, -}