Commit Graph

169 Commits (b6c700fce9c13d883578f9cc5e81d624e9fbd9f8)

Author SHA1 Message Date
Skyler Hawthorne 0f3c10a021 Fix initial selection of Document in new view
When a new View of a Document is created, a default cursor of 0, 0 is
created, and it does not get normalized to a single width cursor until
at least one movement of the cursor happens. This appears to have no
practical negative effect that I could find, but it makes tests difficult
to work with, since the initial selection is not what you expect it to be.

This changes the initial selection of a new View to be the width of the
first grapheme in the text.
2022-06-18 23:54:03 -04:00
Blaž Hrastnik 3d9923969a
minor: Simplify Document.language_id() 2022-06-07 00:23:41 +09:00
farwyler f92a25a856
Passing extra formatting options to LSPs (#2635)
* allows passing extra formatting options to LSPs

- adds optional field 'format' to [[language]] sections in 'languages.toml'

- passes specified options the LSPs via FormattingOptions

* cleaner conversion of formatting properties

* move formatting options inside lsp::Client

* cleans up formatting properties merge
2022-06-05 19:50:57 +09:00
chunghha 3a398eec56
fix typos (#2304) 2022-04-27 14:21:20 -05:00
Omnikar 660e0e44b2
Add `:write!` to create nonexistent subdirectories (#1839)
* Make `:write` create nonexistent subdirectories

Prompting as to whether this should take place remains a TODO.

* Move subdirectory creation to new `w!` command
2022-04-12 16:52:54 +09:00
Roland Kovacs d962e06e91
Add runtime language configuration (#1794) (#1866)
* Add runtime language configuration (#1794)

* Add set-language typable command to change the language of current buffer.
* Add completer for available language options.

* Update set-language to refresh language server as well

* Add language id based config lookup on `syntax::Loader`.
* Add `Document::set_language3` to set programming language based on language
  id.
* Update `Editor::refresh_language_server` to try language detection only if
  language is not already set.

* Remove language detection from Editor::refresh_language_server

* Move document language detection to where the scratch buffer is saved.
* Rename Document::set_language3 to Document::set_language_by_language_id.

* Remove unnecessary clone in completers::language
2022-04-05 09:56:14 +09:00
Blaž Hrastnik c18de0e8f0
fix: Don't rely on FormattingOptions::default()
Refs #1884
2022-03-30 15:19:21 +09:00
Skyler Hawthorne a494f47a5d
Configurable auto pairs (#1624)
* impl auto pairs config

Implements configuration for which pairs of tokens get auto completed.

In order to help with this, the logic for when *not* to auto complete
has been generalized from a specific hardcoded list of characters to
simply testing if the next/prev char is alphanumeric.

It is possible to configure a global list of pairs as well as at the
language level. The language config will take precedence over the
global config.

* rename AutoPair -> Pair

* clean up insert_char command

* remove Rc

* remove some explicit cloning with another impl

* fix lint

* review comments

* global auto-pairs = false takes precedence over language settings

* make clippy happy

* print out editor config on startup

* move auto pairs accessor into Document

* rearrange auto pair doc comment

* use pattern in Froms
2022-02-25 17:36:54 +09:00
Blaž Hrastnik a449156702 Extract a lsp position helper 2022-02-18 14:37:59 +09:00
Gokul Soumya 59b5bf3178 Refactor document methods 2022-02-10 10:56:08 +09:00
Blaž Hrastnik e2d2f19fd0
Merge pull request #1154 from sudormrfbin/cursor-shape-new
Change cursor shape on mode change
2022-01-23 16:35:22 +09:00
Blaž Hrastnik 4080341977 cargo fmt + clippy lint 2022-01-23 16:15:27 +09:00
Blaž Hrastnik 53d881f172 Store theme scopes on the loader, this way theme isn't passed around 2022-01-23 16:00:24 +09:00
Blaž Hrastnik 6728e44490 syntax: Split parsing and highlighting 2022-01-23 16:00:24 +09:00
Kevin Sjöberg 3a34036310
Use the correct language ID for JavaScript & TypeScript (#1466)
* Use correct language ID for JavaScript/TypeScript

* Add missing slash

* Only calculate fallback when needed
2022-01-15 15:23:06 +09:00
Gokul Soumya 449624965b Merge branch 'master' into cursor-shape-new 2022-01-06 11:32:03 +05:30
Matouš Dzivjak 4b0b1a5657
feat(ui): file encoding in statusline (#1355)
* feat(ui): file encoding in statusline

Display file encoding in statusline if the encoding
isn't UTF-8.

* Re-export encoding_rs from core

From there it can be imported by other mods
that rely on it.
2021-12-26 00:10:46 +09:00
WindSoilder 600ce70cf6
Improve dedent behavior (#1232)
* tmp add code for dedent

* finish normal_mode with dedent behavior

* use function pointer

* rebase from origin

* check dedent condition inside normal_mode implementation

* using if let...

* fix check

* using char_is_whitespace instead of ch.is_whitespace

* fix clippy

* abstract restore_indent function
2021-12-21 18:17:55 +09:00
Gokul Soumya d4fb1d0633 Merge branch 'master' into cursor-shape-new 2021-12-18 08:33:15 +05:30
Gokul Soumya 016640f4fb Remove ui.cursor.primary and hashmap lookups 2021-12-18 08:26:11 +05:30
Ivan Tham e2b428cc2d
Add last modified file (gm) (#1093) 2021-12-02 13:46:57 +09:00
ath3 35c974c9c4
Implement "Goto last modification" command (#1067) 2021-11-15 00:11:53 +09:00
Cole Helbling b824e091a9
helix-term/commands: move SCRATCH_BUFFER_NAME to helix-view/document (#1091)
This way, the name is accessible everywhere `Document` and related types
are.
2021-11-13 13:15:41 +09:00
Ivan Tham 9d591427be
Fix earlier/later missing changeset update (#1069)
Fix #1059
2021-11-11 22:32:44 +09:00
Blaž Hrastnik 549cdee561 Refactor shebang detection to reuse the loaded buffer 2021-11-09 00:30:34 +09:00
ath3 77dbbc73f9
Detect filetype from shebang line (#1001) 2021-11-09 00:19:44 +09:00
Blaž Hrastnik e80708eba7 Make sure document diagnostics are sorted 2021-11-06 18:58:58 +09:00
Omnikar 51b4d35dce
Inform when reaching undo/redo bounds (#981)
* Inform when reaching undo/redo bounds

* `Already at oldest change` when undo fails
* `Already at newest change` when redo fails

* Add missing `the`
2021-11-05 10:20:06 +09:00
Kirawi cec0cfdaec
Uncomment mapping LSP diagnostics through changes (#925) 2021-10-29 10:11:30 +09:00
Blaž Hrastnik c1e5831b21 set_path: Pass in the function directly 2021-10-28 10:51:19 +09:00
Blaž Hrastnik 3e69a4852e Simplify set_path 2021-10-28 10:50:17 +09:00
Omnikar e2ed691537
Implement `hx --tutor` and `:tutor` to load `tutor.txt` (#898)
* Implement `hx --tutor` and `:tutor` to load `tutor.txt`

* Document `hx --tutor` and `:tutor`

* Change `Document::set_path` to take an `Option`

* `Document::set_path` accepts an `Option<&Path>` instead of `&Path`.
* Remove `Editor::open_tutor` and make tutor-open functionality use
  `Editor::open` and `Document::set_path`.

* Use `PathBuf::join`

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

* Add comments explaining unsetting tutor path

Co-authored-by: Ivan Tham <pickfire@riseup.net>
2021-10-28 10:23:46 +09:00
Blaž Hrastnik e36ad8b4ed minor: Further simplify take_with 2021-10-27 12:25:00 +09:00
Blaž Hrastnik 3edca7854e completion: fully revert state before apply & insertText common prefix 2021-10-25 11:09:09 +09:00
Blaž Hrastnik c913bade0a fix: Indentation used different default on `hx` vs `hx new_file.txt` 2021-10-24 17:20:30 +09:00
Blaž Hrastnik 0b1bc566e4 fix: lsp: Regression with textDocument/didSave not getting sent 2021-09-09 11:54:43 +09:00
Blaž Hrastnik 64099af3f1 Don't panic on save if language_server isn't initialized 2021-09-06 15:25:46 +09:00
Blaž Hrastnik 37606bad47 lsp: doc.language_server() is None until initialize completes 2021-09-06 15:25:46 +09:00
Blaž Hrastnik 10b690b5bd Drop some &mut bounds where & would have sufficed 2021-09-06 15:25:46 +09:00
Blaž Hrastnik 800d79b584 ls: Refactor textDocument/didSave in a similar vein 2021-09-06 15:25:46 +09:00
Blaž Hrastnik 184637c55a lsp: refactor format so we stop cloning the language_server 2021-09-06 15:25:46 +09:00
Blaž Hrastnik 57ed5180e0 lsp: Improve line ending handling when generating TextEdit 2021-09-06 11:00:33 +09:00
Brian Shu fa4caf7e3d remove unsafe 2021-08-27 09:50:57 +09:00
Kirawi b99db7c687
Move path util functions from helix-term to helix-core (#650) 2021-08-25 10:04:05 +09:00
Blaž Hrastnik 1d45f50781 fix: Don't internally use relative paths in the buffer picker
Fixes #619
2021-08-24 09:56:09 +09:00
Kirawi 16bf8e1e6b
Document more of document.rs (#562) 2021-08-18 09:59:10 +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
Blaž Hrastnik f0eb6ed96a Resolve a couple TODOs 2021-08-08 14:08:54 +09:00
Blaž Hrastnik 557c63033c fix: Map all selections on transaction.apply 2021-08-01 00:44:14 +09:00
Nathan Vegdahl f88d4c1e20 Move indent-style code into `helix_core::indent`. 2021-07-30 12:22:59 +09:00