Skip to content

Commit

Permalink
feat(watch): js/ts/tsx query (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
marilari88 authored Mar 18, 2024
1 parent e2b747f commit 45c15f5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lua/neotest/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ local augroup = vim.api.nvim_create_augroup("NeotestColorSchemeRefresh", {})
vim.api.nvim_create_autocmd("ColorScheme", { callback = define_highlights, group = augroup })
define_highlights()

local js_watch_query = [[
;query
;Captures named imports
(import_specifier name: (identifier) @symbol)
;Captures default import
(import_clause (identifier) @symbol)
;Capture require statements
(variable_declarator
name: (identifier) @symbol
value: (call_expression (identifier) @function (#eq? @function "require")))
;Capture namespace imports
(namespace_import (identifier) @symbol)
]]

---@class neotest.CoreConfig
---@field adapters neotest.Adapter[]
---@field discovery neotest.Config.discovery
Expand Down Expand Up @@ -272,6 +286,9 @@ local default_config = {
watch = {
enabled = true,
symbol_queries = {
typescript = js_watch_query,
javascript = js_watch_query,
tsx = js_watch_query,
python = [[
;query
;Captures imports and modules they're imported from
Expand Down

0 comments on commit 45c15f5

Please sign in to comment.