Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify list_insert_unique usages #175

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
-- add regex to treesitters
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "regex")
end
-- Add the "regex" parser to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "regex")
end,
},
}
22 changes: 4 additions & 18 deletions lua/astrocommunity/pack/astro/astro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,17 @@ return {
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "astro")
end
-- Add the required file types to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "astro")
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add tsserver to opts.ensure_installed using vim.list_extend.
utils.list_insert_unique(opts.ensure_installed, "astro")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "astro") end,
},
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add to opts.ensure_installed using table.insert.
utils.list_insert_unique(opts.ensure_installed, "js")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "js") end,
},
}
28 changes: 5 additions & 23 deletions lua/astrocommunity/pack/bash/bash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,23 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "bash")
end
-- Add the "julia" and "toml" language to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "bash")
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add julia lsp and toml lsp to ensure_installed
utils.list_insert_unique(opts.ensure_installed, "bashls")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "bashls") end,
},
{
"jay-babu/mason-null-ls.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add julia lsp and toml lsp to ensure_installed
utils.list_insert_unique(opts.ensure_installed, { "shellcheck", "shfmt" })
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "shellcheck", "shfmt" })
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add julia lsp and toml lsp to ensure_installed
utils.list_insert_unique(opts.ensure_installed, "bash")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "bash") end,
},
}
14 changes: 3 additions & 11 deletions lua/astrocommunity/pack/cmake/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "cmake")
end
utils.list_insert_unique(opts.ensure_installed, "cmake")
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "neocmake")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "neocmake") end,
},
}
17 changes: 4 additions & 13 deletions lua/astrocommunity/pack/dart/dart.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "dart")
end
-- Add the "dart" and "yaml" language to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "dart")
end,
},
{
"akinsho/flutter-tools.nvim",
ft = { "dart" },
init = function() utils.list_insert_unique(astronvim.lsp.skip_setup, "dartls") end,
init = function() astronvim.lsp.skip_setup = utils.list_insert_unique(astronvim.lsp.skip_setup, "dartls") end,
opts = {
lsp = require("astronvim.utils.lsp").config "dartls",
debugger = {
Expand All @@ -28,11 +23,7 @@ return {
{ "nvim-lua/plenary.nvim" },
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "dart")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "dart") end,
},
},
},
Expand Down
27 changes: 6 additions & 21 deletions lua/astrocommunity/pack/go/go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,22 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "go")
end
-- Add the "go" language to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "go")
end,
},

{
"jay-babu/mason-null-ls.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add go lsps to opts.ensure_installed using vim.list_extend.
utils.list_insert_unique(opts.ensure_installed, { "gomodifytags", "gofumpt", "iferr", "impl", "goimports" })
opts.ensure_installed =
utils.list_insert_unique(opts.ensure_installed, { "gomodifytags", "gofumpt", "iferr", "impl", "goimports" })
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "gopls")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "gopls") end,
},
{
"leoluz/nvim-dap-go",
Expand All @@ -39,11 +28,7 @@ return {
"mfussenegger/nvim-dap",
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "delve")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "delve") end,
},
},
opts = {},
Expand Down
23 changes: 5 additions & 18 deletions lua/astrocommunity/pack/haskell/haskell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "haskell")
end
-- ensure haskell treesitter installed
utils.list_insert_unique(opts.ensure_installed, "haskell")
end,
},
{
"mrcjkb/haskell-tools.nvim",
ft = { "haskell" },
branch = "1.x.x", -- reccomended by haskell-tools
init = function() utils.list_insert_unique(astronvim.lsp.skip_setup, "hls") end,
init = function() astronvim.lsp.skip_setup = utils.list_insert_unique(astronvim.lsp.skip_setup, "hls") end,
opts = {
hls = {
on_attach = function(client, bufnr) require("astronvim.utils.lsp").on_attach(client, bufnr) end,
Expand All @@ -37,20 +32,12 @@ return {
-- TODO: Need haskell to be pulled into mason-nvim-dap (haskell hopefully coming soon)
-- {
-- "jay-babu/mason-nvim-dap.nvim",
-- opts = function(_, opts)
-- -- Ensure that opts.ensure_installed exists and is a table.
-- if not opts.ensure_installed then opts.ensure_installed = {} end
-- utils.list_insert_unique(opts.ensure_installed, "haskell-dap")
-- end,
-- opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "haskell") end,
-- },
mehalter marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "hls")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "hls") end,
},
}
4 changes: 1 addition & 3 deletions lua/astrocommunity/pack/haxe/haxe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ return {
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "haxe_language_server")
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "haxe_language_server")
end,
},
}
29 changes: 6 additions & 23 deletions lua/astrocommunity/pack/java/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,34 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "java", "html" })
end
-- Add the "java" and "html" language to opts.ensure_installed.
-- XML does not have it's own treesitter plugin so HTML can take over if necessary
utils.list_insert_unique(opts.ensure_installed, { "java", "html" })
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add jdtls and lemminx lsps to opts.ensure_installed using vim.list_extend.
utils.list_insert_unique(opts.ensure_installed, { "jdtls", "lemminx" })
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "jdtls", "lemminx" })
end,
},

{
"jay-babu/mason-null-ls.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add clang_format to opts.ensure_installed
utils.list_insert_unique(opts.ensure_installed, { "clang_format" })
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "clang_format") end,
},

{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add javadgb to required
utils.list_insert_unique(opts.ensure_installed, { "javadbg", "javatest" })
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "javadbg", "javatest" })
end,
},

{
"mfussenegger/nvim-jdtls",
ft = { "java" },
init = function() utils.list_insert_unique(astronvim.lsp.skip_setup, "jdtls") end,
init = function() astronvim.lsp.skip_setup = utils.list_insert_unique(astronvim.lsp.skip_setup, "jdtls") end,
opts = function(_, opts)
-- use this function notation to build some variables
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle", ".project" }
Expand Down
14 changes: 3 additions & 11 deletions lua/astrocommunity/pack/json/json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "json", "jsonc" })
end
utils.list_insert_unique(opts.ensure_installed, { "json", "jsonc" })
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "jsonls")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "jsonls") end,
},
}
16 changes: 3 additions & 13 deletions lua/astrocommunity/pack/julia/julia.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "julia")
end
-- Add the "julia" and "toml" language to opts.ensure_installed.
utils.list_insert_unique(opts.ensure_installed, "julia")
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table
if not opts.ensure_installed then opts.ensure_installed = {} end
-- Add julia lsp and toml lsp to ensure_installed
utils.list_insert_unique(opts.ensure_installed, "julials")
end,
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "julials") end,
},
{
"hrsh7th/nvim-cmp",
Expand Down
Loading