{"id":13761258,"url":"https://github.com/tjdevries/tree-sitter-lua","last_synced_at":"2025-04-05T16:09:58.596Z","repository":{"id":41866745,"uuid":"284136111","full_name":"tjdevries/tree-sitter-lua","owner":"tjdevries","description":"Neovim Tree Sitter Lua Grammar \u0026 Library","archived":false,"fork":false,"pushed_at":"2024-10-23T23:44:16.000Z","size":3484,"stargazers_count":119,"open_issues_count":21,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T15:11:14.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tjdevries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-31T21:52:28.000Z","updated_at":"2025-03-09T00:29:29.000Z","dependencies_parsed_at":"2024-01-15T03:59:04.184Z","dependency_job_id":"cb7fd18d-e63f-4d4f-b2b0-2d35a32d0443","html_url":"https://github.com/tjdevries/tree-sitter-lua","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Ftree-sitter-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Ftree-sitter-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Ftree-sitter-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Ftree-sitter-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjdevries","download_url":"https://codeload.github.com/tjdevries/tree-sitter-lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361693,"owners_count":20926643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T13:01:46.188Z","updated_at":"2025-04-05T16:09:58.565Z","avatar_url":"https://github.com/tjdevries.png","language":"C","funding_links":[],"categories":["Lua","C"],"sub_categories":[],"readme":"# tree-sitter-(n)lua\n\nTODO: Document how you can use `make build_parser` to automatically install\nthis for lua.\n\nTree sitter grammar for Lua built to be used inside of Neovim.\n\nGoal: Make a super great Lua grammar and tailor it to usage for Neovim.\n\n## Docgen\n\nThis grammar has a docgen module.\n\n[How to write emmy documentation](./HOWTO.md)\n\n### How to generate documentation\n\nWrite a lua script that looks like this:\n\n```lua\nlocal docgen = require('docgen')\n\nlocal docs = {}\n\ndocs.test = function()\n  -- Filepaths that should generate docs\n  local input_files = {\n    \"./lua/telescope/init.lua\",\n    \"./lua/telescope/builtin/init.lua\",\n    \"./lua/telescope/pickers/layout_strategies.lua\",\n    \"./lua/telescope/actions/init.lua\",\n    \"./lua/telescope/previewers/init.lua\",\n  }\n\n  -- Maybe sort them that depends what you want and need\n  table.sort(input_files, function(a, b)\n    return #a \u003c #b\n  end)\n\n  -- Output file\n  local output_file = \"./doc/telescope.txt\"\n  local output_file_handle = io.open(output_file, \"w\")\n\n  for _, input_file in ipairs(input_files) do\n    docgen.write(input_file, output_file_handle)\n  end\n\n  output_file_handle:write(\" vim:tw=78:ts=8:ft=help:norl:\\n\")\n  output_file_handle:close()\n  vim.cmd [[checktime]]\nend\n\ndocs.test()\n\nreturn docs\n```\n\nIt is suggested to use a `minimal_init.vim`. Example:\n\n```viml\nset rtp+=.\nset rtp+=../plenary.nvim/\nset rtp+=../tree-sitter-lua/\n\nruntime! plugin/plenary.vim\n```\n\nAfter that you can run docgen like this:\n\n```\nnvim --headless --noplugin -u scripts/minimal_init.vim -c \"luafile ./scripts/gendocs.lua\" -c 'qa'\n```\n\n## Thoughts on LSP:\n\nOK, so here's what I'm thinking:\n\n1. We have tree sitter for Lua (that we wrote)\n2. Can use tree sitter + queries to get information about one file\n    - This is like, what a variable is in the file, where it's defined, references, etc.\n3. We can use \"programming\" to link up multiple files w/ our tree sitter info\n    - Use package.path, package.searchers, etc. to find where requires lead to.\n4. Now we have \"project\" level knowledge.\n5. Can give smarts based on those things.\n\nALSO!\n\nWe can cheat :) :) :)\n\nLet's say we run our LSP in another neovim instance (just `nvim --headless -c 'some stuff'`)\n...\nOK\n\nthis means we can ask `vim` about itself (and other globals, and your package.path, etc.)\n\n\nPart 2 of cheating:\n\nwe can re-use vim.lsp in our implementation\n\n## Status\n\n- [ ] Grammar\n    - [ ]\n\n\n\n## How did I get this to be da one for nvim-treesitter\n\n1. It helps if you made @vigoux the person he is today.\n    - (Not a firm requirement, but it's very helpful)\n2. Make a grammar.js and then be able to generate a parser.so\n3. Write a bunch of tests for the language and provide somethjing the other parser doesnt.\n    - Mine is mostly that it parses docs\n    - It also parses more specifically many aspects of the language for smarter highlighting (hopefully)\n    - I also like the names more\n4. To test with nvim-treesitter, you need to make a `lua.so` (or whatever your filetype is) available somewhere in rtp in a folder called `parser`.\n    - Then you need to write the `.scm` files, like highlight and all that good stuff.\n5. ???\n1. Profit!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjdevries%2Ftree-sitter-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjdevries%2Ftree-sitter-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjdevries%2Ftree-sitter-lua/lists"}