From 3cd3e38358679b7a244c6b6d350419ecf528bf5c Mon Sep 17 00:00:00 2001 From: RafayAhmad7548 Date: Sat, 25 Oct 2025 21:04:46 +0500 Subject: [PATCH] neovim update --- .config/nvim/lazy-lock.json | 31 +- .config/nvim/lua/config/keymaps.lua | 4 +- .config/nvim/lua/config/options.lua | 3 + .config/nvim/lua/config/plugins/git.lua | 286 +++++++++--------- .config/nvim/lua/config/plugins/init.lua | 3 +- .../lua/config/plugins/languages/molten.lua | 27 -- .../lua/config/plugins/languages/notebook.lua | 121 ++++++++ .config/nvim/lua/config/plugins/snacks.lua | 2 + 8 files changed, 288 insertions(+), 189 deletions(-) delete mode 100644 .config/nvim/lua/config/plugins/languages/molten.lua create mode 100644 .config/nvim/lua/config/plugins/languages/notebook.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 8d4b3b7..983b05a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,28 +1,29 @@ { "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, - "auto-session": { "branch": "main", "commit": "ee320d7a59c1dfe83df7c9d58150d9f194690d53" }, - "blink.cmp": { "branch": "main", "commit": "586ee87534f5bf65f1c8dea2d1da2a57e8cddd36" }, - "catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" }, + "auto-session": { "branch": "main", "commit": "3a895bace7d0260c8daac5bf5c84236765f00212" }, + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, + "catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "fidget.nvim": { "branch": "main", "commit": "4d5858bd4c471c895060e1b9f3575f1551184dc5" }, "flutter-tools.nvim": { "branch": "main", "commit": "65b7399804315a1160933b64292d3c5330aa4e9f" }, - "gitsigns.nvim": { "branch": "main", "commit": "93f882f7041a2e779addbd34943812ca66edef5a" }, + "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, "image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" }, + "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "markview.nvim": { "branch": "main", "commit": "ec33f2aa333ca1d76f51847922578434d7aeadf7" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "markview.nvim": { "branch": "main", "commit": "e6b0f5aee8105adab6077509c46459812db4cffa" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7f9a39fcd2ac6e979001f857727d606888f5909c" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, "mini.nvim": { "branch": "main", "commit": "94cae4660a8b2d95dbbd56e1fbc6fcfa2716d152" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, - "notebook.nvim": { "branch": "main", "commit": "e7145d5e905f74ac927aa45fe109adbdd9e9f340" }, - "nvim-lspconfig": { "branch": "master", "commit": "f47cd681d7cb6048876a2e908b6d8ba1e530d152" }, + "nvim-lspconfig": { "branch": "master", "commit": "1f7fbc34e6420476142b5cc85e9bee52717540fb" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, + "otter.nvim": { "branch": "main", "commit": "c44d645f03ae96e2e3cdc37f92ecfa93a534b736" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "snacks.nvim": { "branch": "main", "commit": "d67a47739dfc652cfcf66c59e929c704a854b37a" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" } } diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index c16aa09..943a30a 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -75,7 +75,7 @@ vim.keymap.set('n', '/', function() Snacks.picker.lines({ layout = 'select' }) end, { desc = 'fuzzily search in current buffer' }) -vim.keymap.set('n', 'sp', 'SessionSearch', { desc = 'search sessions' }) +vim.keymap.set('n', 'sp', 'AutoSession search', { desc = 'search sessions' }) -- INFO: LSP @@ -204,7 +204,7 @@ vim.keymap.set('n', 'mo', ':MoltenEvaluateOperator', { silent = true vim.keymap.set('n', 'ml', ':MoltenEvaluateLine', { silent = true, desc = 'evaluate line' }) vim.keymap.set('v', 'mv', ':MoltenEvaluateVisualgv', { silent = false, desc = 'evaluate visual selection' }) vim.keymap.set('n', 'mc', ':MoltenReevaluateCell', { silent = false, desc = 'reevaluate cell' }) -vim.keymap.set('n', 'me', ':noautocmd MoltenEnterOutput', { silent = true, desc = 'show/enter output' }) +vim.keymap.set('n', 'me', ':noautocmd MoltenEnterOutput:noautocmd MoltenEnterOutput', { silent = true, desc = 'show/enter output' }) vim.keymap.set('n', 'mh', ':MoltenHideOutput', { silent = true, desc = 'hide output' }) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 977a59d..e98ad2e 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -47,6 +47,9 @@ vim.o.winborder = 'rounded' vim.opt.hlsearch = false vim.opt.wrap = false +vim.o.swapfile = false +vim.o.undofile = false + vim.o.sessionoptions='blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions' -- Example for configring Neovim to load user-installed installed Lua rocks: package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?/init.lua;' diff --git a/.config/nvim/lua/config/plugins/git.lua b/.config/nvim/lua/config/plugins/git.lua index dbffb9e..fdb7eba 100644 --- a/.config/nvim/lua/config/plugins/git.lua +++ b/.config/nvim/lua/config/plugins/git.lua @@ -1,154 +1,154 @@ return { - { - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - signs_staged = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - signs_staged_enable = true, - signcolumn = true, + { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged_enable = true, + signcolumn = true, - on_attach = function() - local gitsigns = require('gitsigns') + on_attach = function() + local gitsigns = require('gitsigns') - vim.keymap.set('n', 'gs', gitsigns.stage_hunk, { desc = 'stage hunk' }) - vim.keymap.set('n', 'gr', gitsigns.reset_hunk, { desc = 'restore hunk' }) + vim.keymap.set('n', 'gs', gitsigns.stage_hunk, { desc = 'stage hunk' }) + vim.keymap.set('n', 'gr', gitsigns.reset_hunk, { desc = 'restore hunk' }) - vim.keymap.set('n', 'gS', gitsigns.stage_buffer, { desc = 'stage buffer' }) - vim.keymap.set('n', 'gR', gitsigns.stage_hunk, { desc = 'reset buffer' }) + vim.keymap.set('n', 'gS', gitsigns.stage_buffer, { desc = 'stage buffer' }) + vim.keymap.set('n', 'gR', gitsigns.stage_hunk, { desc = 'reset buffer' }) - vim.keymap.set('n', 'gp', gitsigns.preview_hunk, { desc = 'preview hunk' }) - vim.keymap.set('n', 'gb', gitsigns.blame_line, { desc = 'blame line' }) + vim.keymap.set('n', 'gp', gitsigns.preview_hunk, { desc = 'preview hunk' }) + vim.keymap.set('n', 'gb', gitsigns.blame_line, { desc = 'blame line' }) - end - }, + end }, - { - 'sindrets/diffview.nvim', - config = function () - local actions = require('diffview.config').actions - require('diffview').setup({ - keymaps = { - disable_defaults = true, - file_panel = { - ['i'] = '', - ['k'] = '', - ['j'] = false, + }, + { + 'sindrets/diffview.nvim', + config = function () + local actions = require('diffview.config').actions + require('diffview').setup({ + keymaps = { + disable_defaults = true, + file_panel = { + ['i'] = '', + ['k'] = '', + ['j'] = false, - [''] = function () actions.toggle_stage_entry() end + [''] = function () actions.toggle_stage_entry() end - } - } - }) - end - }, - -- { - -- 'NeogitOrg/neogit', - -- dependencies = { - -- 'nvim-lua/plenary.nvim', - -- 'nvim-telescope/telescope.nvim', - -- }, - -- config = function() - -- require('neogit').setup({ - -- - -- kind = 'floating', - -- graph_style = 'kitty', - -- disable_line_numbers = false, - -- disable_relative_line_numbers = false, - -- commit_editor = { - -- kind = 'floating', - -- }, - -- commit_select_view = { - -- kind = 'floating', - -- }, - -- commit_view = { - -- kind = 'floating', - -- verify_commit = vim.fn.executable('gpg') == 1, -- Can be set to true or false, otherwise we try to find the binary - -- }, - -- log_view = { - -- kind = 'floating', - -- }, - -- rebase_editor = { - -- kind = 'floating', - -- }, - -- reflog_view = { - -- kind = 'floating', - -- }, - -- merge_editor = { - -- kind = 'floating', - -- }, - -- description_editor = { - -- kind = 'floating', - -- }, - -- tag_editor = { - -- kind = 'floating', - -- }, - -- preview_buffer = { - -- kind = 'floating', - -- }, - -- popup = { - -- kind = 'floating', - -- }, - -- stash = { - -- kind = 'floating', - -- }, - -- refs_view = { - -- kind = 'floating', - -- }, - -- mappings = { - -- status = { - -- ['i'] = 'MoveUp', - -- ['k'] = 'MoveDown', - -- ['j'] = false, - -- }, - -- } - -- }) - -- vim.keymap.set('n', 'gg', 'Neogit', { desc = 'open neogit '}) - -- end - -- } - -- { - -- 'tpope/vim-fugitive', - -- } - -- { - -- 'sindrets/diffview.nvim', - -- dependencies = { 'nvim-tree/nvim-web-devicons' }, - -- -- lazy, only load diffview by these commands - -- cmd = { - -- 'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh' - -- } - -- }, - -- { - -- 'SuperBo/fugit2.nvim', - -- build = false, - -- opts = { - -- width = 100, - -- }, - -- dependencies = { - -- 'MunifTanjim/nui.nvim', - -- 'nvim-tree/nvim-web-devicons', - -- 'nvim-lua/plenary.nvim', - -- -- { - -- -- 'chrisgrieser/nvim-tinygit', -- optional: for Github PR view - -- -- dependencies = { 'stevearc/dressing.nvim' } - -- -- }, - -- }, - -- cmd = { 'Fugit2', 'Fugit2Diff', 'Fugit2Graph' }, - -- keys = { - -- { 'F', mode = 'n', 'Fugit2' } - -- } - -- }, + } + } + }) + end + }, + -- { + -- 'NeogitOrg/neogit', + -- dependencies = { + -- 'nvim-lua/plenary.nvim', + -- 'nvim-telescope/telescope.nvim', + -- }, + -- config = function() + -- require('neogit').setup({ + -- + -- kind = 'floating', + -- graph_style = 'kitty', + -- disable_line_numbers = false, + -- disable_relative_line_numbers = false, + -- commit_editor = { + -- kind = 'floating', + -- }, + -- commit_select_view = { + -- kind = 'floating', + -- }, + -- commit_view = { + -- kind = 'floating', + -- verify_commit = vim.fn.executable('gpg') == 1, -- Can be set to true or false, otherwise we try to find the binary + -- }, + -- log_view = { + -- kind = 'floating', + -- }, + -- rebase_editor = { + -- kind = 'floating', + -- }, + -- reflog_view = { + -- kind = 'floating', + -- }, + -- merge_editor = { + -- kind = 'floating', + -- }, + -- description_editor = { + -- kind = 'floating', + -- }, + -- tag_editor = { + -- kind = 'floating', + -- }, + -- preview_buffer = { + -- kind = 'floating', + -- }, + -- popup = { + -- kind = 'floating', + -- }, + -- stash = { + -- kind = 'floating', + -- }, + -- refs_view = { + -- kind = 'floating', + -- }, + -- mappings = { + -- status = { + -- ['i'] = 'MoveUp', + -- ['k'] = 'MoveDown', + -- ['j'] = false, + -- }, + -- } + -- }) + -- vim.keymap.set('n', 'gg', 'Neogit', { desc = 'open neogit '}) + -- end + -- } + -- { + -- 'tpope/vim-fugitive', + -- } + -- { + -- 'sindrets/diffview.nvim', + -- dependencies = { 'nvim-tree/nvim-web-devicons' }, + -- -- lazy, only load diffview by these commands + -- cmd = { + -- 'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh' + -- } + -- }, + -- { + -- 'SuperBo/fugit2.nvim', + -- build = false, + -- opts = { + -- width = 100, + -- }, + -- dependencies = { + -- 'MunifTanjim/nui.nvim', + -- 'nvim-tree/nvim-web-devicons', + -- 'nvim-lua/plenary.nvim', + -- -- { + -- -- 'chrisgrieser/nvim-tinygit', -- optional: for Github PR view + -- -- dependencies = { 'stevearc/dressing.nvim' } + -- -- }, + -- }, + -- cmd = { 'Fugit2', 'Fugit2Diff', 'Fugit2Graph' }, + -- keys = { + -- { 'F', mode = 'n', 'Fugit2' } + -- } + -- }, } diff --git a/.config/nvim/lua/config/plugins/init.lua b/.config/nvim/lua/config/plugins/init.lua index 4b073b1..07c0cca 100644 --- a/.config/nvim/lua/config/plugins/init.lua +++ b/.config/nvim/lua/config/plugins/init.lua @@ -17,7 +17,6 @@ require('lazy').setup({ 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = {} }, - { 'meatballs/notebook.nvim', opts = {} }, -- { 'stevearc/dressing.nvim', opts = {}, }, -- 'ThePrimeagen/vim-be-good', @@ -33,7 +32,7 @@ require('lazy').setup({ require('config.plugins.snacks'), require('config.plugins.mini'), - require('config.plugins.languages.molten'), + require('config.plugins.languages.notebook'), require('config.plugins.languages.flutter'), require('config.plugins.languages.markdown'), diff --git a/.config/nvim/lua/config/plugins/languages/molten.lua b/.config/nvim/lua/config/plugins/languages/molten.lua deleted file mode 100644 index e44324f..0000000 --- a/.config/nvim/lua/config/plugins/languages/molten.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - { - '3rd/image.nvim', - version = '1.1.0', - build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239 - opts = { - backend = 'kitty', -- whatever backend you would like to use - max_width = 100, - max_height = 20, - max_height_window_percentage = math.huge, - max_width_window_percentage = math.huge, - window_overlap_clear_enabled = true, -- toggles images when windows are overlapped - window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '' }, - } - - }, - { - 'benlubas/molten-nvim', - version = '^1.0.0', -- use version <2.0.0 to avoid breaking changes - dependencies = { '3rd/image.nvim' }, - build = ':UpdateRemotePlugins', - init = function() - -- these are examples, not defaults. Please see the readme - vim.g.molten_image_provider = 'image.nvim' - end, - } -} diff --git a/.config/nvim/lua/config/plugins/languages/notebook.lua b/.config/nvim/lua/config/plugins/languages/notebook.lua new file mode 100644 index 0000000..8fba839 --- /dev/null +++ b/.config/nvim/lua/config/plugins/languages/notebook.lua @@ -0,0 +1,121 @@ +-- Provide a command to create a blank new Python notebook +-- note: the metadata is needed for Jupytext to understand how to parse the notebook. +-- if you use another language than Python, you should change it in the template. +local default_notebook = [[ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython" + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 + } +]] + +local function new_notebook(filename) + local path = filename .. ".ipynb" + local file = io.open(path, "w") + if file then + file:write(default_notebook) + file:close() + vim.cmd("edit " .. path) + else + print("Error: Could not open new notebook file for writing.") + end +end + +vim.api.nvim_create_user_command('NewNotebook', function(opts) + new_notebook(opts.args) +end, { + nargs = 1, + complete = 'file' +}) + +return { + { + '3rd/image.nvim', + version = '1.1.0', + build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239 + opts = { + backend = 'kitty', -- whatever backend you would like to use + max_width = 100, + max_height = 20, + max_height_window_percentage = math.huge, + max_width_window_percentage = math.huge, + window_overlap_clear_enabled = true, -- toggles images when windows are overlapped + window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '' }, + } + + }, + { + 'benlubas/molten-nvim', + version = '^1.0.0', -- use version <2.0.0 to avoid breaking changes + dependencies = { '3rd/image.nvim' }, + build = ':UpdateRemotePlugins', + init = function() + -- these are examples, not defaults. Please see the readme + vim.g.molten_image_provider = 'image.nvim' + vim.g.molten_virt_text_output = true + vim.g.molten_virt_lines_off_by_1 = true + vim.g.molten_auto_open_output = false + end, + }, + { + 'GCBallesteros/jupytext.nvim', + opts = { + style = 'markdown', + output_extension = 'md', + force_ft = 'markdown' + } + }, + { + 'jmbuhr/otter.nvim', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + }, + config = function () + local otter = require('otter') + otter.setup() + + vim.api.nvim_create_autocmd('BufEnter', { + pattern = { '*.ipynb' }, + callback = function () + if not vim.b._molten_import_output then + vim.b._molten_import_output = true + vim.cmd('MoltenImportOutput') + otter.activate({ 'python' }) + end + end + }) + vim.api.nvim_create_autocmd('BufWritePost', { + pattern = { '*.ipynb' }, + callback = function () + vim.cmd('MoltenExportOutput!') + end + }) + + end + } +} diff --git a/.config/nvim/lua/config/plugins/snacks.lua b/.config/nvim/lua/config/plugins/snacks.lua index aac696f..8e3c376 100644 --- a/.config/nvim/lua/config/plugins/snacks.lua +++ b/.config/nvim/lua/config/plugins/snacks.lua @@ -79,6 +79,8 @@ return { [''] = { 'toggle_hidden', mode = 'i' }, [''] = { 'toggle_ignored', mode = 'i' }, + + [''] = { 'qflist', mode = 'i' }, } } },