aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/language.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-02-27 15:20:32 +0000
committerLewis Russell <me@lewisr.dev>2024-03-01 23:02:18 +0000
commita5fe8f59d98398d04bed8586cee73864bbcdde92 (patch)
tree9dd8086edc1e572ba1fddd03df17918dcd76a72e /runtime/lua/vim/treesitter/language.lua
parent813dd36b72979dfd05479eb6402b9becc0faea29 (diff)
downloadrneovim-a5fe8f59d98398d04bed8586cee73864bbcdde92.tar.gz
rneovim-a5fe8f59d98398d04bed8586cee73864bbcdde92.tar.bz2
rneovim-a5fe8f59d98398d04bed8586cee73864bbcdde92.zip
docs: improve/add documentation of Lua types
- Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.
Diffstat (limited to 'runtime/lua/vim/treesitter/language.lua')
-rw-r--r--runtime/lua/vim/treesitter/language.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 0f6d5ecbd0..78c73c698c 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -56,10 +56,17 @@ function M.require_language(lang, path, silent, symbol_name)
return true
end
----@class vim.treesitter.language.RequireLangOpts
----@field path? string
----@field silent? boolean
+---@class vim.treesitter.language.add.Opts
+---@inlinedoc
+---
+---Default filetype the parser should be associated with.
+---(Default: {lang})
---@field filetype? string|string[]
+---
+---Optional path the parser is located at
+---@field path? string
+---
+---Internal symbol name for the language to load
---@field symbol_name? string
--- Load parser with name {lang}
@@ -67,13 +74,8 @@ end
--- Parsers are searched in the `parser` runtime directory, or the provided {path}
---
---@param lang string Name of the parser (alphanumerical and `_` only)
----@param opts (table|nil) Options:
---- - filetype (string|string[]) Default filetype the parser should be associated with.
---- Defaults to {lang}.
---- - path (string|nil) Optional path the parser is located at
---- - symbol_name (string|nil) Internal symbol name for the language to load
+---@param opts? vim.treesitter.language.add.Opts Options:
function M.add(lang, opts)
- ---@cast opts vim.treesitter.language.RequireLangOpts
opts = opts or {}
local path = opts.path
local filetype = opts.filetype or lang