From 467f005604f23ef59e4d2a604ed7c50fd434c39e Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Mon, 23 Mar 2026 20:34:40 -0400 Subject: [PATCH] refactor: update remaining language and misc plugins - Update copilot.lua, copilot-chat.lua AI integrations - Refactor jupytext.lua, slime.lua, venv-selector.lua for Python dev - Update dadbod.lua database tools, vimtex.lua LaTeX support - Clean up context.lua, render-markdown.lua, solarized.lua, monokai.lua - Update auto-dark-mode.lua, undotree.lua --- lua/custom/plugins/auto-dark-mode.lua | 32 ++++-- lua/custom/plugins/context.lua | 2 +- lua/custom/plugins/copilot-chat.lua | 29 ++---- lua/custom/plugins/copilot.lua | 6 +- lua/custom/plugins/dadbod.lua | 30 +++--- lua/custom/plugins/jupytext.lua | 136 ++++++++++++------------- lua/custom/plugins/monokai.lua | 2 +- lua/custom/plugins/render-markdown.lua | 4 +- lua/custom/plugins/slime.lua | 76 +++++++------- lua/custom/plugins/solarized.lua | 2 +- lua/custom/plugins/undotree.lua | 1 + lua/custom/plugins/venv-selector.lua | 5 +- lua/custom/plugins/vimtex.lua | 1 - 13 files changed, 163 insertions(+), 163 deletions(-) mode change 100644 => 100755 lua/custom/plugins/context.lua mode change 100644 => 100755 lua/custom/plugins/copilot-chat.lua mode change 100644 => 100755 lua/custom/plugins/jupytext.lua diff --git a/lua/custom/plugins/auto-dark-mode.lua b/lua/custom/plugins/auto-dark-mode.lua index c733b7f..8053f20 100755 --- a/lua/custom/plugins/auto-dark-mode.lua +++ b/lua/custom/plugins/auto-dark-mode.lua @@ -1,3 +1,5 @@ +local themes = require('custom.themes') + -- Define the function to set custom highlights for both themes local function set_lsp_highlights(mode) local hl = vim.api.nvim_set_hl @@ -20,6 +22,10 @@ local function set_lsp_highlights(mode) local comment = '#75715e' local line_nr = '#90908a' + -- Transparent background for editor + hl(0, 'Normal', { bg = 'none' }) + hl(0, 'NormalNC', { bg = 'none' }) + for _, group in ipairs(diagnostic_groups) do hl(0, group, { fg = fg, bg = bg, underline = false }) end @@ -27,11 +33,19 @@ local function set_lsp_highlights(mode) hl(0, 'TreesitterContext', { bg = bg }) hl(0, 'TreesitterContextLineNumber', { fg = line_nr }) hl(0, 'TreesitterContextSeparator', { fg = comment }) + + -- Notify styling + hl(0, 'NormalFloat', { bg = bg, fg = '#f8f8f2' }) + hl(0, 'FloatBorder', { bg = bg, fg = '#75715e' }) elseif mode == 'light' then local bg = '#fdf6e3' local fg = '#657b83' local comment = '#586e75' + -- Transparent background for editor + hl(0, 'Normal', { bg = 'none' }) + hl(0, 'NormalNC', { bg = 'none' }) + hl(0, 'LspDocumentHighlight', { bg = bg, fg = fg, underline = false }) hl(0, 'DiagnosticVirtualTextError', { fg = '#dc322f' }) hl(0, 'DiagnosticVirtualTextWarn', { fg = '#b58900' }) @@ -41,25 +55,27 @@ local function set_lsp_highlights(mode) hl(0, 'TreesitterContext', { bg = 'NONE' }) hl(0, 'TreesitterContextLineNumber', { fg = comment }) hl(0, 'TreesitterContextSeparator', { fg = comment }) + + -- Notify styling + hl(0, 'NormalFloat', { bg = bg, fg = '#657b83' }) + hl(0, 'FloatBorder', { bg = bg, fg = comment }) end end return { 'f-person/auto-dark-mode.nvim', + lazy = false, + priority = 1000, opts = { update_interval = 2000, set_dark_mode = function() - vim.api.nvim_set_option_value('background', 'dark', {}) - vim.cmd('colorscheme monokai_soda') - - -- Apply custom highlight settings for Monokai + vim.o.background = 'dark' + vim.cmd.colorscheme(themes.dark) set_lsp_highlights('dark') end, set_light_mode = function() - vim.api.nvim_set_option_value('background', 'light', {}) - vim.cmd('colorscheme solarized') - - -- Apply custom highlight settings for Solarized + vim.o.background = 'light' + vim.cmd.colorscheme(themes.light) set_lsp_highlights('light') end, }, diff --git a/lua/custom/plugins/context.lua b/lua/custom/plugins/context.lua old mode 100644 new mode 100755 index dd80393..50f1fc2 --- a/lua/custom/plugins/context.lua +++ b/lua/custom/plugins/context.lua @@ -7,7 +7,7 @@ return { multiwindow = false, multiline_threshold = 1, trim_scope = 'inner', - mode = 'cursor', -- faster than 'cursor' + mode = 'cursor', -- faster than 'topline' separator = '─', on_attach = function(buf) -- disable for large files diff --git a/lua/custom/plugins/copilot-chat.lua b/lua/custom/plugins/copilot-chat.lua old mode 100644 new mode 100755 index 3a7459e..0bf19e9 --- a/lua/custom/plugins/copilot-chat.lua +++ b/lua/custom/plugins/copilot-chat.lua @@ -1,4 +1,3 @@ --- Copilot Chat (UI + prompts for Copilot) return { 'CopilotC-Nvim/CopilotChat.nvim', cmd = { @@ -13,31 +12,23 @@ return { 'CopilotChatToggle', }, keys = { - { 'C', 'CopilotChat', desc = 'Open CopilotChat' }, - { 'Cq', 'CopilotChatClose', desc = 'Close CopilotChat' }, - { 'Ce', 'CopilotChatExplain', desc = 'Explain code', mode = { 'n', 'v' } }, - { 'Cr', 'CopilotChatReview', desc = 'Review code', mode = { 'n', 'v' } }, - { 'Ct', 'CopilotChatTests', desc = 'Generate tests', mode = { 'n', 'v' } }, - { 'Cf', 'CopilotChatRefactor', desc = 'Refactor code', mode = { 'n', 'v' } }, - { 'Co', 'CopilotChatOptimize', desc = 'Optimize code', mode = { 'n', 'v' } }, - { 'Cd', 'CopilotChatDocs', desc = 'Generate docs', mode = { 'n', 'v' } }, - { 'Cp', 'CopilotChatToggle', desc = 'Toggle CopilotChat' }, + { 'CC', 'CopilotChat', desc = 'Open CopilotChat' }, -- fix: was C + { 'Cq', 'CopilotChatClose', desc = 'Close' }, + { 'Ce', 'CopilotChatExplain', desc = 'Explain', mode = { 'n', 'v' } }, + { 'Cr', 'CopilotChatReview', desc = 'Review', mode = { 'n', 'v' } }, + { 'Ct', 'CopilotChatTests', desc = 'Tests', mode = { 'n', 'v' } }, + { 'Cf', 'CopilotChatRefactor', desc = 'Refactor', mode = { 'n', 'v' } }, + { 'Co', 'CopilotChatOptimize', desc = 'Optimize', mode = { 'n', 'v' } }, + { 'Cd', 'CopilotChatDocs', desc = 'Docs', mode = { 'n', 'v' } }, + { 'Cp', 'CopilotChatToggle', desc = 'Toggle' }, }, build = 'make tiktoken', opts = { debug = false, show_help = true, - prompts = { - Explain = 'Please explain how the following code works.', - Review = 'Please review the following code and provide suggestions for improvement.', - Tests = 'Please explain how the selected code works, then generate unit tests for it.', - Refactor = 'Please refactor the following code to improve its clarity and readability.', - Optimize = 'Please optimize the following code for efficiency and performance.', - Docs = 'Please generate documentation for the following code.', - }, }, dependencies = { 'nvim-lua/plenary.nvim', - 'zbirenbaum/copilot.lua', -- make sure copilot is available + 'zbirenbaum/copilot.lua', }, } diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua index 1771de3..0b7ee87 100755 --- a/lua/custom/plugins/copilot.lua +++ b/lua/custom/plugins/copilot.lua @@ -1,17 +1,13 @@ --- GitHub Copilot base plugin return { 'zbirenbaum/copilot.lua', cmd = 'Copilot', - event = 'InsertEnter', + event = 'VeryLazy', -- loads immediately after UI, not blocked on first keypress opts = { - node_cmd = vim.fn.executable('node') == 1 and vim.fn.exepath('node') or 'node', suggestion = { auto_trigger = true, keymap = { accept_word = '', accept_line = '', - -- next = '', - -- previous = '', }, }, }, diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua index f897f9e..257f1ee 100755 --- a/lua/custom/plugins/dadbod.lua +++ b/lua/custom/plugins/dadbod.lua @@ -1,17 +1,17 @@ return { - 'kristijanhusak/vim-dadbod-ui', - dependencies = { - { 'tpope/vim-dadbod', lazy = true }, - { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional - }, - cmd = { - 'DBUI', - 'DBUIToggle', - 'DBUIAddConnection', - 'DBUIFindBuffer', - }, - init = function() - -- Your DBUI configuration - vim.g.db_ui_use_nerd_fonts = 1 - end, + -- 'kristijanhusak/vim-dadbod-ui', + -- dependencies = { + -- { 'tpope/vim-dadbod', lazy = true }, + -- { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional + -- }, + -- cmd = { + -- 'DBUI', + -- 'DBUIToggle', + -- 'DBUIAddConnection', + -- 'DBUIFindBuffer', + -- }, + -- init = function() + -- -- Your DBUI configuration + -- vim.g.db_ui_use_nerd_fonts = 1 + -- end, } diff --git a/lua/custom/plugins/jupytext.lua b/lua/custom/plugins/jupytext.lua old mode 100644 new mode 100755 index 71de7ac..8e806a2 --- a/lua/custom/plugins/jupytext.lua +++ b/lua/custom/plugins/jupytext.lua @@ -1,70 +1,70 @@ return { - 'goerz/jupytext.vim', - lazy = false, - config = function() - vim.g.jupytext_fmt = 'py:percent' - vim.g.jupytext_enable = 1 - vim.g.jupytext_pairing = 1 - - local jupytext_bin = vim.fn.exepath('jupytext') - if jupytext_bin ~= nil and jupytext_bin ~= '' then - vim.g.jupytext_command = jupytext_bin - else - local preferred_python3 = '/opt/homebrew/bin/python3' - local python3_bin = preferred_python3 - if vim.fn.executable(preferred_python3) ~= 1 then - python3_bin = vim.fn.exepath('python3') - end - - if python3_bin ~= nil and python3_bin ~= '' then - vim.g.jupytext_command = python3_bin .. ' -m jupytext' - else - vim.schedule(function() - vim.notify( - 'Jupytext: no `jupytext` or `python3` found in PATH. Install jupytext (e.g. `/opt/homebrew/bin/python3 -m pip install --user jupytext`) or set `vim.g.jupytext_command`.', - vim.log.levels.WARN - ) - end) - end - end - - local jupytext_group = vim.api.nvim_create_augroup('custom_jupytext', { clear = true }) - - vim.api.nvim_create_autocmd('BufWritePost', { - group = jupytext_group, - pattern = '*.py', - callback = function() - local ipynb_file = vim.fn.expand('%:r') .. '.ipynb' - if vim.fn.filereadable(ipynb_file) == 1 then - vim.cmd('silent! Jupytext --sync') - end - end, - }) - - vim.api.nvim_create_autocmd('BufWritePost', { - group = jupytext_group, - pattern = '*.ipynb', - callback = function() - local py_file = vim.fn.expand('%:r') .. '.py' - if vim.fn.filereadable(py_file) == 1 then - vim.cmd('silent! Jupytext --sync') - end - end, - }) - - vim.api.nvim_create_autocmd({ 'BufReadPost', 'BufNewFile' }, { - group = jupytext_group, - pattern = '*.ipynb', - callback = function() - local py_file = vim.fn.expand('%:r') .. '.py' - if vim.fn.filereadable(py_file) == 0 then - vim.cmd('silent! Jupytext --to py:percent') - end - - if vim.fn.filereadable(py_file) == 1 then - vim.cmd('silent! edit ' .. vim.fn.fnameescape(py_file)) - end - end, - }) - end, + -- 'goerz/jupytext.vim', + -- ft = { 'python', 'markdown' }, + -- config = function() + -- vim.g.jupytext_fmt = 'py:percent' + -- vim.g.jupytext_enable = 1 + -- vim.g.jupytext_pairing = 1 + -- + -- local jupytext_bin = vim.fn.exepath('jupytext') + -- if jupytext_bin ~= nil and jupytext_bin ~= '' then + -- vim.g.jupytext_command = jupytext_bin + -- else + -- local preferred_python3 = '/opt/homebrew/bin/python3' + -- local python3_bin = preferred_python3 + -- if vim.fn.executable(preferred_python3) ~= 1 then + -- python3_bin = vim.fn.exepath('python3') + -- end + -- + -- if python3_bin ~= nil and python3_bin ~= '' then + -- vim.g.jupytext_command = python3_bin .. ' -m jupytext' + -- else + -- vim.schedule(function() + -- vim.notify( + -- 'Jupytext: no `jupytext` or `python3` found in PATH. Install jupytext (e.g. `/opt/homebrew/bin/python3 -m pip install --user jupytext`) or set `vim.g.jupytext_command`.', + -- vim.log.levels.WARN + -- ) + -- end) + -- end + -- end + -- + -- local jupytext_group = vim.api.nvim_create_augroup('custom_jupytext', { clear = true }) + -- + -- vim.api.nvim_create_autocmd('BufWritePost', { + -- group = jupytext_group, + -- pattern = '*.py', + -- callback = function() + -- local ipynb_file = vim.fn.expand('%:r') .. '.ipynb' + -- if vim.fn.filereadable(ipynb_file) == 1 then + -- vim.cmd('silent! Jupytext --sync') + -- end + -- end, + -- }) + -- + -- vim.api.nvim_create_autocmd('BufWritePost', { + -- group = jupytext_group, + -- pattern = '*.ipynb', + -- callback = function() + -- local py_file = vim.fn.expand('%:r') .. '.py' + -- if vim.fn.filereadable(py_file) == 1 then + -- vim.cmd('silent! Jupytext --sync') + -- end + -- end, + -- }) + -- + -- vim.api.nvim_create_autocmd({ 'BufReadPost', 'BufNewFile' }, { + -- group = jupytext_group, + -- pattern = '*.ipynb', + -- callback = function() + -- local py_file = vim.fn.expand('%:r') .. '.py' + -- if vim.fn.filereadable(py_file) == 0 then + -- vim.cmd('silent! Jupytext --to py:percent') + -- end + -- + -- if vim.fn.filereadable(py_file) == 1 then + -- vim.cmd('silent! edit ' .. vim.fn.fnameescape(py_file)) + -- end + -- end, + -- }) + -- end, } diff --git a/lua/custom/plugins/monokai.lua b/lua/custom/plugins/monokai.lua index e8c7ae4..e454ca7 100755 --- a/lua/custom/plugins/monokai.lua +++ b/lua/custom/plugins/monokai.lua @@ -1,5 +1,5 @@ return { 'tanvirtin/monokai.nvim', - priority = 1000, + lazy = true, config = function() end, } diff --git a/lua/custom/plugins/render-markdown.lua b/lua/custom/plugins/render-markdown.lua index 5f31277..78f3ead 100755 --- a/lua/custom/plugins/render-markdown.lua +++ b/lua/custom/plugins/render-markdown.lua @@ -4,7 +4,5 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons', }, - opts = { - -- Put any overrides here only if you need them. - }, + opts = {}, } diff --git a/lua/custom/plugins/slime.lua b/lua/custom/plugins/slime.lua index 1816c91..3afd3b0 100755 --- a/lua/custom/plugins/slime.lua +++ b/lua/custom/plugins/slime.lua @@ -1,40 +1,40 @@ return { - 'jpalardy/vim-slime', - ft = { 'python' }, - keys = { - { 'RC', 'SlimeConfig', desc = 'Slime Config' }, - { - 'RS', - function() - if require('custom.user.ipython_utils').is_ipython_open() then - if vim.fn.mode() == 'v' then - -- Visual mode mapping - vim.cmd("'<,'>SlimeSend") - else - -- Normal mode mapping: Execute the SlimeSendCell and move to the next cell delimiter - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('SlimeSendCell', true, true, true), 'm', true) - vim.cmd('normal! /^# %%\\') - end - else - vim.notify('No IPython REPL found. Open an IPython terminal first.', vim.log.levels.WARN) - end - end, - mode = { 'n', 'v' }, - }, - }, - init = function() - vim.g.slime_target = 'neovim' - vim.g.slime_no_mappings = true - end, - config = function() - -- Slime configuration - vim.g.slime_cell_delimiter = '# %%' - vim.g.slime_bracketed_paste = 1 - vim.g.slime_paste_file = os.getenv('HOME') .. '/.slime_paste' - vim.g.slime_input_pid = false - vim.g.slime_suggest_default = true - vim.g.slime_menu_config = false - vim.g.slime_neovim_ignore_unlisted = false - vim.g.slime_python_ipython = 0 - end, + -- 'jpalardy/vim-slime', + -- ft = { 'python' }, + -- keys = { + -- { 'RC', 'SlimeConfig', desc = 'Slime Config' }, + -- { + -- 'RS', + -- function() + -- if require('custom.user.ipython_utils').is_ipython_open() then + -- if vim.fn.mode() == 'v' then + -- -- Visual mode mapping + -- vim.cmd("'<,'>SlimeSend") + -- else + -- -- Normal mode mapping: Execute the SlimeSendCell and move to the next cell delimiter + -- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('SlimeSendCell', true, true, true), 'm', true) + -- vim.cmd('normal! /^# %%\\') + -- end + -- else + -- vim.notify('No IPython REPL found. Open an IPython terminal first.', vim.log.levels.WARN) + -- end + -- end, + -- mode = { 'n', 'v' }, + -- }, + -- }, + -- init = function() + -- vim.g.slime_target = 'neovim' + -- vim.g.slime_no_mappings = true + -- end, + -- config = function() + -- -- Slime configuration + -- vim.g.slime_cell_delimiter = '# %%' + -- vim.g.slime_bracketed_paste = 1 + -- vim.g.slime_paste_file = os.getenv('HOME') .. '/.slime_paste' + -- vim.g.slime_input_pid = false + -- vim.g.slime_suggest_default = true + -- vim.g.slime_menu_config = false + -- vim.g.slime_neovim_ignore_unlisted = false + -- vim.g.slime_python_ipython = 0 + -- end, } diff --git a/lua/custom/plugins/solarized.lua b/lua/custom/plugins/solarized.lua index b24e566..4a44e13 100755 --- a/lua/custom/plugins/solarized.lua +++ b/lua/custom/plugins/solarized.lua @@ -1,6 +1,6 @@ return { 'shaunsingh/solarized.nvim', - event = 'VeryLazy', + lazy = true, config = function() vim.g.solarized_variant = 'light' end, diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua index a7d79b8..b316ea7 100755 --- a/lua/custom/plugins/undotree.lua +++ b/lua/custom/plugins/undotree.lua @@ -1,5 +1,6 @@ return { 'mbbill/undotree', + cmd = 'UndotreeToggle', config = function() -- Set Undotree to open on the right side vim.g.undotree_WindowLayout = 4 diff --git a/lua/custom/plugins/venv-selector.lua b/lua/custom/plugins/venv-selector.lua index a3969c5..6b9beb3 100755 --- a/lua/custom/plugins/venv-selector.lua +++ b/lua/custom/plugins/venv-selector.lua @@ -4,14 +4,13 @@ return { dependencies = { 'neovim/nvim-lspconfig', 'nvim-telescope/telescope.nvim', - -- Remove nvim-dap-python from here - it's defined separately }, opts = { settings = { options = { activate_venv_in_terminal = true, - notify_user_on_venv_activation = true, - debug = true, + notify_user_on_venv_activation = false, -- stops pulling nvim-notify at BufReadPre + debug = false, -- also turn off debug in production, it's noisy and slow }, search = { pyenv = { diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua index 94477b1..20b9f3b 100755 --- a/lua/custom/plugins/vimtex.lua +++ b/lua/custom/plugins/vimtex.lua @@ -1,7 +1,6 @@ return { 'lervag/vimtex', ft = { 'tex', 'latex', 'cls', 'sty', 'bib' }, - lazy = false, init = function() -- macOS PDF viewer - Skim is better than Zathura on macOS vim.g.vimtex_view_method = 'skim'