From 53d06709b2d3757eb061e36161906df378e73055 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 9 Aug 2026 12:18:18 -0500 Subject: [PATCH] use mason for dependency management --- common.sh | 16 ++++++---- nvim/lua/darcula/config/init.lua | 7 ++++ nvim/lua/darcula/keymaps.lua | 10 ++---- nvim/lua/darcula/plugins.lua | 8 ++--- nvim/lua/darcula/setup.lua | 2 +- nvim/lua/darcula/setup/050_mason.lua | 48 ++++++++++++++++++++++++++++ nvim/lua/darcula/setup/100_mason.lua | 28 ++-------------- 7 files changed, 75 insertions(+), 44 deletions(-) create mode 100644 nvim/lua/darcula/setup/050_mason.lua diff --git a/common.sh b/common.sh index 0fba2e6..54968e8 100755 --- a/common.sh +++ b/common.sh @@ -83,6 +83,14 @@ function check_binary() { fi } +function ensure_brew_binary() { + if ! command -v "$1" >/dev/null 2>&1; then + check_binary brew + brew install "$2" + fi + check_binary "$1" +} + export PATH="${HOME}/.local/bin:${PATH}" for BINARY in "${NVIM_REQUIRED_BINARIES[@]}"; do @@ -94,13 +102,9 @@ if ! command -v luafmt >/dev/null 2>&1; then fi check_binary luafmt -if [ "${NVIM_OS}" = "macOS" ] && - ! command -v vala-language-server >/dev/null 2>&1; then - check_binary brew - brew install vala-language-server -fi if [ "${NVIM_OS}" = "macOS" ]; then - check_binary vala-language-server + ensure_brew_binary pwsh powershell + ensure_brew_binary vala-language-server vala-language-server fi pushd "${SCRIPT_DIR}" 1>/dev/null 2>&1 || error_exit "failed to push: ${SCRIPT_DIR}" diff --git a/nvim/lua/darcula/config/init.lua b/nvim/lua/darcula/config/init.lua index 40ae930..ac991d3 100644 --- a/nvim/lua/darcula/config/init.lua +++ b/nvim/lua/darcula/config/init.lua @@ -38,6 +38,13 @@ NV_DARCULA_ENABLE_INLAY_HINTS = utils.parse_env("NV_DARCULA_ENABLE_INLAY_HINTS", false) NV_DARCULA_ENABLE_VIRTUAL_TEXT = utils.parse_env("NV_DARCULA_ENABLE_VIRTUAL_TEXT", false) +NV_DARCULA_MASON_ROOT = + utils.parse_env( + "NV_DARCULA_MASON_ROOT", + vim.fs.normalize( + vim.fs.joinpath(vim.fn.stdpath("data"), "..", "darcula", "mason") + ) +) NV_DARCULA_CLANGD_ARGS = utils.parse_env_list( diff --git a/nvim/lua/darcula/keymaps.lua b/nvim/lua/darcula/keymaps.lua index 54d145f..7eb2e4b 100644 --- a/nvim/lua/darcula/keymaps.lua +++ b/nvim/lua/darcula/keymaps.lua @@ -719,10 +719,8 @@ if not NV_DARCULA_ENABLE_COC then end end -if not NV_DARCULA_ENABLE_COC then - function M.mason() - km.map(km.leader "in", ":Mason", {remap = true, silent = true}) - end +function M.mason() + km.map(km.leader "in", ":Mason", {remap = true, silent = true}) end function M.navigation() @@ -1453,9 +1451,7 @@ end if not NV_DARCULA_ENABLE_COC then M.lsp() end - if not NV_DARCULA_ENABLE_COC then - M.mason() - end + M.mason() M.navigation() M.nvim_dap() M.nvim_haven() diff --git a/nvim/lua/darcula/plugins.lua b/nvim/lua/darcula/plugins.lua index 548afeb..8b2e58f 100644 --- a/nvim/lua/darcula/plugins.lua +++ b/nvim/lua/darcula/plugins.lua @@ -57,7 +57,10 @@ vim.api.nvim_create_autocmd( local packages = { {src = "https://github.com/nvim-lua/plenary.nvim"}, {src = "https://github.com/rktjmp/lush.nvim"}, - {src = "https://git.fifthgrid.com/sgraves/darcula_lush"} + {src = "https://git.fifthgrid.com/sgraves/darcula_lush"}, + {src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim"}, + {src = "https://github.com/mason-org/mason-lspconfig.nvim"}, + {src = "https://github.com/mason-org/mason.nvim"} } if NV_DARCULA_ENABLE_COC then @@ -81,11 +84,8 @@ else {src = "https://github.com/hrsh7th/cmp-path"}, {src = "https://github.com/rafamadriz/friendly-snippets"}, {src = "https://github.com/neovim/nvim-lspconfig"}, - {src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim"}, {src = "https://github.com/akinsho/flutter-tools.nvim"}, {src = "https://github.com/kosayoda/nvim-lightbulb"}, - {src = "https://github.com/mason-org/mason-lspconfig.nvim"}, - {src = "https://github.com/mason-org/mason.nvim"}, {src = "https://github.com/ray-x/lsp_signature.nvim"} } ) diff --git a/nvim/lua/darcula/setup.lua b/nvim/lua/darcula/setup.lua index a3d1b59..3e9f8ee 100644 --- a/nvim/lua/darcula/setup.lua +++ b/nvim/lua/darcula/setup.lua @@ -21,6 +21,6 @@ local setup_list = require("darcula.utils").get_files_sorted_without_extension( vim.fs.joinpath(vim.fn.stdpath("config"), "lua", "darcula", "setup") ) -for _, name in pairs(setup_list) do +for _, name in ipairs(setup_list) do require("darcula.setup." .. name) end diff --git a/nvim/lua/darcula/setup/050_mason.lua b/nvim/lua/darcula/setup/050_mason.lua new file mode 100644 index 0000000..f38184c --- /dev/null +++ b/nvim/lua/darcula/setup/050_mason.lua @@ -0,0 +1,48 @@ +-- The MIT License (MIT) +-- +-- Copyright © 2026 Scott E. Graves +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software +-- and associated documentation files (the “Software”), to deal in the Software without restriction, +-- including without limitation the rights to use, copy, modify, merge, publish, distribute, +-- sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in all copies or +-- substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +-- BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-- +local symbols = require("darcula.utils.symbols") + +require("mason").setup { + install_root_dir = NV_DARCULA_MASON_ROOT, + PATH = "prepend", + ui = { + border = "rounded", + icons = { + package_installed = symbols.status.ok, + package_pending = symbols.status.checking, + package_uninstalled = symbols.status.uninstalled + } + } +} + +local ensure_installed = vim.deepcopy(NV_DARCULA_MASON_INST_LIST) +vim.list_extend(ensure_installed, NV_DARCULA_MASON_TOOL_LIST) + +local installer = require("mason-tool-installer") +installer.setup { + ensure_installed = ensure_installed, + integrations = { + ["mason-lspconfig"] = true, + ["mason-null-ls"] = false, + ["mason-nvim-dap"] = false + }, + run_on_start = false +} +installer.check_install(false, true) diff --git a/nvim/lua/darcula/setup/100_mason.lua b/nvim/lua/darcula/setup/100_mason.lua index 85360dd..263ec84 100644 --- a/nvim/lua/darcula/setup/100_mason.lua +++ b/nvim/lua/darcula/setup/100_mason.lua @@ -21,29 +21,11 @@ if NV_DARCULA_ENABLE_COC then return end -local symbols = require("darcula.utils.symbols") ---@diagnostic disable-next-line: deprecated local unpacker = table.unpack or unpack -require("mason").setup { - ui = { - border = "rounded", - icons = { - package_installed = symbols.status.ok, - package_pending = symbols.status.checking, - package_uninstalled = symbols.status.uninstalled - } - } -} - require("mason-lspconfig").setup { - automatic_enable = NV_DARCULA_MASON_LSP_LIST, - ensure_installed = NV_DARCULA_MASON_INST_LIST -} - -require("mason-tool-installer").setup { - ensure_installed = NV_DARCULA_MASON_TOOL_LIST, - run_on_start = true + automatic_enable = NV_DARCULA_MASON_LSP_LIST } local capabilities = require("cmp_nvim_lsp").default_capabilities() @@ -83,13 +65,7 @@ for _, name in pairs(NV_DARCULA_MASON_LSP_LIST) do ) elseif name == "jdtls" then local lombok = - vim.fs.joinpath( - vim.fn.stdpath("data"), - "mason", - "packages", - "jdtls", - "lombok.jar" - ) + vim.fs.joinpath(NV_DARCULA_MASON_ROOT, "packages", "jdtls", "lombok.jar") vim.env.JDTLS_JVM_ARGS = table.concat( {