add helper function for language specific plugins

This commit is contained in:
Daylin Morgan 2024-06-14 14:14:58 -05:00
parent da2045c78a
commit 92be866971
Signed by: daylin
GPG key ID: 950D13E9719334AD
10 changed files with 33 additions and 60 deletions

View file

@ -10,3 +10,9 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.md" },
command = "set conceallevel=0",
})
-- make .roc files have the correct filetype
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.roc" },
command = "set filetype=roc",
})

View file

@ -1,9 +1,5 @@
if not vim.fn.executable("go") then
return
end
-- adapted from https://www.lazyvim.org/extras/lang/go
return {
return require("util").if_exe("go", {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@ -93,4 +89,4 @@ return {
vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt", "gomodifytags", "impl", "delve" })
end,
},
}
})

View file

@ -1,4 +1,3 @@
return {
{ "alaviss/nim.nvim" },
{ "raivivek/vim-snakemake" },
}

View file

@ -1,9 +1,8 @@
if not vim.fn.executable("nim") then
return
end
local util = require("util")
return {
require("util").setup_lang({ treesitter = { "nim", "nim_format_string" } }),
return util.if_exe("nim", {
util.setup_lang({ treesitter = { "nim", "nim_format_string" } }),
{ "alaviss/nim.nvim" },
{
"neovim/nvim-lspconfig",
opts = {
@ -14,4 +13,4 @@ return {
},
},
},
}
})

View file

@ -1,9 +1,6 @@
if not vim.fn.executable("nix") then
return
end
return {
require("util").setup_lang({ treesitter = { "nix" } }),
local util = require("util")
return util.if_exe("nix", {
util.setup_lang({ treesitter = { "nix" } }),
{
"neovim/nvim-lspconfig",
opts = {
@ -17,4 +14,4 @@ return {
},
},
},
}
})

View file

@ -1,11 +1,7 @@
if not vim.fn.executable("nu") then
return
end
return {
return require("util").if_exe("nu", {
"nvim-treesitter/nvim-treesitter",
dependencies = {
{ "nushell/tree-sitter-nu" },
},
build = ":TSUpdate",
}
})

View file

@ -1,24 +1,4 @@
if not vim.fn.executable("roc") then
return
end
-- make .roc files have the correct filetype
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.roc" },
command = "set filetype=roc",
})
-- -- add roc tree-sitter
-- local parsers = require("nvim-treesitter.parsers").get_parser_configs()
--
-- parsers.roc = {
-- install_info = {
-- url = "https://github.com/faldor20/tree-sitter-roc",
-- files = { "src/parser.c", "src/scanner.c" },
-- },
-- }
return {
return require("util").if_exe("roc", {
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "roc" } } },
{
"neovim/nvim-lspconfig",
@ -30,4 +10,4 @@ return {
},
},
},
}
})

View file

@ -1,9 +1,5 @@
if not vim.fn.executable("rust") then
return
end
-- adapted from https://www.lazyvim.org/extras/lang/rust
return {
return require("util").if_exe("rust", {
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
@ -100,4 +96,4 @@ return {
},
},
},
}
})

View file

@ -1,9 +1,5 @@
if not vim.fn.executable("zig") then
return
end
-- adapted from https://www.lazyvim.org/extras/lang/rust
return {
return require("util").if_exe("zig", {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@ -21,4 +17,4 @@ return {
},
},
},
}
})

View file

@ -25,6 +25,14 @@ local function setup_lang(defs)
}
end
local function if_exe(exe, deps)
if vim.fn.executable(exe) == 0 then
return {}
end
return deps
end
return {
setup_lang = setup_lang,
if_exe = if_exe,
}