Skip to content

Commit 177ff61

Browse files
committed
Add type hints to plugin options where possible
This could help beginners to get autocompletion, catch mistakes earlier, and allow them to skip the docs for simple configs. This is not perfect because a lot of the plugins type all of their keys as required, even though they have defaults, but this is good enough.
1 parent b9f3965 commit 177ff61

8 files changed

Lines changed: 56 additions & 10 deletions

File tree

init.lua

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,16 @@ require('lazy').setup({
275275
-- See `:help gitsigns` to understand what the configuration keys do
276276
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
277277
'lewis6991/gitsigns.nvim',
278+
---@module 'gitsigns'
279+
---@type Gitsigns.Config
280+
---@diagnostic disable-next-line: missing-fields
278281
opts = {
279282
signs = {
280-
add = { text = '+' },
281-
change = { text = '~' },
282-
delete = { text = '_' },
283-
topdelete = { text = '' },
284-
changedelete = { text = '~' },
283+
add = { text = '+' }, ---@diagnostic disable-line: missing-fields
284+
change = { text = '~' }, ---@diagnostic disable-line: missing-fields
285+
delete = { text = '_' }, ---@diagnostic disable-line: missing-fields
286+
topdelete = { text = '' }, ---@diagnostic disable-line: missing-fields
287+
changedelete = { text = '~' }, ---@diagnostic disable-line: missing-fields
285288
},
286289
},
287290
},
@@ -303,6 +306,9 @@ require('lazy').setup({
303306
{ -- Useful plugin to show you pending keybinds.
304307
'folke/which-key.nvim',
305308
event = 'VimEnter',
309+
---@module 'which-key'
310+
---@type wk.Opts
311+
---@diagnostic disable-next-line: missing-fields
306312
opts = {
307313
-- delay between pressing a key and opening which-key (milliseconds)
308314
delay = 0,
@@ -480,7 +486,13 @@ require('lazy').setup({
480486
-- Automatically install LSPs and related tools to stdpath for Neovim
481487
-- Mason must be loaded before its dependents so we need to set it up here.
482488
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
483-
{ 'mason-org/mason.nvim', opts = {} },
489+
{
490+
'mason-org/mason.nvim',
491+
---@module 'mason.settings'
492+
---@type MasonSettings
493+
---@diagnostic disable-next-line: missing-fields
494+
opts = {},
495+
},
484496
-- Maps LSP server names between nvim-lspconfig and Mason package names.
485497
'mason-org/mason-lspconfig.nvim',
486498
'WhoIsSethDaniel/mason-tool-installer.nvim',
@@ -673,6 +685,8 @@ require('lazy').setup({
673685
desc = '[F]ormat buffer',
674686
},
675687
},
688+
---@module 'conform'
689+
---@type conform.setupOpts
676690
opts = {
677691
notify_on_error = false,
678692
format_on_save = function(bufnr)
@@ -730,8 +744,8 @@ require('lazy').setup({
730744
opts = {},
731745
},
732746
},
733-
--- @module 'blink.cmp'
734-
--- @type blink.cmp.Config
747+
---@module 'blink.cmp'
748+
---@type blink.cmp.Config
735749
opts = {
736750
keymap = {
737751
-- 'default' (recommended) for mappings similar to built-in completions
@@ -816,7 +830,15 @@ require('lazy').setup({
816830
},
817831

818832
-- Highlight todo, notes, etc in comments
819-
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
833+
{
834+
'folke/todo-comments.nvim',
835+
event = 'VimEnter',
836+
dependencies = { 'nvim-lua/plenary.nvim' },
837+
---@module 'todo-comments'
838+
---@type TodoOptions
839+
---@diagnostic disable-next-line: missing-fields
840+
opts = { signs = false },
841+
},
820842

821843
{ -- Collection of various small independent plugins/modules
822844
'nvim-mini/mini.nvim',
@@ -892,7 +914,7 @@ require('lazy').setup({
892914
-- Or use telescope!
893915
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
894916
-- you can continue same window with `<space>sr` which resumes last telescope search
895-
}, {
917+
}, { ---@diagnostic disable-line: missing-fields
896918
ui = {
897919
-- If you are using a Nerd Font: set icons to an empty table which will use the
898920
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table

lua/custom/plugins/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
-- I promise not to create any merge conflicts in this directory :)
33
--
44
-- See the kickstart.nvim README for more information
5+
6+
---@module 'lazy'
7+
---@type LazySpec
58
return {}

lua/kickstart/plugins/autopairs.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-- autopairs
22
-- https://github.com/windwp/nvim-autopairs
33

4+
---@module 'lazy'
5+
---@type LazySpec
46
return {
57
'windwp/nvim-autopairs',
68
event = 'InsertEnter',

lua/kickstart/plugins/debug.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
-- be extended to other languages as well. That's why it's called
77
-- kickstart.nvim and not kitchen-sink.nvim ;)
88

9+
---@module 'lazy'
10+
---@type LazySpec
911
return {
1012
-- NOTE: Yes, you can install new plugins here!
1113
'mfussenegger/nvim-dap',
@@ -86,11 +88,13 @@ return {
8688

8789
-- Dap UI setup
8890
-- For more information, see |:help nvim-dap-ui|
91+
---@diagnostic disable-next-line: missing-fields
8992
dapui.setup {
9093
-- Set icons to characters that are more likely to work in every terminal.
9194
-- Feel free to remove or use ones that you like more! :)
9295
-- Don't feel like these are good choices.
9396
icons = { expanded = '', collapsed = '', current_frame = '*' },
97+
---@diagnostic disable-next-line: missing-fields
9498
controls = {
9599
icons = {
96100
pause = '',

lua/kickstart/plugins/gitsigns.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
-- NOTE: gitsigns is already included in init.lua but contains only the base
33
-- config. This will add also the recommended keymaps.
44

5+
---@module 'lazy'
6+
---@type LazySpec
57
return {
68
{
79
'lewis6991/gitsigns.nvim',
10+
---@module 'gitsigns'
11+
---@type Gitsigns.Config
12+
---@diagnostic disable-next-line: missing-fields
813
opts = {
914
on_attach = function(bufnr)
1015
local gitsigns = require 'gitsigns'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
---@module 'lazy'
2+
---@type LazySpec
13
return {
24
{ -- Add indentation guides even on blank lines
35
'lukas-reineke/indent-blankline.nvim',
46
-- Enable `lukas-reineke/indent-blankline.nvim`
57
-- See `:help ibl`
68
main = 'ibl',
9+
---@module 'ibl'
10+
---@type ibl.config
711
opts = {},
812
},
913
}

lua/kickstart/plugins/lint.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
---@module 'lazy'
2+
---@type LazySpec
13
return {
24

35
{ -- Linting

lua/kickstart/plugins/neo-tree.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-- Neo-tree is a Neovim plugin to browse the file system
22
-- https://github.com/nvim-neo-tree/neo-tree.nvim
33

4+
---@module 'lazy'
5+
---@type LazySpec
46
return {
57
'nvim-neo-tree/neo-tree.nvim',
68
version = '*',
@@ -13,6 +15,8 @@ return {
1315
keys = {
1416
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
1517
},
18+
---@module 'neo-tree'
19+
---@type neotree.Config
1620
opts = {
1721
filesystem = {
1822
window = {

0 commit comments

Comments
 (0)