Skip to content

Commit 64912ff

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 d350db2 commit 64912ff

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
@@ -265,13 +265,16 @@ require('lazy').setup({
265265
-- See `:help gitsigns` to understand what the configuration keys do
266266
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
267267
'lewis6991/gitsigns.nvim',
268+
---@module 'gitsigns'
269+
---@type Gitsigns.Config
270+
---@diagnostic disable-next-line: missing-fields
268271
opts = {
269272
signs = {
270-
add = { text = '+' },
271-
change = { text = '~' },
272-
delete = { text = '_' },
273-
topdelete = { text = '' },
274-
changedelete = { text = '~' },
273+
add = { text = '+' }, ---@diagnostic disable-line: missing-fields
274+
change = { text = '~' }, ---@diagnostic disable-line: missing-fields
275+
delete = { text = '_' }, ---@diagnostic disable-line: missing-fields
276+
topdelete = { text = '' }, ---@diagnostic disable-line: missing-fields
277+
changedelete = { text = '~' }, ---@diagnostic disable-line: missing-fields
275278
},
276279
},
277280
},
@@ -293,6 +296,9 @@ require('lazy').setup({
293296
{ -- Useful plugin to show you pending keybinds.
294297
'folke/which-key.nvim',
295298
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
299+
---@module 'which-key'
300+
---@type wk.Opts
301+
---@diagnostic disable-next-line: missing-fields
296302
opts = {
297303
-- delay between pressing a key and opening which-key (milliseconds)
298304
-- this setting is independent of vim.opt.timeoutlen
@@ -460,6 +466,9 @@ require('lazy').setup({
460466
-- used for completion, annotations and signatures of Neovim apis
461467
'folke/lazydev.nvim',
462468
ft = 'lua',
469+
---@module 'lazydev'
470+
---@type lazydev.Config
471+
---@diagnostic disable-next-line: missing-fields
463472
opts = {
464473
library = {
465474
-- Load luvit types when the `vim.uv` word is found
@@ -474,7 +483,13 @@ require('lazy').setup({
474483
-- Automatically install LSPs and related tools to stdpath for Neovim
475484
-- Mason must be loaded before its dependents so we need to set it up here.
476485
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
477-
{ 'williamboman/mason.nvim', opts = {} },
486+
{
487+
'williamboman/mason.nvim',
488+
---@module 'mason.settings'
489+
---@type MasonSettings
490+
---@diagnostic disable-next-line: missing-fields
491+
opts = {},
492+
},
478493
'williamboman/mason-lspconfig.nvim',
479494
'WhoIsSethDaniel/mason-tool-installer.nvim',
480495

@@ -742,6 +757,8 @@ require('lazy').setup({
742757
desc = '[F]ormat buffer',
743758
},
744759
},
760+
---@module 'conform'
761+
---@type conform.setupOpts
745762
opts = {
746763
notify_on_error = false,
747764
format_on_save = function(bufnr)
@@ -802,8 +819,8 @@ require('lazy').setup({
802819
},
803820
'folke/lazydev.nvim',
804821
},
805-
--- @module 'blink.cmp'
806-
--- @type blink.cmp.Config
822+
---@module 'blink.cmp'
823+
---@type blink.cmp.Config
807824
opts = {
808825
keymap = {
809826
-- 'default' (recommended) for mappings similar to built-in completions
@@ -891,7 +908,15 @@ require('lazy').setup({
891908
},
892909

893910
-- Highlight todo, notes, etc in comments
894-
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
911+
{
912+
'folke/todo-comments.nvim',
913+
event = 'VimEnter',
914+
dependencies = { 'nvim-lua/plenary.nvim' },
915+
---@module 'todo-comments'
916+
---@type TodoOptions
917+
---@diagnostic disable-next-line: missing-fields
918+
opts = { signs = false },
919+
},
895920

896921
{ -- Collection of various small independent plugins/modules
897922
'echasnovski/mini.nvim',
@@ -935,6 +960,9 @@ require('lazy').setup({
935960
build = ':TSUpdate',
936961
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
937962
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
963+
---@module 'nvim-treesitter.configs'
964+
---@type TSConfig
965+
---@diagnostic disable-next-line: missing-fields
938966
opts = {
939967
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
940968
-- Autoinstall languages that are not installed
@@ -982,7 +1010,7 @@ require('lazy').setup({
9821010
-- Or use telescope!
9831011
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
9841012
-- you can continue same window with `<space>sr` which resumes last telescope search
985-
}, {
1013+
}, { ---@diagnostic disable-line: missing-fields
9861014
ui = {
9871015
-- If you are using a Nerd Font: set icons to an empty table which will use the
9881016
-- 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'
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)