Skip to content

Instantly share code, notes, and snippets.

View pmouraguedes's full-sized avatar

Paulo Moura Guedes pmouraguedes

View GitHub Profile
(program ; [0, 0] - [3, 0]
(statement ; [0, 0] - [0, 17]
(select ; [0, 0] - [0, 8]
(keyword_select) ; [0, 0] - [0, 6]
(select_expression ; [0, 7] - [0, 8]
(term ; [0, 7] - [0, 8]
value: (all_fields)))) ; [0, 7] - [0, 8]
(from ; [0, 9] - [0, 17]
(keyword_from) ; [0, 9] - [0, 13]
(relation ; [0, 14] - [0, 17]
@pmouraguedes
pmouraguedes / gist:c0d51609fbaf1db46c9ad945fe716e6f
Last active May 5, 2025 13:53
tree-sitter sql traversing in neovim
local bufnr = vim.api.nvim_get_current_buf()
local ok, parser = pcall(vim.treesitter.get_parser, bufnr, "sql")
if not ok or not parser then
vim.notify("Failed to get SQL parser", vim.log.levels.ERROR)
return
end
local tree = parser:parse()[1]
if not tree then
vim.notify("No parse tree available", vim.log.levels.WARN)