feat(lsp): deprecate non-method client functions

Deprecated:
- `client.request()` -> `client:request()`
- `client.request_sync()` -> `client:request_sync()`
- `client.notify()` -> `client:notify()`
- `client.cancel_request()` -> `client:cancel_request()`
- `client.stop()` -> `client:stop()`
- `client.is_stopped()` `client:is_stopped()`
- `client.supports_method()` -> `client:supports_method()`
- `client.on_attach()` -> `client:on_attach()`

Fixed docgen to link class fields to the full function doc.
This commit is contained in:
Lewis Russell
2024-11-14 11:53:20 +00:00
committed by Lewis Russell
parent f55c842ec7
commit 454ae672aa
19 changed files with 403 additions and 358 deletions

View File

@ -538,7 +538,8 @@ end
--- @param generics? table<string,string>
--- @param classes? table<string,nvim.luacats.parser.class>
--- @param exclude_types? true
local function render_fields_or_params(xs, generics, classes, exclude_types)
--- @param cfg nvim.gen_vimdoc.Config
local function render_fields_or_params(xs, generics, classes, exclude_types, cfg)
local ret = {} --- @type string[]
xs = vim.tbl_filter(should_render_field_or_param, xs)
@ -558,7 +559,9 @@ local function render_fields_or_params(xs, generics, classes, exclude_types)
p.desc = pdesc
inline_type(p, classes)
local nm, ty, desc = p.name, p.type, p.desc
local nm, ty = p.name, p.type
local desc = p.classvar and string.format('See |%s|.', cfg.fn_helptag_fmt(p)) or p.desc
local fnm = p.kind == 'operator' and fmt('op(%s)', nm) or fmt_field_name(nm)
local pnm = fmt(' • %-' .. indent .. 's', fnm)
@ -591,7 +594,8 @@ end
--- @param class nvim.luacats.parser.class
--- @param classes table<string,nvim.luacats.parser.class>
local function render_class(class, classes)
--- @param cfg nvim.gen_vimdoc.Config
local function render_class(class, classes, cfg)
if class.access or class.nodoc or class.inlinedoc then
return
end
@ -610,7 +614,7 @@ local function render_class(class, classes)
table.insert(ret, md_to_vimdoc(class.desc, INDENTATION, INDENTATION, TEXT_WIDTH))
end
local fields_txt = render_fields_or_params(class.fields, nil, classes)
local fields_txt = render_fields_or_params(class.fields, nil, classes, nil, cfg)
if not fields_txt:match('^%s*$') then
table.insert(ret, '\n Fields: ~\n')
table.insert(ret, fields_txt)
@ -621,11 +625,12 @@ local function render_class(class, classes)
end
--- @param classes table<string,nvim.luacats.parser.class>
local function render_classes(classes)
--- @param cfg nvim.gen_vimdoc.Config
local function render_classes(classes, cfg)
local ret = {} --- @type string[]
for _, class in vim.spairs(classes) do
ret[#ret + 1] = render_class(class, classes)
ret[#ret + 1] = render_class(class, classes, cfg)
end
return table.concat(ret)
@ -656,10 +661,6 @@ local function render_fun_header(fun, cfg)
local proto = fun.table and nm or nm .. '(' .. table.concat(args, ', ') .. ')'
if not cfg.fn_helptag_fmt then
cfg.fn_helptag_fmt = fn_helptag_fmt_common
end
local tag = '*' .. cfg.fn_helptag_fmt(fun) .. '*'
if #proto + #tag > TEXT_WIDTH - 8 then
@ -774,7 +775,8 @@ local function render_fun(fun, classes, cfg)
end
if fun.params and #fun.params > 0 then
local param_txt = render_fields_or_params(fun.params, fun.generics, classes, cfg.exclude_types)
local param_txt =
render_fields_or_params(fun.params, fun.generics, classes, cfg.exclude_types, cfg)
if not param_txt:match('^%s*$') then
table.insert(ret, '\n Parameters: ~\n')
ret[#ret + 1] = param_txt
@ -957,6 +959,7 @@ end
--- @param cfg nvim.gen_vimdoc.Config
local function gen_target(cfg)
cfg.fn_helptag_fmt = cfg.fn_helptag_fmt or fn_helptag_fmt_common
print('Target:', cfg.filename)
local sections = {} --- @type table<string,nvim.gen_vimdoc.Section>
@ -987,7 +990,7 @@ local function gen_target(cfg)
print(' Processing file:', f)
local funs_txt = render_funs(funs, all_classes, cfg)
if next(classes) then
local classes_txt = render_classes(classes)
local classes_txt = render_classes(classes, cfg)
if vim.trim(classes_txt) ~= '' then
funs_txt = classes_txt .. '\n' .. funs_txt
end

View File

@ -1,9 +1,6 @@
local luacats_grammar = require('scripts.luacats_grammar')
--- @class nvim.luacats.parser.param
--- @field name string
--- @field type string
--- @field desc string
--- @class nvim.luacats.parser.param : nvim.luacats.Param
--- @class nvim.luacats.parser.return
--- @field name string
@ -41,21 +38,14 @@ local luacats_grammar = require('scripts.luacats_grammar')
--- @field notes? nvim.luacats.parser.note[]
--- @field see? nvim.luacats.parser.note[]
--- @class nvim.luacats.parser.field
--- @field name string
--- @field type string
--- @field desc string
--- @field access? 'private'|'package'|'protected'
--- @class nvim.luacats.parser.field : nvim.luacats.Field
--- @field classvar? string
--- @field nodoc? true
--- @class nvim.luacats.parser.class
--- @field kind 'class'
--- @field parent? string
--- @field name string
--- @field desc string
--- @class nvim.luacats.parser.class : nvim.luacats.Class
--- @field desc? string
--- @field nodoc? true
--- @field inlinedoc? true
--- @field access? 'private'|'package'|'protected'
--- @field fields nvim.luacats.parser.field[]
--- @field notes? string[]
@ -332,7 +322,10 @@ local function process_lua_line(line, state, classes, classvars, has_indent)
end
-- Add method as the field to the class
table.insert(classes[class].fields, fun2field(cur_obj))
local cls = classes[class]
local field = fun2field(cur_obj)
field.classvar = cur_obj.classvar
table.insert(cls.fields, field)
return
end