Commit Graph

166 Commits (fd0e4b1159e2e96548a5fa962298fe8f2a80fc5c)

Author SHA1 Message Date
Blaž Hrastnik a930f99179 fix: Make sure to actually use idle_timeout config value for the timers 2021-10-10 22:39:47 +09:00
Blaž Hrastnik 633b981db2 Make idle-timeout configurable 2021-10-10 12:32:06 +09:00
Blaž Hrastnik f99bea404f idle timer wip 2021-10-05 22:27:10 +09:00
Dmitry Sharshakov bf53aff27d Merge branch 'master' into debug 2021-09-25 23:14:59 +03:00
lurpahi a958d34bfb
Add option for automatic insertion of closing-parens/brackets/etc (#779)
* Add auto-pair editor option

* Document auto-pair editor option

* Make cargo fmt happy

* Actually make cargo fmt happy

* Rename auto-pair option to auto-pairs

* Inline a few constants

Co-authored-by: miaomai <cunso@tutanota.com>
2021-09-24 10:28:44 +09:00
kraem 4a003782a5
enable smart case regex search by default (#761) 2021-09-20 13:45:07 +09:00
Kirawi ef532e0c0d
log errors produced when trying to initialize the LSP (#746) 2021-09-15 14:58:06 +09:00
Blaž Hrastnik 72cf86e462 Regex prompts should have a history with a specifiable register 2021-09-08 16:34:04 +09:00
Blaž Hrastnik 46f3c69f06 lsp: Don't send notifications until initialize completes
Then send open events for all documents with the LSP attached.
2021-09-06 15:25:46 +09:00
Blaž Hrastnik 59ed1c8c78 Simplify documents & documents_mut() 2021-09-06 15:25:46 +09:00
Blaž Hrastnik dc7799b980 lsp: Refactor code that could use document_by_path_mut 2021-09-06 15:25:46 +09:00
Blaž Hrastnik c00cf238af Simplify textDocument/didClose, we don't need to look up LSP again 2021-09-06 15:25:46 +09:00
oberblastmeister 99a753a579
Document macros (#693)
* add docs

* clean up

* remove

* more

* Update helix-view/src/macros.rs

Co-authored-by: Ivan Tham <pickfire@riseup.net>

Co-authored-by: Ivan Tham <pickfire@riseup.net>
2021-09-05 12:42:33 +09:00
Blaž Hrastnik b997d2cdeb dap: Allow setting breakpoints before starting the adapter 2021-09-03 13:26:30 +09:00
Dmitry Sharshakov 5b20f6020a Merge remote-tracking branch 'origin/master' into debug
Contains type fix on helix-term/src/ui/editor.rs:752:13
2021-08-31 21:29:11 +03:00
Omnikar e772808a5b
Shell commands (#547)
* Implement shell interaction commands

* Use slice instead of iterator for shell invocation

* Default to `sh` instead of `$SHELL` for shell commands

* Enforce trailing comma in `commands` macro

* Use `|` register for shell commands

* Move shell config to `editor` and use in command

* Update shell command prompts

* Remove clone of shell config

* Change shell function names to match prompts

* Log stderr contents upon external command error

* Remove `unwrap` calls on potential common errors

`shell` will no longer panic if:
  * The user-configured shell cannot be found
  * The shell command does not output UTF-8

* Remove redundant `pipe` parameter

* Rename `ShellBehavior::None` to `Ignore`

* Display error when shell command is used and `shell = []`

* Document shell commands in `keymap.md`
2021-08-31 18:13:16 +09:00
Dmitry Sharshakov b42631942b
Defaults in completions, better schema 2021-08-29 14:51:47 +03:00
Dmitry Sharshakov 2d42766a71
wip: refactor parameters in UI start 2021-08-29 10:23:36 +03:00
Dmitry Sharshakov 94901b8677
Customized completion for template parameters 2021-08-28 19:11:19 +03:00
Dmitry Sharshakov 8df6739759
New way of starting debug sessions 2021-08-28 14:23:54 +03:00
Dmitry Sharshakov 890b51b568
Paginated variables 2021-08-28 10:13:19 +03:00
Dmitry Sharshakov c7759a5aa0
Merge remote-tracking branch 'origin/master' into debug 2021-08-25 19:22:01 +03:00
Kirawi b99db7c687
Move path util functions from helix-term to helix-core (#650) 2021-08-25 10:04:05 +09:00
Dmitry Sharshakov a938f5a87a
refactor: handle DAP events in editor main loop 2021-08-21 17:21:35 +03:00
Dmitry Sharshakov 6458edecfd
Add stack pointer display when stopped 2021-08-21 14:15:29 +03:00
Blaž Hrastnik 94a1951d40 Work towards a breakpoint UI 2021-08-20 13:51:38 +09:00
Blaž Hrastnik d39baa3b4e Start integrating into the editor's event loop 2021-08-20 13:48:32 +09:00
Blaž Hrastnik 557fd86e71 Extract view.inner_area(), simplify render_focused_view_elements 2021-08-19 15:59:03 +09:00
Blaž Hrastnik 9776553ad0 Refactor view.first_line/first_col into view.offset (Position) 2021-08-19 12:52:07 +09:00
Grzegorz Baranski 78923496a6
feat: relative numbers (#485)
* feat(helix-view): configuring line-number

* feat(helix-term): relative line numbers

* feat(helix-term): passing editor::Config to render

* fix(helix-view): remove LineNumber::None

* feat(helix-term): rendering line-number according to configuration

* fix(term): put calculating current line above line iteration

* fix: add abs_diff function

* deps: cargo update

* fix: pass config argument
2021-08-16 11:11:53 +09:00
Gokul Soumya d84f8b5fde
Show file preview in split pane in fuzzy finder (#534)
* Add preview pane for fuzzy finder

* Fix picker preview lag by caching

* Add picker preview for document symbols

* Cache picker preview per document instead of view

* Use line instead of range for preview doc

* Add picker preview for buffer picker

* Fix render bug and refactor picker

* Refactor picker preview rendering

* Split picker and preview and compose

The current selected item is cloned on every event, which is
undesirable

* Refactor out clones in previewed picker

* Retrieve doc from editor if possible in filepicker

* Disable syntax highlight for picker preview

Files already loaded in memory have syntax highlighting enabled

* Ignore directory symlinks in file picker

* Cleanup unnecessary pubs and derives

* Remove unnecessary highlight from file picker

* Reorganize buffer rendering

* Use normal picker for code actions

* Remove unnecessary generics and trait impls

* Remove prepare_for_render and make render mutable

* Skip picker preview if screen small, less padding
2021-08-12 16:00:42 +09:00
Dmitry Sharshakov 7d51805e94
Support primary clipboard (#548)
* clipboard-none: add in-memory fallback buffer

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* view: add Wayland primary clipboard

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Format

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: copy to primary selection after mouse move stops

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: don't update primary selection if it is a single character

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: discard result of setting primary selection

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: add commands for interaction with primary clipboard

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* editor: implement primary selection copy/paste using commands

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard: support xsel for primary selection

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard: support xclip for primary selection

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: multiple cursor support for middle click paste

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* rename primary selection to primary clipboard in scope of PR

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: make middle click paste optional

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Format

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Update helix-term/src/ui/editor.rs

* fix formatting

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* config: correct defaults if terminal prop is not set

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* refactor: merge clipboard and primary selection implementations

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Tidy up code

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* view: remove names for different clipboard/selection providers

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Update helix-view/src/clipboard.rs

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>

* helix-view: tidy macros

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: refactor paste-replace commands

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: use new config for middle-click-paste

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard: remove memory fallback for command and windows providers

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard-win: fix build

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard: return empty string when primary clipboard is missing

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* clipboard: fix errors in Windows build

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
2021-08-12 11:53:48 +09:00
Dmitry Sharshakov 27b551d345
helix-term: handle scrolling when mouse is enabled (#554)
* helix-term: handle scrolling when mouse is enabled

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: configure scrolling speed

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: use new config for scrolling

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* config: defaults for edtior config

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* config: add scroll-lines property

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: scroll hovered view

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: support inverted scrolling

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: remove duplicating code

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: do not focus view while scrolled

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* helix-term: refactor mouse events and scrolling

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* simplify

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2021-08-10 14:35:20 +09:00
Blaž Hrastnik a2ccfffda1 config: Rename [terminal] to [editor] and pass it into Editor 2021-08-08 14:10:01 +09:00
Nathan Vegdahl f62ec6e51e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 2021-07-26 11:19:10 -07:00
Gokul Soumya 88d6f65239
Allow multi key remappings in config file (#454)
* Use tree like structure to store keymaps

* Allow multi key keymaps in config file

* Allow multi key keymaps in insert mode

* Make keymap state self contained

* Add keymap! macro for ergonomic declaration

* Add descriptions for editor commands

* Allow keymap! to take multiple keys

* Restore infobox display

* Fix keymap merging and add infobox titles

* Fix and add tests for keymaps

* Clean up comments and apply suggestions

* Allow trailing commas in keymap!

* Remove mode suffixes from keymaps

* Preserve order of keys when showing infobox

* Make command descriptions smaller

* Strip infobox title prefix from items

* Strip infobox title prefix from items
2021-07-27 01:07:13 +09:00
Nathan Vegdahl 0883b4fae0 Collect some common patterns into methods on `Range`. 2021-07-26 08:40:30 -07:00
Nathan Vegdahl b0311f4fc2 Fixed primary cursor position calculation to use 1-width semantics.
This had a bunch of knock-on effects that were buggy, such as bracket
match highlighting.
2021-07-19 09:25:10 -07:00
Cor 9fcbbfa467 Changed startup behaviour to only open a single view when multiple files are specified on the commandline.
Changed the behaviour; the first argument on the commandline is the file on display
2021-07-18 00:29:05 +09:00
Blaž Hrastnik d530d6e39d Further simplify error handling in :commands 2021-07-11 16:36:36 +09:00
Lionel Flandrin 9c02a1b070 Make command implementation return a Result<()>
The error message is displayed with cx.editor.set_error.
2021-07-11 16:36:20 +09:00
Ivan Tham 5977b07e19 Reduce calculation and improve pattern in infobox
- switch to use static OnceCell to calculate Info once
- pass Vec<(&[KeyEvent], &str)> rather than Vec<(Vec<KeyEvent>, &str)>
- expr -> tt to allow using | as separator, make it more like match
2021-07-04 18:01:59 +09:00
Ivan Tham 8985c58fd3 Add infobox 2021-07-04 18:01:59 +09:00
Joe Neeman c9be480bf8 Make formatting happen asynchronously. 2021-06-30 17:08:50 +09:00
Keith Simmons 4418e17547
reverse the dependency between helix-tui and helix-view (#366)
* reverse the dependency between helix-tui and helix-view by moving a fiew types to view

* fix tests

* clippy and format fixes

Co-authored-by: Keith Simmons <keithsim@microsoft.com>
2021-06-25 12:58:15 +09:00
Shafkath Shuhan fd98e743e8 Handle non-UTF8 files 2021-06-23 15:40:27 +09:00
Nathan Vegdahl e686c3e462 Merge branch 'master' of github.com:helix-editor/helix into line_ending_detection
Rebasing was making me manually fix conflicts on every commit, so
merging instead.
2021-06-20 16:09:14 -07:00
Nathan Vegdahl 4efd6713c5 Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
2021-06-20 15:33:02 -07:00
Benoît CORTIER a2b8cfca34 Add system clipboard yank and paste commands
This commit adds six new commands to interact with system clipboard:
- clipboard-yank
- clipboard-yank-join
- clipboard-paste-after
- clipboard-paste-before
- clipboard-paste-replace
- show-clipboard-provider

System clipboard provider is detected by checking a few environment
variables and executables. Currently only built-in detection is
supported.

`clipboard-yank` will only yank the "main" selection, which is currently the first
one. This will need to be revisited later.

Closes https://github.com/helix-editor/helix/issues/76
2021-06-20 23:25:53 +09:00
wojciechkepka 6825e19509 Only reconfiure highlights when setting theme 2021-06-20 00:07:13 +09:00
wojciechkepka ce97a2f05f Add ability to change theme on editor 2021-06-20 00:07:13 +09:00
wojciechkepka c5a2fd5da3 Add `close_language_servers` method on `Editor` 2021-06-19 13:02:56 +09:00
Benoît CORTIER 8664d70e73 Replace `Editor::current` by a macro
This is necessary to workaround ownership issues across function calls.
The issue notably arised when implementing the registers into `Editor`
and I was getting annoyed again when implementing copy/pasting into
system clipboard.
The problem is addressed by using macro calls instead of function calls.
There is no notable side effect.
2021-06-18 09:38:10 +09:00
Ivan Tham 124514aa70 Add cursor kind to separate hidden cursor from pos
Now IME cursor position should be correct since we can still set cursor
position without drawing the cursor.
2021-06-15 23:46:21 +08:00
Benoît CORTIER 6bdf609caa Remove RwLock for registers
Registers are stored inside `Editor` and accessed without `RwLock`.
To work around ownership, I added a sister method to `Editor::current`:
`Editor::current_with_context`. I tried to modify `Editor::current`
directly but it's used at a lot of places so I reverted into this for
now at least.
2021-06-15 23:01:56 +08:00
Robin 44cc0d8eb0
add alternate file (#223)
* add alternate file

inspired by vim ctrl-6/kak ga commands. the alternate file is kept per view

* apply feedback from #223

* rename to last_accessed

* add ga doc

* add fail message for ga
2021-06-12 21:21:06 +09:00
Wojciech Kępka 098806ce2a
lsp: Display LSP progress messages (#216) 2021-06-11 12:42:16 +09:00
Ivan Tham 7cc13fefe9 Derive debug without feature
Note that this also removed those `finish_non_exhaustive()`.
2021-06-10 22:00:08 +09:00
notoria 1a3a924634 Implement Debug for data structure as a feature 2021-06-10 22:00:08 +09:00
Zheming Li ae51065213 Support go to line 1 2021-06-08 17:27:21 +09:00
Egor Karavaev 960bc9f134 Don't panic on LSP not starting 2021-06-08 10:02:41 +09:00
Benoît CORTIER 68affa3c59 Implement register selection
User can select register to yank into with the " command.
A new state is added to `Editor` and `commands::Context` structs.
This state is managed by leveraging a new struct `RegisterSelection`.
2021-06-07 21:52:09 +09:00
Wojciech Kępka 14f511da93 Create document if it doesn't exist on save 2021-06-06 17:28:09 +08:00
Blaž Hrastnik 06d8d3f55f Try to detect language when document file path is set
Fixes #91
2021-06-04 11:03:40 +09:00
Blaž Hrastnik c0332bd935 Fix split sizes getting out of sync with the terminal size, refs #69 2021-06-03 10:28:49 +09:00
Blaž Hrastnik 2100f5a2c0 Address clippy lint. 2021-05-17 23:01:45 +09:00
Blaž Hrastnik 8f6f329057 If switching to a previously open buffer in the same view, keep it's old offset 2021-05-17 16:36:13 +09:00
Blaž Hrastnik c0a8b81487 Only send the document close event if we're closing the underlying buffer 2021-05-07 14:52:47 +09:00
Blaž Hrastnik c20813690f View::new is infallible, so is editor.switch/new_file. 2021-05-07 14:45:49 +09:00
Blaž Hrastnik f2c79e245b Allow switching views back to scratch buffers. 2021-05-07 14:36:37 +09:00
Blaž Hrastnik 418ee17b86 Canonicalize the path on open to avoid duplicates. 2021-05-07 14:30:23 +09:00
Blaž Hrastnik 7c915dc065 Add the :new command, don't crash if saving without filename. 2021-05-07 14:19:58 +09:00
Blaž Hrastnik fd4fd12fa3 clippy lint 2021-05-06 17:20:00 +09:00
Blaž Hrastnik d00414f81a Start moving more LSP calls into callbacks/futures without capturing self 2021-05-06 15:08:59 +09:00
Blaž Hrastnik 355ad3cb82 Tokio migration. 2021-05-06 13:56:34 +09:00
Blaž Hrastnik bc4e54c0c4 Load config files from ~/.config/helix, fallback to defaults. 2021-04-07 23:56:20 +09:00
Blaž Hrastnik 91462af546 Allow starting hx without a file. A new blank file will be created. 2021-04-06 19:02:22 +09:00
Blaž Hrastnik 0dbd5b61ef Simplify code by providin cx.current() = (view, doc). 2021-04-01 11:01:26 +09:00
Blaž Hrastnik ceea5eacd8 clippy lint 2021-03-31 23:42:16 +09:00
Blaž Hrastnik 6c4093c946 Weave through view_id references so that views into one file have independent selects. 2021-03-31 17:17:01 +09:00
Blaž Hrastnik c1f2a14453 view: document.rs cleanup 2021-03-29 15:22:43 +09:00
Blaž Hrastnik a65395d94b Load theme from toml file. 2021-03-25 16:42:14 +09:00
Blaž Hrastnik 8657c57cf2 Trivial jumplist implementation. 2021-03-24 18:01:26 +09:00
Blaž Hrastnik 4b176caded Reset first_line when changing files. 2021-03-24 16:56:29 +09:00
Blaž Hrastnik 8a0ab447ec editor.open can now either replace the current view or open in a split. 2021-03-24 14:28:26 +09:00
Blaž Hrastnik b24cdd1295 Derive a separate ViewId type. 2021-03-24 14:03:20 +09:00
Blaž Hrastnik 8328fe926d Drop refcell use, make view simply ref doc.id. 2021-03-23 18:14:35 +09:00
Blaž Hrastnik bf95ee27aa Store Document on the Editor type, make View reference it. 2021-03-22 13:53:43 +09:00
Blaž Hrastnik cbcacb1063 Merge some imports. 2021-03-22 12:40:07 +09:00
Blaž Hrastnik 8ba1e15d29 Expose doc.syntax() via accessor. 2021-03-18 14:53:29 +09:00
Blaž Hrastnik 51c15da3c3 Hold a reference to executor on the Editor type. 2021-03-16 23:14:51 +09:00
Blaž Hrastnik e3ec5e31ec Fix goto code before merging. 2021-03-16 23:05:43 +09:00
Jan Hrastnik eadad13efa preparing for gd merge 2021-03-16 23:03:29 +09:00
Jan Hrastnik 4e461bea2f editor.open now checks if view already exists 2021-03-16 23:03:29 +09:00
Blaž Hrastnik 54a7e893b7 lsp: Wire up didClose notification on editor.close. 2021-03-16 16:27:12 +09:00
Blaž Hrastnik eca2a73ad0 lsp: Pass through language_id on didOpenTextDocument. 2021-03-16 16:13:41 +09:00
Blaž Hrastnik dd91090a1a Implement keep_selections (filter selections on regex). 2021-03-15 17:09:18 +09:00
Blaž Hrastnik bb87b08fc9 Configure language servers via LanguageConfiguration. 2021-03-14 17:14:34 +09:00
Blaž Hrastnik 8f4ff4c646 editor: We still want to be able to calculate cursor pos. 2021-03-02 15:44:09 +09:00
Blaž Hrastnik 8289bd1cb0 minor, fix clippy lint 2021-02-25 16:52:32 +09:00