Add type annotations to plugin specs

This commit is contained in:
Marko Korhonen 2023-11-25 14:37:36 +02:00
parent 7bd4c6e93e
commit efcdb566b8
31 changed files with 56 additions and 14 deletions

View file

@ -1,11 +1,13 @@
-- AsciiDoc plugins are grouped together here -- AsciiDoc plugins are grouped together here
return { return {
-- Vim ♥️ Asciidoctor -- Vim ♥️ Asciidoctor
--- @type LazyPluginSpec
{ {
"habamax/vim-asciidoctor", "habamax/vim-asciidoctor",
ft = { "asciidoctor", "asciidoc" }, ft = { "asciidoctor", "asciidoc" },
}, },
-- AsciiDoc preview -- AsciiDoc preview
--- @type LazyPluginSpec
{ {
"tigion/nvim-asciidoc-preview", "tigion/nvim-asciidoc-preview",
ft = { "asciidoctor", "asciidoc" }, ft = { "asciidoctor", "asciidoc" },

View file

@ -1,4 +1,5 @@
-- Automatic brackets -- Automatic brackets
--- @type LazyPluginSpec
return { return {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
config = true config = true

View file

@ -1,8 +1,10 @@
-- Bufferline
--- @type LazyPluginSpec
return { return {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
version = "*", version = "*",
dependencies = { "kyazdani42/nvim-web-devicons" }, dependencies = { "kyazdani42/nvim-web-devicons" },
---@type BufferlineConfig --- @type BufferlineConfig
opts = { opts = {
options = { options = {
diagnostics = "nvim_lsp", diagnostics = "nvim_lsp",

View file

@ -1,4 +1,5 @@
-- Caddyfile syntax support -- Caddyfile syntax support
--- @type LazyPluginSpec
return { return {
"isobit/vim-caddyfile", "isobit/vim-caddyfile",
ft = "caddyfile", ft = "caddyfile",

View file

@ -1,4 +1,5 @@
-- Autoompletion -- Autoompletion
--- @type LazyPluginSpec
return { return {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { dependencies = {

View file

@ -1,3 +1,5 @@
-- Confirm before quit
--- @type LazyPluginSpec
return { return {
"yutkat/confirm-quit.nvim", "yutkat/confirm-quit.nvim",
event = "CmdlineEnter", event = "CmdlineEnter",

View file

@ -1,4 +1,5 @@
-- GitHub Copilot -- GitHub Copilot
--- @type LazyPluginSpec
return { return {
"zbirenbaum/copilot.lua", "zbirenbaum/copilot.lua",
opts = { opts = {

View file

@ -1,4 +1,5 @@
-- Startup dashboard -- Startup dashboard
--- @type LazyPluginSpec
return { return {
"glepnir/dashboard-nvim", "glepnir/dashboard-nvim",
event = "VimEnter", event = "VimEnter",

View file

@ -1,3 +1,5 @@
-- Show the current LSP context in winbar
--- @type LazyPluginSpec
return { return {
"Bekaboo/dropbar.nvim", "Bekaboo/dropbar.nvim",
} }

View file

@ -1,4 +1,5 @@
-- Neovim inside Firefox -- Neovim inside Firefox
--- @type LazyPluginSpec
return { return {
"glacambre/firenvim", "glacambre/firenvim",
build = function() build = function()

View file

@ -1,2 +1,3 @@
-- Git commands -- Git commands
--- @type LazyPluginSpec
return { "tpope/vim-fugitive" } return { "tpope/vim-fugitive" }

View file

@ -1,4 +1,5 @@
-- Edit GPG encrypted files transparently -- Edit GPG encrypted files transparently
--- @type LazyPluginSpec
return { return {
"jamessan/vim-gnupg", "jamessan/vim-gnupg",
ft = { "gpg" }, ft = { "gpg" },

View file

@ -1,7 +1,8 @@
-- Indent characters -- Indent characters
--- @type LazyPluginSpec
return { return {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
---@type ibl.config --- @type ibl.config
opts = { opts = {
exclude = { exclude = {
filetypes = { filetypes = {

View file

@ -1,7 +1,8 @@
-- Colorscheme -- Colorscheme
--- @type LazyPluginSpec
return { return {
"rebelot/kanagawa.nvim", "rebelot/kanagawa.nvim",
---@type KanagawaConfig --- @type KanagawaConfig
opts = { opts = {
compile = true, compile = true,
dimInactive = true, dimInactive = true,
@ -46,6 +47,7 @@ return {
} }
end, end,
}, },
--- @param opts KanagawaConfig
config = function(_, opts) config = function(_, opts)
require("kanagawa").setup(opts) require("kanagawa").setup(opts)
vim.cmd("colorscheme kanagawa") vim.cmd("colorscheme kanagawa")

View file

@ -1,4 +1,5 @@
-- Statusline -- Statusline
--- @type LazyPluginSpec
return { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { "kyazdani42/nvim-web-devicons" }, dependencies = { "kyazdani42/nvim-web-devicons" },

View file

@ -1,4 +1,5 @@
-- Snippets plugin -- Snippets plugin
--- @type LazyPluginSpec
return { return {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
-- Snippets collection -- Snippets collection

View file

@ -1,4 +1,5 @@
-- Markdown preview -- Markdown preview
--- @type LazyPluginSpec
return { return {
"iamcco/markdown-preview.nvim", "iamcco/markdown-preview.nvim",
build = "cd app && yarn install", build = "cd app && yarn install",

View file

@ -1,5 +1,6 @@
-- Package manager for LSP servers, DAP adapters etc. -- Package manager for LSP servers, DAP adapters etc.
-- It also handles starting all of my LSP servers -- It also handles starting all of my LSP servers
--- @type LazyPluginSpec
return { return {
"williamboman/mason.nvim", "williamboman/mason.nvim",
dependencies = { dependencies = {
@ -13,7 +14,7 @@ return {
-- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API. -- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.
{ {
"folke/neodev.nvim", "folke/neodev.nvim",
---@type LuaDevOptions --- @type LuaDevOptions
opts = { opts = {
override = function(root_dir, library) override = function(root_dir, library)
local dotfiles_path = tostring(vim.fn.expand("~/git/dotfiles")) local dotfiles_path = tostring(vim.fn.expand("~/git/dotfiles"))

View file

@ -1,4 +1,5 @@
-- Library of 30+ independent Lua modules improving overall Neovim -- Library of 30+ independent Lua modules improving overall Neovim
--- @type LazyPluginSpec
return { return {
"echasnovski/mini.nvim", "echasnovski/mini.nvim",
version = "*", version = "*",

View file

@ -1,4 +1,5 @@
-- Formatter plugin -- Formatter plugin
--- @type LazyPluginSpec
return { return {
"sbdchd/neoformat", "sbdchd/neoformat",
keys = { keys = {

View file

@ -1,10 +1,11 @@
-- Replace much of neovim's default UI -- Replace much of neovim's default UI
-- with a modern replacement -- with a modern replacement
--- @type LazyPluginSpec
return { return {
"folke/noice.nvim", "folke/noice.nvim",
event = "VeryLazy", event = "VeryLazy",
dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" }, dependencies = { "MunifTanjim/nui.nvim", "rcarriga/nvim-notify" },
---@type NoiceConfig --- @type NoiceConfig
opts = { opts = {
lsp = { lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter** -- override markdown rendering so that **cmp** and other plugins use **Treesitter**

View file

@ -1,4 +1,5 @@
-- High performance color highlighter -- High performance color highlighter
--- @type LazyPluginSpec
return { return {
"norcalli/nvim-colorizer.lua", "norcalli/nvim-colorizer.lua",
config = true, config = true,

View file

@ -1,3 +1,5 @@
-- Debug adapter for NeoVim
--- @type LazyPluginSpec
return { return {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
config = function() config = function()

View file

@ -1,4 +1,5 @@
-- Tree explorer -- Tree explorer
--- @type LazyPluginSpec
return { return {
"kyazdani42/nvim-tree.lua", "kyazdani42/nvim-tree.lua",
lazy = false, lazy = false,

View file

@ -1,4 +1,5 @@
-- Make editing passwords safer -- Make editing passwords safer
--- @type LazyPluginSpec
return { return {
"https://git.zx2c4.com/password-store", "https://git.zx2c4.com/password-store",
config = function(plugin) config = function(plugin)

View file

@ -1,3 +1,5 @@
-- Customize statuscolumn
--- @type LazyPluginSpec
return { return {
"luukvbaal/statuscol.nvim", "luukvbaal/statuscol.nvim",
dependencies = { dependencies = {

View file

@ -1,2 +1,3 @@
-- Do stuff as sudo -- Do stuff as sudo
--- @type LazyPluginSpec
return { "lambdalisue/suda.vim" } return { "lambdalisue/suda.vim" }

View file

@ -1,3 +1,4 @@
--- @type LazyPluginSpec
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
dependencies = { dependencies = {

View file

@ -1,14 +1,15 @@
return { return {
-- Improved syntax highlighting, text objects and more
--- @type LazyPluginSpec
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
init = function(plugin) init = function()
require("nvim-treesitter.install").update({ require("nvim-treesitter.install").update({
with_sync = true, with_sync = true,
}) })
end, end,
---@type TSConfig --- @type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = { opts = {
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
@ -70,10 +71,10 @@ return {
}, },
}, },
}, },
---@param opts TSConfig --- @param opts TSConfig
config = function(_, opts) config = function(_, opts)
if type(opts.ensure_installed) == "table" then if type(opts.ensure_installed) == "table" then
---@type table<string, boolean> --- @type table<string, boolean>
local added = {} local added = {}
opts.ensure_installed = vim.tbl_filter(function(lang) opts.ensure_installed = vim.tbl_filter(function(lang)
if added[lang] then if added[lang] then
@ -91,13 +92,15 @@ return {
config = function() config = function()
-- When in diff mode, we want to use the default -- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones. -- vim text objects c & C instead of the treesitter ones.
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)> --- @type table<string,fun(...)>
local move = require("nvim-treesitter.textobjects.move")
local configs = require("nvim-treesitter.configs") local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do for name, fn in pairs(move) do
if name:find("goto") == 1 then if name:find("goto") == 1 then
move[name] = function(q, ...) move[name] = function(q, ...)
if vim.wo.diff then if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string> --- @type table<string,string>
local config = configs.get_module("textobjects.move")[name]
for key, query in pairs(config or {}) do for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key) vim.cmd("normal! " .. key)
@ -115,8 +118,9 @@ return {
}, },
-- Automatically add closing tags for HTML and JSX -- Automatically add closing tags for HTML and JSX
--- @type LazyPluginSpec
{ {
"windwp/nvim-ts-autotag", "windwp/nvim-ts-autotag",
opts = {}, config = true,
}, },
} }

View file

@ -1,13 +1,15 @@
-- Better folds -- Better folds
--- @type LazyPluginSpec
return { return {
"kevinhwang91/nvim-ufo", "kevinhwang91/nvim-ufo",
dependencies = { "kevinhwang91/promise-async" }, dependencies = { "kevinhwang91/promise-async" },
---@type UfoConfig --- @type UfoConfig
opts = { opts = {
close_fold_kinds = { close_fold_kinds = {
"imports", "imports",
}, },
}, },
--- @param opts UfoConfig
config = function(_, opts) config = function(_, opts)
local ufo = require("ufo") local ufo = require("ufo")
ufo.setup(opts) ufo.setup(opts)

View file

@ -1,6 +1,7 @@
-- Display possible keybinds -- Display possible keybinds
-- Here I have also defined some generic keybinds -- Here I have also defined some generic keybinds
-- Plugin specific keybinds are set up in plugin configuration file -- Plugin specific keybinds are set up in plugin configuration file
--- @type LazyPluginSpec
return { return {
"folke/which-key.nvim", "folke/which-key.nvim",
config = function() config = function()