TODO: Document how you can use make build_parser to automatically install
this for lua.
Tree sitter grammar for Lua built to be used inside of Neovim.
Goal: Make a super great Lua grammar and tailor it to usage for Neovim.
This grammar has a docgen module.
How to write emmy documentation
Write a lua script that looks like this:
local docgen = require('docgen')
local docs = {}
docs.test = function()
-- Filepaths that should generate docs
local input_files = {
"./lua/telescope/init.lua",
"./lua/telescope/builtin/init.lua",
"./lua/telescope/pickers/layout_strategies.lua",
"./lua/telescope/actions/init.lua",
"./lua/telescope/previewers/init.lua",
}
-- Maybe sort them that depends what you want and need
table.sort(input_files, function(a, b)
return #a < #b
end)
-- Output file
local output_file = "./doc/telescope.txt"
local output_file_handle = io.open(output_file, "w")
for _, input_file in ipairs(input_files) do
docgen.write(input_file, output_file_handle)
end
output_file_handle:write(" vim:tw=78:ts=8:ft=help:norl:\n")
output_file_handle:close()
vim.cmd [[checktime]]
end
docs.test()
return docs
It is suggested to use a minimal_init.vim. Example:
set rtp+=.
set rtp+=../plenary.nvim/
set rtp+=../tree-sitter-lua/
runtime! plugin/plenary.vim
After that you can run docgen like this:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "luafile ./scripts/gendocs.lua" -c 'qa'
OK, so here's what I'm thinking:
ALSO!
We can cheat :) :) :)
Let's say we run our LSP in another neovim instance (just nvim --headless -c 'some stuff')
...
OK
this means we can ask vim about itself (and other globals, and your package.path, etc.)
Part 2 of cheating:
we can re-use vim.lsp in our implementation
lua.so (or whatever your filetype is) available somewhere in rtp in a folder called parser.
.scm files, like highlight and all that good stuff.C
90.9%
Lua
6.8%
TODO: Document how you can use make build_parser to automatically install
this for lua.
Tree sitter grammar for Lua built to be used inside of Neovim.
Goal: Make a super great Lua grammar and tailor it to usage for Neovim.
This grammar has a docgen module.
How to write emmy documentation
Write a lua script that looks like this:
local docgen = require('docgen')
local docs = {}
docs.test = function()
-- Filepaths that should generate docs
local input_files = {
"./lua/telescope/init.lua",
"./lua/telescope/builtin/init.lua",
"./lua/telescope/pickers/layout_strategies.lua",
"./lua/telescope/actions/init.lua",
"./lua/telescope/previewers/init.lua",
}
-- Maybe sort them that depends what you want and need
table.sort(input_files, function(a, b)
return #a < #b
end)
-- Output file
local output_file = "./doc/telescope.txt"
local output_file_handle = io.open(output_file, "w")
for _, input_file in ipairs(input_files) do
docgen.write(input_file, output_file_handle)
end
output_file_handle:write(" vim:tw=78:ts=8:ft=help:norl:\n")
output_file_handle:close()
vim.cmd [[checktime]]
end
docs.test()
return docs
It is suggested to use a minimal_init.vim. Example:
set rtp+=.
set rtp+=../plenary.nvim/
set rtp+=../tree-sitter-lua/
runtime! plugin/plenary.vim
After that you can run docgen like this:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "luafile ./scripts/gendocs.lua" -c 'qa'
OK, so here's what I'm thinking:
ALSO!
We can cheat :) :) :)
Let's say we run our LSP in another neovim instance (just nvim --headless -c 'some stuff')
...
OK
this means we can ask vim about itself (and other globals, and your package.path, etc.)
Part 2 of cheating:
we can re-use vim.lsp in our implementation
lua.so (or whatever your filetype is) available somewhere in rtp in a folder called parser.
.scm files, like highlight and all that good stuff.C
90.9%
Lua
6.8%