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 <noreply@anthropic.com>
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user