Commit Graph

40818 Commits

Author SHA1 Message Date
Andrew Dupont
0cbdc2a810 Ensure getSyntaxNodeAndGrammarContainingRange
…returns its expected object signature.
2023-05-02 15:49:53 -07:00
Andrew Dupont
c62845d59d Fix issue with highlighting injection layers…
…when they haven't been re-parsed yet.

Say we've got an injection layer on rows 100-150. If a user inserts a newline
on line 1, we know for certain that that doesn't affect the parsed tree of that
injection layer, except that it needs to be edited to incorporate that change
so that its node positions are correct. So we wait to re-parse it because we
don't need to, even though we know the tree is technically dirty. We only need
to re-parse it when an edit occurs within its layer extent.

But each node has a `text` property that's actually just a getter. When `text`
is read, the node looks up its text using its `startIndex` and `endIndex`. If we
called `parse` with a string originally, then it's going to do its lookups
against a string that we know to be stale. Most `#match?` predicates would be
doomed to fail, and if the display layer needed to highlight any part of that
layer, it'd miss a lot of stuff.

Luckily, web-tree-sitter envisions that your buffer might be represented by a
strange data structure, and lets you specify a callback that is used when
the parser needs to get the contents of various buffer ranges. We can have that
callback do its lookups against a string copy of the buffer that we know to be
fresh, because we're updating it on every buffer change.

This is a big deal, because the alternative is having to re-parse every
injection layer on every transaction. Now we can safely run captures against
dirty trees when we know that the changes cannot have affected the structure of
the tree.
2023-05-02 15:49:19 -07:00
confused-Techie
5a166ef376 Comment out Failing tests 2023-05-01 21:30:15 -07:00
confused-Techie
5873e27f40 Install bundled tree-view 2023-05-01 20:51:59 -07:00
confused-Techie
4a5d3155cb Remove keybinding-resolver link at bottom as it was previously missed 2023-05-01 20:43:09 -07:00
confused-Techie
e22a8064fe Update tree-view entry on Readme 2023-05-01 20:42:33 -07:00
confused-Techie
d4e645f059 Update package.json 2023-05-01 20:40:44 -07:00
confused-Techie
ef3ea6db38 Bundle tree-view code 2023-05-01 20:40:09 -07:00
confused_techie
c8aee53bf1
Merge pull request #476 from pulsar-edit/hard-bundles
Bundle `autocomplete-atom-api`
2023-05-01 20:33:50 -07:00
confused-Techie
ac18e8882d Revert "Bundle symbols-view"
This reverts commit 696822a862.
2023-05-01 18:59:52 -07:00
confused-Techie
9b216d1070 Revert "Install symbols-view"
This reverts commit 2dd0e5a432.
2023-05-01 18:59:49 -07:00
confused-Techie
987d149654 Revert "Use original tarball data (not our fork) to bundle, try to match commits on fork"
This reverts commit df7a2555d2.
2023-05-01 18:59:43 -07:00
confused_techie
631d3cb146
Merge pull request #505 from Daeraxa/rpm-buildid
Add FPM option to stop rpm buildid clash
2023-04-30 20:47:28 -07:00
confused_techie
f74da92be1
Merge branch 'master' into renovate/npm-underscore-vulnerability 2023-04-30 20:42:47 -07:00
Andrew Dupont
008fa13c8b Fix a bug in ordering of highlight iterators 2023-04-30 14:48:09 -07:00
Andrew Dupont
d8444b4cbe Add some highlighting fixes to EJS…
…the same ones we applied to ERB earlier.
2023-04-30 14:07:19 -07:00
Andrew Dupont
ee3b8924af Update to latest tree-sitter-ruby
This is the latest `master` — it works fine now that we build our own version
of `web-tree-sitter`.

It's twice as big as the last stable release. I don't know why, but I've been
using it for about a week without any trouble.
2023-04-30 14:06:41 -07:00
Andrew Dupont
1f5947cee7 Add namespaces to Ruby query files…
…and add a `tags.scm`.
2023-04-30 14:05:41 -07:00
Andrew Dupont
28e6a03c01 Fix issue where a non-root layer…
…might not update its own injections during startup as new grammars load.
2023-04-30 14:04:25 -07:00
Andrew Dupont
18b42b1f6d Add fixes for ERB highlighting 2023-04-30 11:47:28 -07:00
Andrew Dupont
e567f407d4 I'm bad at exception-throwing 2023-04-29 15:08:16 -07:00
Andrew Dupont
8dc6ec0a19 Add namespaces to all folds.scm files 2023-04-29 15:01:25 -07:00
Andrew Dupont
1c90032276 Add namespaces to custom #set! predicates
Predicates were getting pretty chaotic. With the namespace, it's now clearer
where a predicate may be defined and what its purpose is. It also helps resolve
ambiguity — e.g., both folds and highlights can have an `endAt` predicate, so
now they're disambiguated as `fold.endAt` and `adjust.endAt`, respectively.

Namespaces:

* `highlight` for highlight-specific settings (of which there is presently only
   one)
* `test` for scope tests (currently used by highlights and indents)
* `adjust` for scope adjustments (highlights)
* `indent` for indent settings
* `fold` for fold settings

Right now, only the `test` namespace will be used by more than one kind of query
file, but I could imagine that changing in the future.

For now, tests and adjustments still work without the prepended namespace, but
I imagine I'll take that out even before we ship this feature experimentally.
Much easier to make big changes like this before anyone depends on them.

This also draws a much clearer line between `#set!` predicates with special
meaning in Pulsar… and those which are being used to set arbitrary data for
later use. For instance, if you see `(#set! isOnLeftSideOfAssignment true)`, you
know it must just be arbitrary data.
2023-04-29 14:58:42 -07:00
confused_techie
a03061576f
Merge pull request #502 from pulsar-edit/renovate/npm-minimist-vulnerability
chore(deps): update dependency minimist [security]
2023-04-29 11:48:35 -07:00
confused_techie
56bf4a4486
Merge pull request #477 from pulsar-edit/happy-ci
Disable Failing Tests
2023-04-29 11:47:17 -07:00
confused_techie
1bf630313f
Merge pull request #501 from pulsar-edit/renovate/npm-ajv-vulnerability
chore(deps): update dependency ajv to 6.12.3 [security]
2023-04-27 15:28:03 -07:00
Andrew Dupont
0237ddceba Update name of Ruby regex injection 2023-04-27 13:53:33 -07:00
Andrew Dupont
8d5de25407 Add back the TODO/hyperlink injections for Ruby 2023-04-27 13:51:43 -07:00
Andrew Dupont
354fecaf77 Add symbols for Jasmine define/it methods…
…to match the `ctags` config for JS files.
2023-04-27 13:50:02 -07:00
Andrew Dupont
20192d80fa Make onlyIfFirstTextOnRow consider the node's…
…starting row.
2023-04-27 13:48:53 -07:00
renovate[bot]
e8547e5434
chore(deps): update dependency ajv to 6.12.3 [security] 2023-04-27 13:22:38 +00:00
Andrew Dupont
92dfb5aab3 Add scope test onlyIfFirstTextOnRow
…and its negation.
2023-04-26 18:17:41 -07:00
Andrew Dupont
71d4ad1d07 Restore core.useTreeSitterParsers setting…
…along with a temporary `core.useExperimentalModernTreeSitter` setting.

If we truly planned to keep three different language modes around indefinitely,
changing `core.useTreeSitterParsers` to an enum would make sense. But we don't,
so it'd actually just be a gigantic pain in the ass to migrate one setting to
another of a different type.

When we ship modern-tree-sitter experimentally, we'll make it opt-in via the
temporary setting. When we make it the official tree-sitter implementation and
remove the legacy node-tree-sitter version, we'll remove the temporary setting
and just change the semantics around `core.useTreeSitterParsers`.

Reverting the addition of the `core.languageParser` setting is a chore, but it
prevents a _gigantic_ future headache.
2023-04-26 17:46:02 -07:00
Andrew Dupont
010aa1fe03 Add forgotten method for invalidateOnChange 2023-04-26 17:31:53 -07:00
Andrew Dupont
9f053522ac Update docs for building custom web-tree-sitter 2023-04-26 17:31:09 -07:00
Andrew Dupont
4ca19440dc Add invalidateOnChange scope setting
It's possible to assign a node different scopes based on its contents, but we
need a way to detect these sorts of nodes so that we know how much of the buffer
to invalidate when that node's contents change.

Previously, we were simply finding the range of the deepest node in the tree for
a given edit and invalidating its entire region, in the hopes that this
heuristic would let us hide this complexity from users. Sadly, we can't get away
with that in terms of performance; the most specific node could end up being a
_very large_ node, and it's just not worth slowing everything else down just to
handle these silly edge cases.

Instead, a grammar author can mark certain queries in `highlights.scm` with
an `invalidateOnChange` property:

```scm
((comment) @comment.block.documentation.javadoc.java
  (#match? @comment.block.documentation.javadoc.java "^/\\*\\*")
  (#set! final true)
  (#set! invalidateOnChange true))

((comment) @comment.block.java
  (#match? @comment.block.java "^/\\*")
  (#set! invalidateOnChange true))

```
Here we've got one scope for a JavaDoc (`/**`) block comment and one for a
regular (`/*`) block comment. Since a change in either kind can flip the scope
of the entire comment, both should be marked with `invalidateOnChange`.

If the world were perfect — if the web-tree-sitter bindings allowed it, or if
we could pre-process query files — we could set this property automatically
whenever a node both (a) defined a `#match?` predicate and (b) began and ended
on different rows. We'd be able to use that information to keep track of these
nodes on our own, as well as detect whether an arbitrary edit will actually
trigger a scope change. In the meantime, this is an unusual enough need that
we'll put the onus on the grammar author for now.
2023-04-26 17:30:50 -07:00
Andrew Dupont
70b8bad11b Style tweaks 2023-04-25 17:47:33 -07:00
Andrew Dupont
883109cc46 Fix a bug in highlights.scm in language-python 2023-04-25 17:46:16 -07:00
Andrew Dupont
d573392b38 Update highlights.scm in language-javascript
Also add `tags.scm` in anticipation of its eventual usage in `symbols-view`.
2023-04-25 17:44:28 -07:00
Andrew Dupont
bccc29c608 Update to latest tree-sitter-html
…because my PR to add recognition of HTML entities was accepted.
2023-04-25 17:42:40 -07:00
Andrew Dupont
8671d9cbee Update highlights.scm in language-cpp 2023-04-25 17:41:41 -07:00
Andrew Dupont
59fbcf9c03 Update to latest tree-sitter-css…
…and update `highlights.scm` accordingly.
2023-04-25 17:40:59 -07:00
Andrew Dupont
d202df8488 Move to a custom version of web-tree-sitter
The comment in `src/web-tree-sitter.js` and the documentation in
`vendor/web-tree-sitter` explain why this change is needed. I hope it's
temporary.

I haven't removed our `web-tree-sitter` dependency in `package.json` because
it's a useful way of declaring (and remembering) which version of tree-sitter
we've built against, and because it lets us flip a single config flag in
`src/web-tree-sitter.js` to compare the behavior of our custom version with that
of the stock version. The cost of keeping the stock version around is under 300
kilobytes.

The custom builds will come from specialty branches on our tree-sitter fork.
When we upgrade to a new version, someone should follow the directions in
`vendor/web-tree-sitter/README.md` to create a new specialty branch.

When someone wants to build a `language-foo` package and finds that
`tree-sitter-foo` needs a function we don't yet export, they should be able to
see the warning we generate in the console and file a ticket. If we're on our
game, we should be able to generate a new web-tree-sitter build and get it into
a rolling release within a week or so.

I hope web-tree-sitter someday finds a way to fix this so that we no longer need
to do this chore. See https://github.com/tree-sitter/tree-sitter/issues/949.
2023-04-25 17:31:49 -07:00
Andrew Dupont
2cd20067b5 Rename syntaxQuery to highlightsQuery
The `syntaxQuery` key in a grammar definition file is the only query whose name
differs from its canonical filename, and there's no reason why that should be
the case. Might as well change it now before we ship instead of going through
the pain of changing it later.
2023-04-25 11:38:53 -07:00
Andrew Dupont
c06b851e07 Typo 2023-04-24 11:02:01 -07:00
Andrew Dupont
c0c4300dfc Be more cautious in the specs…
…by not assuming a certain tree structure.

The injection-point callbacks should not make any assumptions about the tree
because there's no guaranteed that they'll run when the tree is clean.
2023-04-24 11:01:37 -07:00
Andrew Dupont
e11bdcc2e6 Expose tagsQuery to the language mode.
`tags.scm` is a query file that comes standard in a tree-sitter repo, and is one
that we understand well enough to be able to use to identify symbols in the
file.

This is a big deal because it gives us an alternative to the `ctags`-based
symbol navigation that `symbols-view` has been using for ages.

The plan is to refactor `symbols-view` to do nothing except consume various
providers of symbols. We'd bundle a `ctags` provider and a tree-sitter-based
provider by default. LSP-based packages could also register as providers.
2023-04-24 11:00:05 -07:00
Andrew Dupont
93e7757d60 Remove dead code
The old `detectCoveredScope` logic is dead. I have successfully replaced it with
something slightly less awful.
2023-04-24 10:56:51 -07:00
Andrew Dupont
097848736a Guard against check for a tree-sitter tree…
…before a root language layer has been created.
2023-04-24 10:56:03 -07:00
Andrew Dupont
8afdca19f3 Add ability to filter getAllLanguageLayers
…with a predicate.
2023-04-24 10:55:12 -07:00