on master help sign in
minor: TODO comment cleanup
143cfe1Blaž Hrastnik
@@ -22,6 +22,8 @@
22- [ ] buffers should sit on editor.buffers, view simply refs them
22- [ ] buffers should sit on editor.buffers, view simply refs them
23- [ ] yank on delete
23- [ ] yank on delete
24
24
25+- [ ] load toml configs, themes, tabsize/identation
26+
25- [ ] draw separator line between views
27- [ ] draw separator line between views
26
28
27- [ ] lsp: signature help
29- [ ] lsp: signature help
helix-lsp/src/client.rs+6−16
@@ -192,7 +192,7 @@ impl Client {
192 text_document: Some(lsp::TextDocumentClientCapabilities {
192 text_document: Some(lsp::TextDocumentClientCapabilities {
193 completion: Some(lsp::CompletionClientCapabilities {
193 completion: Some(lsp::CompletionClientCapabilities {
194 completion_item: Some(lsp::CompletionItemCapability {
194 completion_item: Some(lsp::CompletionItemCapability {
195− snippet_support: Some(false), // TODO
195+ snippet_support: Some(false),
196 ..Default::default()
196 ..Default::default()
197 }),
197 }),
198 completion_item_kind: Some(lsp::CompletionItemKindCapability {
198 completion_item_kind: Some(lsp::CompletionItemKindCapability {
@@ -284,7 +284,6 @@ impl Client {
284 mut character,
284 mut character,
285 } = pos;
285 } = pos;
286
286
287− // TODO: there should be a better way here
288 for ch in text.chars() {
287 for ch in text.chars() {
289 if ch == '\n' {
288 if ch == '\n' {
290 line += 1;
289 line += 1;
@@ -299,8 +298,6 @@ impl Client {
299 let old_text = old_text.slice(..);
298 let old_text = old_text.slice(..);
300 let new_text = new_text.slice(..);
299 let new_text = new_text.slice(..);
301
300
302− // TODO: verify this function, specifically line num counting
303−
304 while let Some(change) = iter.next() {
301 while let Some(change) = iter.next() {
305 let len = match change {
302 let len = match change {
306 Delete(i) | Retain(i) => *i,
303 Delete(i) | Retain(i) => *i,
@@ -355,7 +352,6 @@ impl Client {
355 changes
352 changes
356 }
353 }
357
354
358− // TODO: trigger any time history.commit_revision happens
359 pub async fn text_document_did_change(
355 pub async fn text_document_did_change(
360 &self,
356 &self,
361 text_document: lsp::VersionedTextDocumentIdentifier,
357 text_document: lsp::VersionedTextDocumentIdentifier,
@@ -365,7 +361,7 @@ impl Client {
365 ) -> Result<()> {
361 ) -> Result<()> {
366 // figure out what kind of sync the server supports
362 // figure out what kind of sync the server supports
367
363
368− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
364+ let capabilities = self.capabilities.as_ref().unwrap();
369
365
370 let sync_capabilities = match capabilities.text_document_sync {
366 let sync_capabilities = match capabilities.text_document_sync {
371 Some(lsp::TextDocumentSyncCapability::Kind(kind)) => kind,
367 Some(lsp::TextDocumentSyncCapability::Kind(kind)) => kind,
@@ -384,7 +380,7 @@ impl Client {
384 range: None, //Some(Range)
380 range: None, //Some(Range)
385 range_length: None, // u64 apparently deprecated
381 range_length: None, // u64 apparently deprecated
386 text: "".to_string(),
382 text: "".to_string(),
387− }] // TODO: probably need old_state here too?
383+ }]
388 }
384 }
389 lsp::TextDocumentSyncKind::Incremental => {
385 lsp::TextDocumentSyncKind::Incremental => {
390 Self::changeset_to_changes(old_text, new_text, changes)
386 Self::changeset_to_changes(old_text, new_text, changes)
@@ -416,7 +412,7 @@ impl Client {
416 text_document: lsp::TextDocumentIdentifier,
412 text_document: lsp::TextDocumentIdentifier,
417 text: &Rope,
413 text: &Rope,
418 ) -> Result<()> {
414 ) -> Result<()> {
419− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
415+ let capabilities = self.capabilities.as_ref().unwrap();
420
416
421 let include_text = match &capabilities.text_document_sync {
417 let include_text = match &capabilities.text_document_sync {
422 Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
418 Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
@@ -446,8 +442,6 @@ impl Client {
446 text_document: lsp::TextDocumentIdentifier,
442 text_document: lsp::TextDocumentIdentifier,
447 position: lsp::Position,
443 position: lsp::Position,
448 ) -> Result<Vec<lsp::CompletionItem>> {
444 ) -> Result<Vec<lsp::CompletionItem>> {
449− // TODO: figure out what should happen when you complete with multiple cursors
450−
451 let params = lsp::CompletionParams {
445 let params = lsp::CompletionParams {
452 text_document_position: lsp::TextDocumentPositionParams {
446 text_document_position: lsp::TextDocumentPositionParams {
453 text_document,
447 text_document,
@@ -489,7 +483,6 @@ impl Client {
489 text_document,
483 text_document,
490 position,
484 position,
491 },
485 },
492− // TODO: support these tokens
493 work_done_progress_params: lsp::WorkDoneProgressParams {
486 work_done_progress_params: lsp::WorkDoneProgressParams {
494 work_done_token: None,
487 work_done_token: None,
495 },
488 },
@@ -514,7 +507,6 @@ impl Client {
514 text_document,
507 text_document,
515 position,
508 position,
516 },
509 },
517− // TODO: support these tokens
518 work_done_progress_params: lsp::WorkDoneProgressParams {
510 work_done_progress_params: lsp::WorkDoneProgressParams {
519 work_done_token: None,
511 work_done_token: None,
520 },
512 },
@@ -533,7 +525,7 @@ impl Client {
533 text_document: lsp::TextDocumentIdentifier,
525 text_document: lsp::TextDocumentIdentifier,
534 options: lsp::FormattingOptions,
526 options: lsp::FormattingOptions,
535 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
527 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
536− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
528+ let capabilities = self.capabilities.as_ref().unwrap();
537
529
538 // check if we're able to format
530 // check if we're able to format
539 let _capabilities = match capabilities.document_formatting_provider {
531 let _capabilities = match capabilities.document_formatting_provider {
@@ -547,7 +539,6 @@ impl Client {
547 let params = lsp::DocumentFormattingParams {
539 let params = lsp::DocumentFormattingParams {
548 text_document,
540 text_document,
549 options,
541 options,
550− // TODO: support these tokens
551 work_done_progress_params: lsp::WorkDoneProgressParams {
542 work_done_progress_params: lsp::WorkDoneProgressParams {
552 work_done_token: None,
543 work_done_token: None,
553 },
544 },
@@ -564,7 +555,7 @@ impl Client {
564 range: lsp::Range,
555 range: lsp::Range,
565 options: lsp::FormattingOptions,
556 options: lsp::FormattingOptions,
566 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
557 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
567− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
558+ let capabilities = self.capabilities.as_ref().unwrap();
568
559
569 // check if we're able to format
560 // check if we're able to format
570 let _capabilities = match capabilities.document_range_formatting_provider {
561 let _capabilities = match capabilities.document_range_formatting_provider {
@@ -579,7 +570,6 @@ impl Client {
579 text_document,
570 text_document,
580 range,
571 range,
581 options,
572 options,
582− // TODO: support these tokens
583 work_done_progress_params: lsp::WorkDoneProgressParams {
573 work_done_progress_params: lsp::WorkDoneProgressParams {
584 work_done_token: None,
574 work_done_token: None,
585 },
575 },
helix-term/src/application.rs−12
@@ -221,15 +221,3 @@ impl Application {
221 Ok(())
221 Ok(())
222 }
222 }
223}
223}
224−
225−// TODO: language configs:
226−// tabSize, fileExtension etc, mapping to tree sitter parser
227−// themes:
228−// map tree sitter highlights to color values
229−//
230−// TODO: expand highlight thing so we're able to render only viewport range
231−// TODO: async: maybe pre-cache scopes as empty so we render all graphemes initially as regular
232−////text until calc finishes
233−// TODO: scope matching: biggest union match? [string] & [html, string], [string, html] & [ string, html]
234−// can do this by sorting our theme matches based on array len (longest first) then stopping at the
235−// first rule that matches (rule.all(|scope| scopes.contains(scope)))
helix-term/src/commands.rs−13
@@ -460,19 +460,6 @@ pub fn select_regex(cx: &mut Context) {
460}
460}
461
461
462pub fn split_selection(cx: &mut Context) {
462pub fn split_selection(cx: &mut Context) {
463− // TODO: this needs to store initial selection state, revert on esc, confirm on enter
464− // needs to also call the callback function per input change, not just final time.
465− // could cheat and put it into completion_fn
466− //
467− // kakoune does it like this:
468− // # save state to register
469− // {
470− // # restore state from register
471− // # if event == abort, return early
472− // # add to history if enabled
473− // # update state
474− // }
475−
476 let prompt = ui::regex_prompt(cx, "split:".to_string(), |doc, regex| {
463 let prompt = ui::regex_prompt(cx, "split:".to_string(), |doc, regex| {
477 let text = doc.text().slice(..);
464 let text = doc.text().slice(..);
478 let selection = selection::split_on_matches(text, doc.selection(), &regex);
465 let selection = selection::split_on_matches(text, doc.selection(), &regex);
helix-term/src/compositor.rs−3
@@ -54,9 +54,6 @@ pub trait Component {
54 /// May be used by the parent component to compute the child area.
54 /// May be used by the parent component to compute the child area.
55 /// viewport is the maximum allowed area, and the child should stay within those bounds.
55 /// viewport is the maximum allowed area, and the child should stay within those bounds.
56 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
56 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
57− // TODO: the compositor should trigger this on push_layer too so that we can use it as an
58− // initializer there too.
59− //
60 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
57 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
61 // that way render can use it
58 // that way render can use it
62 None
59 None
helix-term/src/keymap.rs−1
@@ -90,7 +90,6 @@ use std::collections::HashMap;
90// #[cfg(feature = "term")]
90// #[cfg(feature = "term")]
91pub use crossterm::event::{KeyCode, KeyEvent as Key, KeyModifiers as Modifiers};
91pub use crossterm::event::{KeyCode, KeyEvent as Key, KeyModifiers as Modifiers};
92
92
93−// TODO: could be trie based
94pub type Keymap = HashMap<Key, Command>;
93pub type Keymap = HashMap<Key, Command>;
95pub type Keymaps = HashMap<Mode, Keymap>;
94pub type Keymaps = HashMap<Mode, Keymap>;
96
95
helix-term/src/ui/editor.rs+3−7
@@ -124,6 +124,9 @@ impl EditorView {
124
124
125 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
125 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
126
126
127+ // TODO: scope matching: biggest union match? [string] & [html, string], [string, html] & [ string, html]
128+ // can do this by sorting our theme matches based on array len (longest first) then stopping at the
129+ // first rule that matches (rule.all(|scope| scopes.contains(scope)))
127 let style = match spans.first() {
130 let style = match spans.first() {
128 Some(span) => theme.get(theme.scopes()[span.0].as_str()),
131 Some(span) => theme.get(theme.scopes()[span.0].as_str()),
129 None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
132 None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
@@ -138,8 +141,6 @@ impl EditorView {
138
141
139 // iterate over range char by char
142 // iterate over range char by char
140 for grapheme in RopeGraphemes::new(text) {
143 for grapheme in RopeGraphemes::new(text) {
141− // TODO: track current char_index
142−
143 if grapheme == "\n" {
144 if grapheme == "\n" {
144 visual_x = 0;
145 visual_x = 0;
145 line += 1;
146 line += 1;
@@ -433,9 +434,7 @@ impl Component for EditorView {
433 Event::Key(event) => {
434 Event::Key(event) => {
434 let view = cx.editor.view_mut();
435 let view = cx.editor.view_mut();
435
436
436− // TODO: sequences (`gg`)
437 let mode = view.doc.mode();
437 let mode = view.doc.mode();
438− // TODO: handle count other than 1
439 let mut cxt = commands::Context {
438 let mut cxt = commands::Context {
440 executor: cx.executor,
439 executor: cx.executor,
441 editor: &mut cx.editor,
440 editor: &mut cx.editor,
@@ -479,8 +478,6 @@ impl Component for EditorView {
479
478
480 if let Some(command) = self.keymap[&mode].get(&event) {
479 if let Some(command) = self.keymap[&mode].get(&event) {
481 command(&mut cxt);
480 command(&mut cxt);
482−
483− // TODO: simplistic ensure cursor in view for now
484 }
481 }
485 }
482 }
486 }
483 }
@@ -503,7 +500,6 @@ impl Component for EditorView {
503
500
504 fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
501 fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
505 for (view, is_focused) in cx.editor.tree.views() {
502 for (view, is_focused) in cx.editor.tree.views() {
506− // TODO: use parent area
507 self.render_view(view, view.area, surface, &cx.editor.theme, is_focused);
503 self.render_view(view, view.area, surface, &cx.editor.theme, is_focused);
508 }
504 }
509 }
505 }
helix-view/src/document.rs+1−3
@@ -255,8 +255,6 @@ impl Document {
255 return;
255 return;
256 }
256 }
257
257
258− // TODO: change -> change -> undo -> change -> change fails, probably old_state needs reset
259−
260 let new_changeset = ChangeSet::new(self.text());
258 let new_changeset = ChangeSet::new(self.text());
261 let changes = std::mem::replace(&mut self.changes, new_changeset);
259 let changes = std::mem::replace(&mut self.changes, new_changeset);
262 // Instead of doing this messy merge we could always commit, and based on transaction
260 // Instead of doing this messy merge we could always commit, and based on transaction
@@ -319,7 +317,7 @@ impl Document {
319 // self.state.doc.slice
317 // self.state.doc.slice
320 // }
318 // }
321
319
322− // TODO: transact(Fn) ?
320+ // transact(Fn) ?
323
321
324 // -- LSP methods
322 // -- LSP methods
325
323
helix-view/src/view.rs+3−6
@@ -13,15 +13,12 @@ use tui::layout::Rect;
13
13
14pub const PADDING: usize = 5;
14pub const PADDING: usize = 5;
15
15
16−// TODO: view should be View { doc: Document(state, history,..) }
17−// since we can have multiple views into the same file
18pub struct View {
16pub struct View {
19 pub id: Key,
17 pub id: Key,
20 pub doc: Document,
18 pub doc: Document,
21 pub first_line: usize,
19 pub first_line: usize,
22 pub area: Rect,
20 pub area: Rect,
23}
21}
24−// TODO: popups should be a thing on the view with a rect + text
25
22
26impl View {
23impl View {
27 pub fn new(doc: Document) -> Result<Self, Error> {
24 pub fn new(doc: Document) -> Result<Self, Error> {
@@ -54,9 +51,9 @@ impl View {
54 /// Calculates the last visible line on screen
51 /// Calculates the last visible line on screen
55 #[inline]
52 #[inline]
56 pub fn last_line(&self) -> usize {
53 pub fn last_line(&self) -> usize {
57− let viewport = Rect::new(6, 0, self.area.width, self.area.height.saturating_sub(1)); // - 1 for statusline
54+ let height = self.area.height.saturating_sub(1); // - 1 for statusline
58 std::cmp::min(
55 std::cmp::min(
59− self.first_line + (viewport.height as usize),
56+ self.first_line + height as usize,
60 self.doc.text().len_lines() - 1,
57 self.doc.text().len_lines() - 1,
61 )
58 )
62 }
59 }
@@ -67,7 +64,7 @@ impl View {
67 pub fn screen_coords_at_pos(&self, text: RopeSlice, pos: usize) -> Option<Position> {
64 pub fn screen_coords_at_pos(&self, text: RopeSlice, pos: usize) -> Option<Position> {
68 let line = text.char_to_line(pos);
65 let line = text.char_to_line(pos);
69
66
70− if line < self.first_line as usize || line > self.last_line() {
67+ if line < self.first_line || line > self.last_line() {
71 // Line is not visible on screen
68 // Line is not visible on screen
72 return None;
69 return None;
73 }
70 }