Skip to content

Commit 5962064

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 3338d39 commit 5962064

File tree

8 files changed

+62
-10
lines changed

8 files changed

+62
-10
lines changed

init.lua

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,16 @@ require('lazy').setup({
273273
-- See `:help gitsigns` to understand what the configuration keys do
274274
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
275275
'lewis6991/gitsigns.nvim',
276+
---@module 'gitsigns'
277+
---@type Gitsigns.Config
278+
---@diagnostic disable-next-line: missing-fields
276279
opts = {
277280
signs = {
278-
add = { text = '+' },
279-
change = { text = '~' },
280-
delete = { text = '_' },
281-
topdelete = { text = '' },
282-
changedelete = { text = '~' },
281+
add = { text = '+' }, ---@diagnostic disable-line: missing-fields
282+
change = { text = '~' }, ---@diagnostic disable-line: missing-fields
283+
delete = { text = '_' }, ---@diagnostic disable-line: missing-fields
284+
topdelete = { text = '' }, ---@diagnostic disable-line: missing-fields
285+
changedelete = { text = '~' }, ---@diagnostic disable-line: missing-fields
283286
},
284287
},
285288
},
@@ -301,6 +304,9 @@ require('lazy').setup({
301304
{ -- Useful plugin to show you pending keybinds.
302305
'folke/which-key.nvim',
303306
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
307+
---@module 'which-key'
308+
---@type wk.Opts
309+
---@diagnostic disable-next-line: missing-fields
304310
opts = {
305311
-- delay between pressing a key and opening which-key (milliseconds)
306312
-- this setting is independent of vim.o.timeoutlen
@@ -468,6 +474,9 @@ require('lazy').setup({
468474
-- used for completion, annotations and signatures of Neovim apis
469475
'folke/lazydev.nvim',
470476
ft = 'lua',
477+
---@module 'lazydev'
478+
---@type lazydev.Config
479+
---@diagnostic disable-next-line: missing-fields
471480
opts = {
472481
library = {
473482
-- Load luvit types when the `vim.uv` word is found
@@ -482,7 +491,13 @@ require('lazy').setup({
482491
-- Automatically install LSPs and related tools to stdpath for Neovim
483492
-- Mason must be loaded before its dependents so we need to set it up here.
484493
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
485-
{ 'mason-org/mason.nvim', opts = {} },
494+
{
495+
'mason-org/mason.nvim',
496+
---@module 'mason.settings'
497+
---@type MasonSettings
498+
---@diagnostic disable-next-line: missing-fields
499+
opts = {},
500+
},
486501
'mason-org/mason-lspconfig.nvim',
487502
'WhoIsSethDaniel/mason-tool-installer.nvim',
488503

@@ -750,6 +765,8 @@ require('lazy').setup({
750765
desc = '[F]ormat buffer',
751766
},
752767
},
768+
---@module 'conform'
769+
---@type conform.setupOpts
753770
opts = {
754771
notify_on_error = false,
755772
format_on_save = function(bufnr)
@@ -810,8 +827,8 @@ require('lazy').setup({
810827
},
811828
'folke/lazydev.nvim',
812829
},
813-
--- @module 'blink.cmp'
814-
--- @type blink.cmp.Config
830+
---@module 'blink.cmp'
831+
---@type blink.cmp.Config
815832
opts = {
816833
keymap = {
817834
-- 'default' (recommended) for mappings similar to built-in completions
@@ -899,7 +916,15 @@ require('lazy').setup({
899916
},
900917

901918
-- Highlight todo, notes, etc in comments
902-
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
919+
{
920+
'folke/todo-comments.nvim',
921+
event = 'VimEnter',
922+
dependencies = { 'nvim-lua/plenary.nvim' },
923+
---@module 'todo-comments'
924+
---@type TodoOptions
925+
---@diagnostic disable-next-line: missing-fields
926+
opts = { signs = false },
927+
},
903928

904929
{ -- Collection of various small independent plugins/modules
905930
'echasnovski/mini.nvim',
@@ -943,6 +968,9 @@ require('lazy').setup({
943968
build = ':TSUpdate',
944969
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
945970
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
971+
---@module 'nvim-treesitter'
972+
---@type TSConfig
973+
---@diagnostic disable-next-line: missing-fields
946974
opts = {
947975
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
948976
-- Autoinstall languages that are not installed
@@ -990,7 +1018,7 @@ require('lazy').setup({
9901018
-- Or use telescope!
9911019
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
9921020
-- you can continue same window with `<space>sr` which resumes last telescope search
993-
}, {
1021+
}, { ---@diagnostic disable-line: missing-fields
9941022
ui = {
9951023
-- If you are using a Nerd Font: set icons to an empty table which will use the
9961024
-- 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',
@@ -100,11 +102,13 @@ return {
100102

101103
-- Dap UI setup
102104
-- For more information, see |:help nvim-dap-ui|
105+
---@diagnostic disable-next-line: missing-fields
103106
dapui.setup {
104107
-- Set icons to characters that are more likely to work in every terminal.
105108
-- Feel free to remove or use ones that you like more! :)
106109
-- Don't feel like these are good choices.
107110
icons = { expanded = '', collapsed = '', current_frame = '*' },
111+
---@diagnostic disable-next-line: missing-fields
108112
controls = {
109113
icons = {
110114
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'

lua/kickstart/plugins/indent_line.lua

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)