From 2a0813b8617d6d8fdf9a3670b66fecbaea054281 Mon Sep 17 00:00:00 2001 From: Rob Harbaugh Date: Wed, 22 Apr 2026 09:58:28 -0400 Subject: [PATCH] Gate laptop/work language packs behind stow-loaded modules Neovim now loads either laptop-languages.lua or work-languages.lua depending on which stow packages are active. Work mode suppresses Rust/Go/C/C++/LaTeX servers, DAP, and vimtex entirely via cond guards. Co-Authored-By: Claude Sonnet 4.6 --- laptop/.config/nvim/init.lua | 67 ++++++++++++-------- laptop/.config/nvim/lua/laptop-languages.lua | 17 +++++ 2 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 laptop/.config/nvim/lua/laptop-languages.lua diff --git a/laptop/.config/nvim/init.lua b/laptop/.config/nvim/init.lua index a4f77c1..3b8ad39 100644 --- a/laptop/.config/nvim/init.lua +++ b/laptop/.config/nvim/init.lua @@ -5,9 +5,14 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = '\\' -- vimtex uses \ll, \lv, etc. vim.g.have_nerd_font = true --- Load work-language extras when the work stow package is active +-- work-languages.lua (work stow) → work mode; laptop-languages.lua → laptop mode. +-- The two are mutually exclusive: work mode suppresses laptop languages. local _work = {} pcall(function() _work = require('work-languages') end) +local _lang = {} +if not next(_work) then + pcall(function() _lang = require('laptop-languages') end) +end ------------------------------------------------------------------------------- -- Options @@ -262,11 +267,12 @@ require('lazy').setup({ build = ':TSUpdate', main = 'nvim-treesitter.configs', opts = { - ensure_installed = vim.list_extend( - { 'bash', 'c', 'cpp', 'go', 'json', 'lua', 'luadoc', 'markdown', - 'markdown_inline', 'rust', 'vim', 'vimdoc', 'yaml', 'latex' }, - _work.parsers or {} - ), + ensure_installed = (function() + local t = { 'bash', 'json', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'vim', 'vimdoc', 'yaml' } + vim.list_extend(t, _lang.parsers or {}) + vim.list_extend(t, _work.parsers or {}) + return t + end)(), auto_install = true, highlight = { enable = true }, indent = { enable = true }, @@ -379,13 +385,11 @@ require('lazy').setup({ }, }, opts = { - formatters_by_ft = vim.tbl_extend('force', { - lua = { 'stylua' }, - go = { 'goimports', 'gofmt' }, - rust = { 'rustfmt' }, - c = { 'clang_format' }, - cpp = { 'clang_format' }, - }, _work.formatters or {}), + formatters_by_ft = vim.tbl_extend('force', + { lua = { 'stylua' } }, + _lang.formatters or {}, + _work.formatters or {} + ), format_on_save = { timeout_ms = 500, lsp_fallback = true }, }, }, @@ -453,26 +457,30 @@ require('lazy').setup({ require('cmp_nvim_lsp').default_capabilities() ) - local servers = vim.tbl_extend('force', { - clangd = {}, - gopls = {}, - rust_analyzer = {}, - lua_ls = { - settings = { - Lua = { - completion = { callSnippet = 'Replace' }, - diagnostics = { globals = { 'vim', 'Snacks' } }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true), - checkThirdParty = false, + local servers = vim.tbl_extend('force', + { + lua_ls = { + settings = { + Lua = { + completion = { callSnippet = 'Replace' }, + diagnostics = { globals = { 'vim', 'Snacks' } }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + checkThirdParty = false, + }, }, }, }, }, - }, _work.servers or {}) + _lang.servers or {}, + _work.servers or {} + ) require('mason-tool-installer').setup({ - ensure_installed = vim.list_extend({ 'stylua', 'clang-format' }, _work.tools or {}), + ensure_installed = vim.list_extend( + vim.list_extend({ 'stylua' }, _lang.tools or {}), + _work.tools or {} + ), }) require('mason-lspconfig').setup({ @@ -493,6 +501,7 @@ require('lazy').setup({ -------------------------------------------------------------------------- { 'mfussenegger/nvim-dap', + cond = function() return not next(_work) end, dependencies = { { 'rcarriga/nvim-dap-ui', @@ -548,9 +557,10 @@ require('lazy').setup({ }, }, - -- install codelldb via mason + -- install codelldb via mason (laptop only) { 'williamboman/mason.nvim', + cond = function() return not next(_work) end, opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} vim.list_extend(opts.ensure_installed, { 'codelldb' }) @@ -562,6 +572,7 @@ require('lazy').setup({ -------------------------------------------------------------------------- { 'lervag/vimtex', + cond = function() return not next(_work) end, lazy = false, init = function() vim.g.vimtex_view_method = 'zathura' diff --git a/laptop/.config/nvim/lua/laptop-languages.lua b/laptop/.config/nvim/lua/laptop-languages.lua new file mode 100644 index 0000000..16debd6 --- /dev/null +++ b/laptop/.config/nvim/lua/laptop-languages.lua @@ -0,0 +1,17 @@ +-- Loaded by init.lua when work-languages.lua is absent (laptop stow only). +-- Mirrors dev-settings.el: C/C++, Go, Rust, DAP. +return { + servers = { + clangd = {}, + gopls = {}, + rust_analyzer = {}, + }, + parsers = { 'c', 'cpp', 'go', 'latex', 'rust' }, + formatters = { + go = { 'goimports', 'gofmt' }, + rust = { 'rustfmt' }, + c = { 'clang_format' }, + cpp = { 'clang_format' }, + }, + tools = { 'clang-format' }, +}