mage: support target in multiple categories

This commit is contained in:
Hoang Nguyen 2023-11-25 00:00:00 +07:00
parent 7f661a0e20
commit 73f9cc17a7
Signed by: folliehiyuki
GPG key ID: B0567C20730E9B11
5 changed files with 62 additions and 58 deletions

2
go.mod
View file

@ -3,7 +3,7 @@ module nvim
go 1.20
require (
github.com/go-playground/validator/v10 v10.15.5
github.com/go-playground/validator/v10 v10.16.0
github.com/goccy/go-yaml v1.11.2
github.com/magefile/mage v1.15.0
github.com/sirupsen/logrus v1.9.3

4
go.sum
View file

@ -12,8 +12,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE=
github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-yaml v1.11.2 h1:joq77SxuyIs9zzxEjgyLBugMQ9NEgTWxXfz2wVqwAaQ=
github.com/goccy/go-yaml v1.11.2/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=

View file

@ -1,7 +1,7 @@
{
"LuaSnip": { "branch": "master", "commit": "1f4ad8bb72bdeb60975e98652636b991a9b7475d" },
"SchemaStore.nvim": { "branch": "main", "commit": "9fb873af43568464f9a1936fc334dfa3d7a59418" },
"aerial.nvim": { "branch": "master", "commit": "d82a994d66a9c6c700f240498304bd6d68fb33f0" },
"LuaSnip": { "branch": "master", "commit": "cab667e2674881001a86a7478fff7dc7791c63f5" },
"SchemaStore.nvim": { "branch": "main", "commit": "6316dc88db89d97d190f24547adddd13569fb746" },
"aerial.nvim": { "branch": "master", "commit": "712802e73107883a445b36f4197376eb60691b85" },
"alpha-nvim": { "branch": "main", "commit": "234822140b265ec4ba3203e3e0be0e0bb826dff5" },
"better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" },
"carbon-now.nvim": { "branch": "main", "commit": "16e843489ba00493466170919abfe144fc9aa158" },
@ -12,15 +12,15 @@
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "a36c68d2cd551e49883ddb2492c178d915567f58" },
"conform.nvim": { "branch": "master", "commit": "fd32ed2dc192ec656a0536699336cd2fe3eb543f" },
"dial.nvim": { "branch": "master", "commit": "019bbe9daea397c93a99adc747f8f071379fee5c" },
"diffview.nvim": { "branch": "main", "commit": "d38c1b5266850f77f75e006bcc26213684e1e141" },
"diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" },
"dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" },
"emmylua-nvim": { "branch": "master", "commit": "50b2eead8af6499fbba708553148ee8156d6612e" },
"emmylua-nvim": { "branch": "master", "commit": "3a5e3eafa93e2ab0fb1712ad3d61faabb8abc524" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"git-conflict.nvim": { "branch": "main", "commit": "896261933afe2fddf6fb043d9cd4d88301b151a9" },
"gitsigns.nvim": { "branch": "main", "commit": "0ccd5fb2316b3f8d8b2f775bc31cae7bc6a77a55" },
"gitsigns.nvim": { "branch": "main", "commit": "5fc573f2d2a49aec74dd6dc977e8b137429d1897" },
"headlines.nvim": { "branch": "master", "commit": "e3d7bfdf40e41a020d966d35f8b48d75b90367d2" },
"heirline.nvim": { "branch": "master", "commit": "7f1e805dfc001d5dbb7d894105063f463f6c7dcc" },
"inc-rename.nvim": { "branch": "main", "commit": "ed0f6f2b917cac4eb3259f907da0a481b27a3b7e" },
@ -39,7 +39,7 @@
"mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" },
"neoconf.nvim": { "branch": "main", "commit": "64437787dba70fce50dad7bfbb97d184c5bc340f" },
"neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" },
"neogit": { "branch": "master", "commit": "987e415247547a372d0356f76444cf402436c727" },
"neogit": { "branch": "master", "commit": "3be926866a6fdee86f53c13455c9b106f85ca3dc" },
"neotest": { "branch": "master", "commit": "d424d262d01bccc1e0b038c9a7220a755afd2a1f" },
"neotest-go": { "branch": "main", "commit": "1a15e1136db43775214a3e7a598f8930c29c94b7" },
"neotest-jest": { "branch": "main", "commit": "d8b00a91e440474da20a8e9acdb0d72051078b8b" },
@ -54,46 +54,46 @@
"nvim-dap": { "branch": "master", "commit": "e154fdb6d70b3765d71f296e718b29d8b7026a63" },
"nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "57f1dbd0458dd84a286b27768c142e1567f3ce3b" },
"nvim-lint": { "branch": "master", "commit": "15fcab91e6a4e2a3e41dc55c5b3471f66c11ce39" },
"nvim-lspconfig": { "branch": "master", "commit": "7384e7149e79365c96dc623d9fa3444737776982" },
"nvim-lint": { "branch": "master", "commit": "3a7c15331a57ba40a56f00f29173700af853fa03" },
"nvim-lspconfig": { "branch": "master", "commit": "553c4e0e667167640c5398573f6f3a488ff8047a" },
"nvim-navic": { "branch": "master", "commit": "0ffa7ffe6588f3417e680439872f5049e38a24db" },
"nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" },
"nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" },
"nvim-spectre": { "branch": "master", "commit": "a18a58015b46f02b4fe537ebfffd82e46110ff24" },
"nvim-tree.lua": { "branch": "master", "commit": "8f9169a05931041aad1a0719e82eb02cea528881" },
"nvim-treesitter": { "branch": "master", "commit": "f2de95e30aac507bf7fa785e13a8edcbdc604605" },
"nvim-treesitter-context": { "branch": "master", "commit": "f3ec0d8a1b4e07d7ed2da6b9a9f10864a83c4be4" },
"nvim-tree.lua": { "branch": "master", "commit": "fa00b57873008700a83c1387f02ef2c6fc183b53" },
"nvim-treesitter": { "branch": "master", "commit": "649d137371e9214d30b20565e0574824fa3a3670" },
"nvim-treesitter-context": { "branch": "master", "commit": "bf4d15ee4e96ff5201f16a4ed14443670662eb90" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "ead792ccdace6a9d64a8119909af243ed0105465" },
"nvim-web-devicons": { "branch": "master", "commit": "e2f6e0e299e193d7e9c48634d355f7a6eb3020b4" },
"orgmode": { "branch": "master", "commit": "e9c08d58c13372981815d207c78763e5beac32d4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "b8ff464f2afc2000f6c72fa331a8fc090cb46b39" },
"nvim-web-devicons": { "branch": "master", "commit": "cdbcca210cf3655aa9b31ebf2422763ecd85ee5c" },
"orgmode": { "branch": "master", "commit": "cbb10d4c7514680e90f791d62f1168cb87aad0ce" },
"overseer.nvim": { "branch": "master", "commit": "6f462a61ce9a5f47743cbf78454bed14a855eb03" },
"pantran.nvim": { "branch": "main", "commit": "461799624948bfb66f73b20b6fffa7e4c8ca6d08" },
"parinfer-rust": { "branch": "master", "commit": "0e4d52e712641ad351a1bfe6cee3d34d63ed087b" },
"persistence.nvim": { "branch": "main", "commit": "ad538bfd5336f1335cdb6fd4e0b0eebfa6e12f32" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"plenary.nvim": { "branch": "master", "commit": "c47e1a21d235a422034012935febd2d078d77ac6" },
"project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "f1d4bab54013ea4275522e42b5ffd9ac11f189f4" },
"rest.nvim": { "branch": "main", "commit": "b8d6c0a8762fd374e0204768a94241135ca3e311" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "a2da59bdacb5e3a28873ac7039a16271ac16b224" },
"rest.nvim": { "branch": "main", "commit": "c186d3e5bc5f962fd026daf087fec8364101db57" },
"scope.nvim": { "branch": "main", "commit": "cd27af77ad61a7199af5c28d27013fb956eb0e3e" },
"sniprun": { "branch": "master", "commit": "7a8bc30fcf04fd4efec43be368f12eb4266fabf6" },
"ssr.nvim": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" },
"stickybuf.nvim": { "branch": "master", "commit": "f3398f8639e903991acdf66e2d63de7a78fe708e" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "f41675fddb1ea9003187d07ecc627a8bf8292633" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" },
"telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" },
"telescope-tabs": { "branch": "master", "commit": "a38c8fee471257a0ff233e065c4a0d123f8e67b0" },
"telescope.nvim": { "branch": "master", "commit": "18774ec7929c8a8003a91e9e1f69f6c32258bbfe" },
"todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" },
"toggleterm.nvim": { "branch": "main", "commit": "c80844fd52ba76f48fabf83e2b9f9b93273f418d" },
"toggleterm.nvim": { "branch": "main", "commit": "fb0c365534e7ee327b30205beff3f3a708dcba33" },
"treesj": { "branch": "main", "commit": "1d6e89f4790aa04eaae38fa9460a3ee191961c96" },
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" },
"twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" },
"undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" },
"venn.nvim": { "branch": "main", "commit": "e4d68341a73dd56c64955058821a58295fb337b1" },
"vim-log-highlighting": { "branch": "master", "commit": "1037e26f3120e6a6a2c0c33b14a84336dee2a78f" },
"vim-matchup": { "branch": "master", "commit": "d30b72d20f01478a8486f15a57c89fe3177373db" },
"vim-matchup": { "branch": "master", "commit": "9e2ced98255cd03e1beaf7debe015fa211269cb5" },
"vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" },
"vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" },

View file

@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"sort"
"strings"
@ -28,7 +29,7 @@ import (
type Target struct {
Env map[string]string `yaml:"env,omitempty" validate:"excluded_unless=Type custom,omitempty,min=1,dive,keys,min=1,endkeys,required"`
Type string `yaml:"type" validate:"required,oneof=python nodejs custom"`
Category string `yaml:"category" validate:"required,oneof=lsp dap lint"`
Category []string `yaml:"category" validate:"required,min=1,dive,oneof=lsp dap lint"`
Pkgs []string `yaml:"pkgs,omitempty" validate:"excluded_if=Type custom,omitempty,min=1,dive,min=1"`
Script []string `yaml:"script,omitempty" validate:"required_if=Type custom,omitempty,min=1,dive,min=1"`
}
@ -75,12 +76,14 @@ func List() {
}
for target, spec := range targets {
switch spec.Category {
case "lsp":
// NOTE: there will be duplications (.e.g elixirls), but it is fine
if slices.Contains(spec.Category, "lsp") {
categories["LSP servers"] = append(categories["LSP servers"], target)
case "dap":
}
if slices.Contains(spec.Category, "dap") {
categories["DAP servers"] = append(categories["DAP servers"], target)
case "lint":
}
if slices.Contains(spec.Category, "lint") {
categories["Linters/Formatters"] = append(categories["Linters/Formatters"], target)
}
}
@ -192,7 +195,7 @@ func filterTargets(targets map[string]Target, category string) []string {
result := []string{}
for name, spec := range targets {
// Treat `all` as matching everything
if spec.Category == category || category == "all" {
if slices.Contains(spec.Category, category) || category == "all" {
result = append(result, name)
}
}
@ -228,7 +231,7 @@ func install(targets map[string]Target, target string) error {
if !ok {
data_dir = filepath.Join(os.Getenv("HOME"), ".local", "share")
}
install_dir := filepath.Join(data_dir, "nvim", spec.Category, target)
install_dir := filepath.Join(data_dir, "nvim", spec.Category[0], target)
// Create the parent directory to install packages into (in the case of `python` or `nodejs`).
// For `custom` type, the script should make this directory in its own way

View file

@ -2,31 +2,13 @@
# DAP servers ====================================
debugpy:
category: dap
category: [dap]
type: python
# LSP servers ====================================
ansiblels: &nodejs_lsp
category: lsp
type: nodejs
pkgs: ['@ansible/ansible-language-server']
awk_ls:
<<: *nodejs_lsp
pkgs: [awk-language-server]
bashls:
<<: *nodejs_lsp
pkgs: [bash-language-server]
dockerls:
<<: *nodejs_lsp
pkgs: [dockerfile-language-server-nodejs]
# NOTE: elixirls also supports DAP, but keep it in `lsp` category
elixirls:
category: lsp
category:
- lsp
- dap
type: custom
env:
MIX_ENV: prod
@ -42,6 +24,25 @@ elixirls:
- mix compile
- mix elixir_ls.release2 -o release/
# LSP servers ====================================
ansiblels: &nodejs_lsp
category: [lsp]
type: nodejs
pkgs: ['@ansible/ansible-language-server']
awk_ls:
<<: *nodejs_lsp
pkgs: [awk-language-server]
bashls:
<<: *nodejs_lsp
pkgs: [bash-language-server]
dockerls:
<<: *nodejs_lsp
pkgs: [dockerfile-language-server-nodejs]
emmet_language_server:
<<: *nodejs_lsp
pkgs: ['@olrtg/emmet-language-server']
@ -51,7 +52,7 @@ mdx_analyzer:
pkgs: ['@mdx-js/language-server']
pylsp:
category: lsp
category: [lsp]
type: python
pkgs:
- python-lsp-server[all]
@ -63,7 +64,7 @@ pylsp:
# - python-lsp-black
ruff_lsp:
category: lsp
category: [lsp]
type: python
pkgs: [ruff-lsp]
@ -102,11 +103,11 @@ yamlls:
# Linters & Formatters ===========================
codespell: &python_lint
category: lint
category: [lint]
type: python
cspell: &nodejs_lint
category: lint
category: [lint]
type: nodejs
proselint: *python_lint