When closing a document we must wait until all views have been updated
first - either replacing their current document or closing the view -
before we remove the document from the `documents` map. The
`Editor::_refresh` helper is called by `Editor::close`. It accesses each
View's Document to sync changes and ensure that the cursor is in view.
When closing multiple Views at once, `Editor::_refresh` will attempt
to access the closing Document while refreshing a to-be-closed View.
This fixes a regression from 6da1a79d80. `:buffer-close` on an
unmodified document would cause later panics since the document should
not have been removed. Instead of eagerly removing the document on the
first line we need to wait until we've checked that it's unmodified.
fix: use relative path when finding file
style: cargo fmt
_
chore: better error message
refactor: rename to `blame_line`
fix: use line of primary cursor for git blame
feat: basic implementation of blocking Blame handler
feat: implement basic virtual text (end of line blame)
feat: figure out how to draw stuff at the end of lines
feat: implement end of line virtual text for the current line
feat: implement inline git blame
chore: clean up
chore: remove unused import
_
chore: set `blame` to `false` by default
docs: document `[editor.vcs.blame]`
chore: add progress
perf: use background task for worker
_
chore: remove unnecessary panic!s
chore: remove commented code
refactor: remove some layers of abstraction
refactor: remove nesting
feat: [editor.vcs] -> [editor.version-control]
fix: account for inserted and deleted lines
_
refactor: extract into a `blame` module
feat: allow using custom commit format
feat: allow more customizability for inline blame
test: add tests for custom inline commit parsser
refactor: rename `blame` -> `blame_line`
_
_
test: create helper macros for tests
test: make test syntax more expressive. Allow specifying line numbers
that just got added
test: with interspersed lines
feat: add `line_blame` static command
_
test: add an extra test case
test: add ability to have `delete`d lines
test: fix on windows (?)
test: `delete` test case
test: add extra step to test case
test: add documentation for macro
refactor: use `hashmap!` macro
refactor: collapse match arm
fix: remove panic
perf: update inline git blame every 150 milliseconds instead of on each
command
test: add attributes on blocks
style: move function earlier in the file
perf: cache blame results in a hashma
chore: remove log statements
chore: clean up.
ALSO: removes checking for inline blame every N seconds.
_
perf: use mspc instead of busy-wait
docs: add information why we don't optimize the repo
_
test: add back the commented out tests
chore: comment out cfg(not(windows))
test: add extra history to blame test
docs: remove incorrect static command
_
test: disable test on windows
feat: send inline blame event update when reloading or saving the
document
feat: rename `version-control` -> `inline-blame`
feat: update theme key used for inline-blame
chore: remove unused #![allow]
chore:
style: remove accidental formatting
docs: remove incorrect key
perf: Use a single `ThreadSafeRepository` instead of re-constructing it
each time
feat: add `inline_blame` static command bound to `space + B`
style: revert formatting in keymap.md
chore: do not compute blame for document when changing config option
This isn't needed anymore because the inline-blame will be computed
regardless if `inline_blame.enable` is set or not
style: remove newline
refactor: use `fold` instead of loop
chore: clean up
feat: log error forl line blame when it happens
feat: improve message when we don't have the blame
We know that we don't have it because we're still calculating it.
feat: do not render inline blame for empty lines
_
feat: do not show blame output when we are on a hunk that was added
refactor: remove additional wrapper methods
fix
_
feat: more readable time for git blame
chr
feat:
feat: improved error handling
fix: path separator on Windows
test: disable on windows
refactor: move pretty date function formatter into `helix-stdx`
perf: do not use a syscall on each render
chore: add TODO comment to update gix version
chore: use `gix::path` conversion from Path -> BString
_
_
chore: do not update file blame on document save
This is not needed because when we write the file, we don't make a new
commit so the blame will not change.
refactor: use statics to get time elapsed instead of editor state
refactor: do not use custom event, use handler instead
fix: do not spawn a new handler
docs: correct examples for `editor.inline-blame.format`
docs: correct static command name
refactor: add comments, and improve variable names
I didn't really understand this function when I made it. Was just
copy-pasted from end of line diagnostics
I wanted to know what this is actually doing, so I investigated and
while doing this also added comments and improved names of variables
so others can understand too
fix: time in future is accounted for
perf: inline some functions that are called in only 1 place, during a
render loop
perf: add option to disable requesting inline blame in the background
fix: request blame again when document is reloaded
chore: inline blame is disabled with request on demand
feat: when requesting line blame with "blame on demand", show blame in
status
perf: use less allocations
perf: less allocations in `format_relative_time`
_
_
_
_
docs: correct name of command
_
feat: improve error message
_
feat: rename enum variants for inline blame behaviour
docs: improve description of behaviour field
Previously the `call` helper (and its related functions) returned a
`serde_json::Value` which was then decoded either later in the client
(see signature help and hover) or by the client's caller. This led to
some unnecessary boilerplate in the client:
let resp = self.call::<MyRequest>(params);
Some(async move { Ok(serde_json::from_value(resp.await?)?) })
and in the caller. It also allowed for mistakes with the types. The
workspace symbol request's calling code for example mistakenly decoded a
`lsp::WorkspaceSymbolResponse` as `Vec<lsp::SymbolInformation>` - one of
the untagged enum members (so it parsed successfully) but not the
correct type.
With this change, the `call` helper eagerly decodes the response to a
request as the `lsp::request::Request::Result` trait item. This is
similar to the old helper `request` (which has become redundant and has
been eliminated) but all work is done within the same async block which
avoids some awkward lifetimes. The return types of functions like
`Client::text_document_range_inlay_hints` are now more verbose but it is
no longer possible to accidentally decode as an incorrect type.
Additionally `Client::resolve_code_action` now uses the `call_with_ref`
helper to avoid an unnecessary clone.
This adds events for:
* a document being opened
* a document being closed
* a language server sending the initialized notification
* a language server exiting
and also moves some handling done for these scenarios into hooks,
generally moving more into helix-view. A hook is also added on
`DocumentDidChange` which sends the `text_document_did_change`
notification - this resolves a TODO in `document`.
This resolves a TODO in the core diagnostic module to refactor this
type. It was originally an alias of `LanguageServerId` for simplicity.
Refactoring as an enum is a necessary step towards introducing
"internal" diagnostics - diagnostics emitted by core features such as
a spell checker. Fully supporting this use-case will require further
larger changes to the diagnostic type, but the change to the provider
can be made first.
Note that `Copy` is not derived for `DiagnosticProvider` (as it was
previously because `LanguageServerId` is `Copy`). In the child commits
we will add the `identifier` used in LSP pull diagnostics which is a
string - not `Copy`.
These match the equivalent options in VSCode. `trim_trailing_whitespace`
is also the name used by EditorConfig.
* `trim-final-newlines` trims any extra line endings after the final one
* `trim-trailing-whitespace` trims any trailing whitespace (but not
empty lines)
Previously LSP notifications were sent within a future and most callers
used a `tokio::spawn` to send the notification, silently discarding any
failures like problems serializing parameters or sending on the channel.
It's possible that tokio could schedule futures out of intended order
though which could cause notifications where order is important, like
document synchronization, to become partially shuffled. This change
removes the future wrapper and logs all internal failures.
Also included in this commit is the same change for `Client::reply`
which was also unnecessarily wrapped in a future.
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
* feat: improve information on the amount of files loaded
* refactor: naming consitency Doc and not Buf
* fix: correct name of method
* chore: appease clippy
* feat: more human error information when Helix cannot start
* refatcor: use if guard on match arm
* Handle window/showMessage and display it bellow status line
* Enable `editor.lsp.display_messages` by default
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
In the case of network file systems, if the server time is ahead
of the local system time, then helix could annoy with messages
that the file has already been modified by another application.
* replicate t-monaghan's changes
* remove View.offset in favour of Document.view_data.view_position
* improve access patterns for Document.view_data
* better borrow checker wrangling with doc_mut!()
* reintroduce ensure_cursor_in_view in handle_config_events
since we sorted out the borrow checker issues using partial borrows,
there's nothing stopping us from going back to the simpler implementation
* introduce helper functions on Document .view_offset, set_view_offset
* fix rebase breakage
This commit brings the text decoration API inline with the
LineAnnotation API (so they are consistent) resulting in a single
streamlined API instead of multiple ADHOK callbacks.
This introduces a custom URI type in core meant to be extended later
if we want to support other schemes. For now it's just a wrapper over a
PathBuf. We use this new URI type to firewall `lsp::Url`. This was
previously done in 8141a4a but using a custom URI type is more flexible
and will improve the way Pickers handle paths for previews in the child
commit(s).
Co-authored-by: soqb <cb.setho@gmail.com>
* Implement check before adding path to files
* fix problem where directories were removed from args.files
* Revert "Implement check before adding path to files"
This reverts commit c123944d9b.
* Dissallow opening of irregular non-symlink files
* Fixed issue with creating new file from command line
* Fixed linting error.
* Optimized regularity check as suggested in review
* Created DocumentOpenError Sum Type to switch on in Application
* Forgot cargo fmt
* Update helix-term/src/application.rs
Accept suggestion in review.
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Moved thiserror version configuration to the workspace instead of the individual packages.
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* auto save after delay
* configable
* clearer names
* init
* working with some odd behaviour
* working with greater consistency
* Apply reviewer suggestions
- Remove unneccessary field
- Remove blocking save
* Improve auto-save configuration
Auto save can be configured to trigger on focus loss:
```toml
auto-save.focus-lost = true|false
```
and after a time delay (in milli seconds) since last keypress:
```toml
auto-save.after-delay.enable = true|false
auto-save.after-delay.timeout = [0, u64::MAX] # default: 3000
```
* Remove boilerplate and unnecessary types
* Remove more useless types
* Update docs for auto-save.after-delay
* Fix wording of (doc) comments relating to auto-save
* book: Move auto-save descriptions to separate section
---------
Co-authored-by: Miguel Perez <miguelvojito@gmail.com>
Co-authored-by: Miguel Perez <perezoji@cs.fsu.edu>
Without a serializer, we drop the custom alphabet when making config
modifications like with `:set`. For example before this commit,
`:set mouse false` would reset a custom alphabet to the default.
* feat: add 'file-abs-path' to statusline (#4434)
* cleanup implementation
* rename to be non-abbreviated names
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
URIs need to be normalized to be comparable. For example a language
server could send a URI for a path containing '+' as '%2B' but we might
encode this in something like 'Document::url' as just '+'. We can
normalize the URI straight into a PathBuf though since this is the only
value we compare these diagnostics URIs against. This also covers
edge-cases like windows drive letter capitalization.
`syn_loader` was replaced rather than interior value being replace,
old value was still being referenced and not updated after `:config-refresh`.
By using `ArcSwap` like for `config`, each `.load()` call will return the most
updated value.
Co-authored-by: kyfan <kyfan@email>
Currently, helix implements operations which change the paths of files
incorrectly and inconsistently. This PR ensures that we do the following
whenever a buffer is renamed (`:move` and workspace edits)
* always send did_open/did_close notifications
* send will_rename/did_rename requests correctly
* send them to all LSP servers not just those that are active for a
buffer
* also send these requests for paths that are not yet open in a buffer (if
triggered from workspace edit).
* only send these if the server registered interests in the path
* autodetect language, indent, line ending, ..
This PR also centralizes the infrastructure for path setting and
therefore `:w <path>` benefits from similar fixed (but without didRename)
We use `which::which` in many crates, so `which` was a separate
dependency across all of them. We can centralize `which` into the
stdx crate so it's easy for all crates to depend on it.
I also moved the rest of `helix-view/src/env.rs` into helix-stdx's
`env` module since it only contained a thin wrapper around `which`
and `std::env`.