- treat `restrict`/`_Atomic` like `const`/`volatile` => @keyword.storage.modifier
- highlight `unsigned int` as builtin => @type.builtin
- recognize `static_cast` and friends => @keyword
- `template` is a kind of entity like `typename` => @keyword.storage.type
- many declaration modifiers have nothing to do with storage/types
(explicit, friend, access specifiers, inline in C++) => @keyword
- fix floats highlighted as integer => @constant.numeric
* Keep arrow and special keys in insert
Advanced users won't need it and is useful for beginners.
Revert part of #3671.
* Change text for insert mode section
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Remove ctrl-up/down in insert
* Reorganize insert keys and docs
* Improve page up experience on last tutor
The last tutor page can page down multiple times and it will break the
heading on the 80x24 screen paging when reaching the last page, this
keeps the style the same and make sure page up and down won't break it.
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
This stanza highlights functions within trait definitions. For example,
in:
pub trait Widget {
fn render(self, area: Rect, buf: &mut Buffer);
}
`render` is currently highlighted as a variable. With this change it's
highlighted as a function.
Underline styles are mutally exclusive and overwrite each other.
Therefore implementing as an modifier lead to incorrect behaviour
when the underline style is overwritten.
For backwards compatability the "underline" modified is retained (but
deprecated). Instead the "underline_style" and "underline_color"
optios should be used to style underlines.
The cxterminfo crate has been used over popular alternatives
like `term` since it supports querying for extended capabilities
and also for it's small codebase size (which will make it easy
to inline it into helix in the future if required).
`do_block` and `block` seem to conflict, causing double-indentation in some cases. Removing `do_block` does not seem to have any negative effect, while fixing the double-indentation issue.
The tutor file is loaded as .txt which can potentially spawn a
language server. Then the path is unset, but the LS remains active.
This can cause panics since updates are now submitted for a doc
with no path.
As a quick workaround we remove the extension which should avoid
detection.
Fixes#3730
* avoid coloring `identifier`s globally
* fix function application when not part of `select_expression`
* add `has_attribute_expression` highlighting
* fix precendence for interpolation, which should be after select
* highlight `@` as delimiter
By simply placing a comment with the name of the desired language just
before a multi-line string, that language will be injected.
Also, common functions and attributes which are expected to be shell
code are automatically injected.
There don't appear to be any regressions from the updates.
Also included is a fix which highlights the "#" as in attributes
as punctuation. This was previously unhighlighted.
For example
-record(state, {})
Would not highlight `state` as a type since the alternation didn't
allow for an empty tuple. Allowing the inner atom of the tuple to be
optional fixes this case.
* theme: add papercolor light
* fix typo
* add markup highlighting
* theme: added diff colors
forgot to add it to PaperColor Light
* fix some ui colors
* assign more color for markup headings
* change heading color to bright7
Changed the `namespace` style to fix the issue (#3533).
I also made the theme look a little closer to how it looks in Emacs, I did however opt to still have it slightly different as I found it easier to read with my port than on the original in Emacs.
I also sorted most keys (mainly from line 8 to 28) for the theme to be in alphabetical order, so it's easier to have a quick glance where they are.
* Fix incorrect indent guide styling
Before the indent guides on top of whitespace inherited the theme
from them. Now they do not.
* Fix dark_plus theme indent_guides
* Use whitespace style as fallback for indent-guide
* Fix dark_plus theme indent_guides
* Move indent_guide style patching out of loop
JavaScript queries now contain a few lines that prevent them from
being used whole-sale in typescript with `; inherits: javascript`.
Here we follow nvim-treesitter's way of using a fake 'ecma' language
as a common base for JavaScript and TypeScript to share as much as
we can.
Some lines went longer than the titlebars, fixed regex in
SPLITTING SELECTIONS which wasn't actually correct.
Changed 1 "bat" to a "cat" in ADDING SELECTION ON NEXT
SEARCH MATCH which makes it harder to do with a simple
s select.
The fix comes from the rewriting of the `closure_parameters` stanza:
it was capturing the entire `closure_parameters` node including
paretheses, whitespace, and commas. Capturing the identifiers within
fixes the tracking.
In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.
A few changes to make TSQ highlights better:
* A parsing error has been fixed in the grammar itself
* Previously tree-sitter-tsq did not parse the variables
in predicates like `(#set! injection.language "javascript")`
* Theme nodes as `tag`
* The newly added node to the parser (from the above fix) is
`variable` which takes over the `variable` capture from nodes
* Highlight known predicates as `function` and unsupported
predicates as `error`
* This may help when translating queries from nvim-treesitter.
For example `#any-of?` is a common one used in nvim-treesitter
queries but not implemented in Helix or tree-sitter-cli.
* Inject tree-sitter-regex into `#match?` predicates
- Misspelling of 'modifiers' for markdown.heading.1 and 2.
- Errors are now just underlined instead of in red.
- Diagnostics are dimmed, as well as whitespace.
- Add constant.builtin.
You might use a macro like `?MODULE` to name a record:
-record(?MODULE, {a, b, c}).
With this fix, the record fields correctly get `variable.other.member`
highlights.
* branch message with current branch and diverged branch has been
added to the parser
* scissors used in verbose commits are marked as a punctuation
delimiter
* we could use comment instead since they're visually the
same but IMO this works better
Punctuation highlights would show up outside of where they
were valid, for example using parentheses in some text. This
change prevents that by gating the captures to being under
the named nodes in which they are valid.
* add punctuation highlights for commas as in function parameters
* remove stray `variable.parameter` highlight
* I couldn't find any regressions from this and it fixes an
edge case I ran into (but sadly did not record 😓)
* highlight `fn` as `keyword.function`
* the theme docs have `fn` as an example so it seems fitting
The '#' character may either be interpreted as a map when used
like so:
%% Example 1
#{a => b}
Or as an operator which updates an existing map when the left-hand
side is an expression:
%% Example 2
MyMap#{a => b}
This commit changes the highlight to `punctuation.bracket` when used
as a character in a literal map (example 1) and keeps the `operator`
highlight when used for updating (example 2).
* Add mode specific styles
In similar vein to neovim's lualine and similar statusline packages this
allows helix users to style their mode based on which mode it is thus
making each mode more visually distinct at a glance
* Add an example based on rosepine
* Add editor.colors-mode config
* Document statusline mode styles
* Default rulers color to red
Currently if the theme a user is using doesn't have `ui.virtual.rulers`
set and they set up a ruler it just fails silently making it really hard
to figure out what went wrong. Did they set incorrectly set the ruler?
Are they using an outdated version of Helix that doesn't support rulers?
This happened to me today, I even switched to the default theme with
the assumption that maybe my theme just doesn't have the rulers setup
properly and it still didn't work.
Not sure if this is a good idea or not, feel free to suggest better
alternatives!
* Use builtin Style methods instead of Bevy style defaults
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Only default the style if there's no ui or ui.virtual
* Update themes style from ui.virtual to ui.virtual.whitespace
* Revert ui.virtual change in onelight theme
* Prefer unwrap_or_else
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
I noticed that in Rust, `println!`being a macro, it matched the color of string literals. This was visually confusing to me, so I checked what the nvim catpuccin theme (https://github.com/catppuccin/nvim) does. While it is pretty different, it does use different colors for strings and all function types: https://share.cleanshot.com/RLG2y1
I don't know if blue or red makes more sense given the other syntax choices, but wanted to propose this change cc @IsotoxalDev
The update to the grammar itself covers the case where the document
is a single expression without a trailing newline such as "min(A, B)".
A small change to the parser now parses these expressions correctly
which improves the display of the function head in the signature
help popup.
The update to the queries marks 'andalso', 'orelse', 'not', etc. as
`@keyword.operator` which improves the look - it looks odd to see
operators that are words highlighted the same as tokens like '->'
or '=:='.
the bottom value is used, so i've removed the top `ui.help` values from all themes
also, the values are not merged, so:
```toml
"ui.help" = { modifiers = ["reversed"] }
"ui.help" = { fg = "white", bg = "black" }
```
is equal to:
```toml
"ui.help" = { fg = "white", bg = "black" }
```
* str, list, etc. handled as @function.builtin and @type.builtin
* None and non-conforming type indentifiers as @type in type hints
* class identifiers treated as @type
* @constructor used for constructor definitions and calls rather than
as a catch-all for type-like things
* Parameters highlighted
* self and cls as @variable.builtin
* improved decorator highlighting as part of @function
Re-ordering of some statements to give more accurate priority.
* Adds tutorial sections for multiple areas including:
- Changing selections to uppercase / lowercase
- yanking and pasting
- macros
- selecting to chars with t and f
PS: I got kind of carried away and put off commiting for a while,
will commit to commit more often in the future.
* Changed section titles to all uppercase
* Added recap and section about jumplist
* Added sections for searching in file, joining lines and indenting lines.
* Removed some trailing whitespace
* Evened out the space between sections to all be 5 lines
* Add section on opening lines (o) and recap
* Changed the amount of lines between sections
This is so that - on a 24 line terminal -
only one section is visible at a time and
page up/page down goes straight to the next
section keeping the header at the top.
* Punctuation error
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Punctuation error
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Spelling error
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Remove unnecessary word
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Reword note about searches
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Change word
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* Update tutor file
* Made some small changes suggested by Omnikar
* Added better demo for macros.
* Small changes
- Add newlines at the end
- Make "MACROS" section fit into 22 lines
- Correct mistake of saying helix copied to clipboard in "COPYING AND PASTING TEXT"
* Reformatted notes in copying/pasting section to fit in screen
* Add a note about n and N and their difference to Vim.
* Combine f and t commands into one section.
* Removed t/T section which was merged into the f/F section.
* Merge sections on manipulating case into one.
* Gave section's numbers
* Convert 'press' to 'type' in some places
* Added examples of how prompt lines should look.
* Reformatted notes in copy/pasting section.
* More rewording to more comfortably fit sections on screen.
* Grammatical error.
* Missing periods.
* Missing capital + small reformat
* Fix mis-numbered section
* Reworded to use these conventions when referring to inputs:
- "Press" for single keypresses
- "Type" for multiple keypresses / modifiers
- "Use" when referencing two inputs as a pair.
* till not 'til
* Say 'press' instead of 'type' when referring to symbols
* 'outdent' not 'unindent'
* Typo and grammar.
* Replace all 'press's with 'type's (apart from places it would make no sense in).
* Improve examples for joining and indenting lines.
* Section alignment.
Co-authored-by: Omnikar <omkar.subramaniam@icloud.com>
* log textobject query construction errors
The current behavior is that invalid queries are discarded silently
which makes it difficult to debug invalid textobjects (either invalid
syntax or an update may have come through that changed the valid set
of nodes).
* fix golang textobject query
`method_spec_list` used to be a named node but was removed (I think
for Helix, it was when updated to pull in the support for generics).
Instead of a named node for the list of method specs we have a bunch
of `method_spec` children nodes now. We can match on the set of them
with a `+` wildcard.
Example go for this query:
type Shape interface {
area() float64
perimeter() float64
}
Which is parsed as:
(source_file
(type_declaration
(type_spec
name: (type_identifier)
type: (interface_type
(method_spec
name: (field_identifier)
parameters: (parameter_list)
result: (type_identifier))
(method_spec
name: (field_identifier)
parameters: (parameter_list)
result: (type_identifier))))))
HEEx is a templating engine on top of Elixir's EEx templating
language specific to HTML that is included in Phoenix.LiveView
(though I think the plan is to eventually include it in base
Phoenix). It's a superset of EEx with some additional features
like components and slots.
The injections don't work perfectly because the Elixir grammar is
newline sensitive (the _terminator rule). See
https://github.com/elixir-lang/tree-sitter-elixir/issues/24
for more information.
This will become more important with the HEEx grammar being added.
Error highlighting with the Elixir grammar is a bit jumpy because
in some scenarios, a bit of missing syntax can force tree-sitter to
give up on error recovery and mark the entire tree as an error.
This ends up looking bad when editing. We don't typically highlight
error nodes so I'm inclined to leave it out of the highlights here.
After the incremental parsing rewrite for injections (which was released
in 22.03 https://helix-editor.com/news/release-22-03-highlights/#incremental-injection-parsing-rewrite),
we can now do combined injections which lets us pull in some templating
grammars. The most notable of those is embedded-template - a pretty
straightforward grammar that covers ERB and EJS.
The grammar and highlights queries are shared between the two but they have
different injections.
It looks like a24fb17b2a (and
855e438f55) broke the typescript
highlights because typescript
; inherits: javascript
but it doesn't have those named nodes in its grammar.
So instead we can separate out JSX into its own language and copy
over everything from javascript and supplement it with the new
JSX highlights. Luckily there isn't too much duplication, just the
language configuration parts - we can re-use the parser with the
languages.toml `grammar` key and most of the queries with `inherits`.