Skip to content

Commit

Permalink
add queries for codechunks as textobjects (#23)
Browse files Browse the repository at this point in the history
* add textobjects

* define queries for codechunks
  • Loading branch information
jmbuhr authored Jan 7, 2023
1 parent 8003f7c commit d2e0f77
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 3 deletions.
5 changes: 5 additions & 0 deletions after/queries/bash/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; extends
(
(comment) @codechunk.inner
(#eq? @codechunk.inner "#%%")
)
4 changes: 4 additions & 0 deletions after/queries/markdown/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; extends
(code_fence_content) @codechunk.inner

(fenced_code_block) @codechunk.outer
5 changes: 5 additions & 0 deletions after/queries/python/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; extends
(
(comment) @codechunk.inner
(#eq? @codechunk.inner "#%%")
)
5 changes: 5 additions & 0 deletions after/queries/r/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; extends
(
(comment) @codechunk.inner
(#eq? @codechunk.inner "#%%")
)
9 changes: 6 additions & 3 deletions examples/example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ def hello():
print("Hello")
```

```bash
git clone
```

This is how we call it:

```{python}
hello()
```

```{haskell}
```haskell
xs = [x | x <- [1..10]]
```

We can press `gd` to go to its definition.

Let's demonstrate the autompletion:
Let's demonstrate the autocompletion:

```{python}
import numpy as np
Expand Down Expand Up @@ -54,4 +58,3 @@ hello_from_r()
library(tidyverse)
```


4 changes: 4 additions & 0 deletions queries/bash/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(
(comment) @codechunk
(#eq? @codechunk "#%%")
)
2 changes: 2 additions & 0 deletions queries/markdown/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(code_fence_content) @codechunk
(fenced_code_block) @codechunk.outer
4 changes: 4 additions & 0 deletions queries/python/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(
(comment) @codechunk
(#eq? @codechunk "#%%")
)
4 changes: 4 additions & 0 deletions queries/r/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(
(comment) @codechunk
(#eq? @codechunk "#%%")
)

0 comments on commit d2e0f77

Please sign in to comment.