Skip to content

chore: add type annotations#2856

Closed
jamestrew wants to merge 2 commits into
masterfrom
typing-annotations
Closed

chore: add type annotations#2856
jamestrew wants to merge 2 commits into
masterfrom
typing-annotations

Conversation

@jamestrew

Copy link
Copy Markdown
Contributor

trying something out.
I like types and I think it can help with our documentation deficiencies as well (eg. confusions around why you can pass default_text to find_files and why it's not documented, where to document it, etc, but this might need some enhancements to tree-sitter-lua since the newer luals luacats annotation support is limited).

Comment thread lua/telescope/pickers.lua

--- Picker is the main UI that shows up to interact w/ your results.
-- Takes a filter & a previewer
---@class TelescopeBasePicker

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels pretty ridiculous lol

Comment thread doc/telescope.txt
Parameters: ~
{opts} (table) options to pass to the picker
TelescopeLiveGrepOpts *TelescopeLiveGrepOpts*
TelescopeBasePickerOpts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't like this

@jamestrew

Copy link
Copy Markdown
Contributor Author

@Conni2461 what do you think?

@Conni2461

Copy link
Copy Markdown
Member

i guess we can do that. i havent made up my mind regarding lua language servers annotations. they aren't compatible with emmylua annotations which are used within docgen (its uses a lua treesitter parser with emmylua support).

fyi there is also this: #1954

@jamestrew

Copy link
Copy Markdown
Contributor Author

they aren't compatible with emmylua annotations which are used within docgen (its uses a lua treesitter parser with emmylua support).

Yeah I actually made an issue on tree-sitter-lua about (me) potentially adding or converting the ts grammar to support luals annotations.

I know this is something neovim core eventually would like for their docgen purposes as well. Somebody just needs to do it.

@jamestrew

Copy link
Copy Markdown
Contributor Author

FYI I replaced telescope-file-browser's docgen with an alternative I've been working on.
HEAVILY based on neovim core's docgen script, integrating LuaCATS much more.

Looking to make a similar conversion for telescope core to enable changes like those in this PR.

nvim-telescope/telescope-file-browser.nvim#399

@clason

clason commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

FYI I replaced telescope-file-browser's docgen with an alternative I've been working on.
HEAVILY based on neovim core's docgen script, integrating LuaCATS much more.

This Is The Way. (There are now tree-sitter parsers for both luadoc and emmylua, so we don't have to choose between type checking and docgen.)

If this project is going to be actively developed in the future, strict annotations are a must IMO.

@clason

clason commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

(But maybe it makes sense to first pick a tool -- as a target, luals and emmyluals are broadly compatible -- and then start from scratch?)

@jamestrew

Copy link
Copy Markdown
Contributor Author

I did also raise a PR a while back to switch out the docgen tool for telescope core too. #3227

I haven't kept up much with how neovim core is still doing docgen. It was all LuaCATS parsing with LPEG back when I converted the neovim docgen script into https://github.com/jamestrew/docgen.nvim
Main motivation for my docgen.nvim was

  1. no dependencies (didn't want to require building treesitter parsers like we currently do with tj's tree-sitter-lua)
  2. look and feel of generated help docs should be very close if not identical to neovim core
  3. easy for plugins to use (main area where things start to differ from neovim core as their implementation has/had some bespoke rules/setup particular to neovim core)

I can take a look at giving it a refresh based on what neovim core is at today.

@clason

clason commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

If there's something core can expose through a refactor to make this easier for plugins, consider raising an issue! Plugin ecosystem health is something the team is taking quite seriously these days.

@clason

clason commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

@jamestrew is this superseded by #3227 ?

@jamestrew

Copy link
Copy Markdown
Contributor Author

something like a second attempt #3670

@jamestrew jamestrew closed this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants