mirror of
https://github.com/helix-editor/helix.git
synced 2024-12-18 14:01:55 +04:00
Add config option for continue commenting (#12213)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
parent
2f74530328
commit
5005c14e99
@ -31,6 +31,7 @@ ### `[editor]` Section
|
|||||||
| `line-number` | Line number display: `absolute` simply shows each line's number, while `relative` shows the distance from the current line. When unfocused or in insert mode, `relative` will still show absolute line numbers | `absolute` |
|
| `line-number` | Line number display: `absolute` simply shows each line's number, while `relative` shows the distance from the current line. When unfocused or in insert mode, `relative` will still show absolute line numbers | `absolute` |
|
||||||
| `cursorline` | Highlight all lines with a cursor | `false` |
|
| `cursorline` | Highlight all lines with a cursor | `false` |
|
||||||
| `cursorcolumn` | Highlight all columns with a cursor | `false` |
|
| `cursorcolumn` | Highlight all columns with a cursor | `false` |
|
||||||
|
| `continue-comments` | if helix should automatically add a line comment token if you create a new line inside a comment. | `false` |
|
||||||
| `gutters` | Gutters to display: Available are `diagnostics` and `diff` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "spacer", "line-numbers", "spacer", "diff"]` |
|
| `gutters` | Gutters to display: Available are `diagnostics` and `diff` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "spacer", "line-numbers", "spacer", "diff"]` |
|
||||||
| `auto-completion` | Enable automatic pop up of auto-completion | `true` |
|
| `auto-completion` | Enable automatic pop up of auto-completion | `true` |
|
||||||
| `path-completion` | Enable filepath completion. Show files and directories if an existing path at the cursor was recognized, either absolute or relative to the current opened document or current working directory (if the buffer is not yet saved). Defaults to true. | `true` |
|
| `path-completion` | Enable filepath completion. Show files and directories if an existing path at the cursor was recognized, either absolute or relative to the current opened document or current working directory (if the buffer is not yet saved). Defaults to true. | `true` |
|
||||||
|
@ -3486,10 +3486,13 @@ fn open(cx: &mut Context, open: Open) {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let continue_comment_token = doc
|
let continue_comment_token = if doc.config.load().continue_comments {
|
||||||
.language_config()
|
doc.language_config()
|
||||||
.and_then(|config| config.comment_tokens.as_ref())
|
.and_then(|config| config.comment_tokens.as_ref())
|
||||||
.and_then(|tokens| comment::get_comment_token(text, tokens, cursor_line));
|
.and_then(|tokens| comment::get_comment_token(text, tokens, cursor_line))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let line = text.line(cursor_line);
|
let line = text.line(cursor_line);
|
||||||
let indent = match line.first_non_whitespace_char() {
|
let indent = match line.first_non_whitespace_char() {
|
||||||
@ -3965,10 +3968,13 @@ pub fn insert_newline(cx: &mut Context) {
|
|||||||
|
|
||||||
let mut new_text = String::new();
|
let mut new_text = String::new();
|
||||||
|
|
||||||
let continue_comment_token = doc
|
let continue_comment_token = if doc.config.load().continue_comments {
|
||||||
.language_config()
|
doc.language_config()
|
||||||
.and_then(|config| config.comment_tokens.as_ref())
|
.and_then(|config| config.comment_tokens.as_ref())
|
||||||
.and_then(|tokens| comment::get_comment_token(text, tokens, current_line));
|
.and_then(|tokens| comment::get_comment_token(text, tokens, current_line))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let (from, to, local_offs) = if let Some(idx) =
|
let (from, to, local_offs) = if let Some(idx) =
|
||||||
text.slice(line_start..pos).last_non_whitespace_char()
|
text.slice(line_start..pos).last_non_whitespace_char()
|
||||||
|
@ -304,6 +304,9 @@ pub struct Config {
|
|||||||
/// Whether to instruct the LSP to replace the entire word when applying a completion
|
/// Whether to instruct the LSP to replace the entire word when applying a completion
|
||||||
/// or to only insert new text
|
/// or to only insert new text
|
||||||
pub completion_replace: bool,
|
pub completion_replace: bool,
|
||||||
|
/// `true` if helix should automatically add a line comment token if you're currently in a comment
|
||||||
|
/// and press `enter`.
|
||||||
|
pub continue_comments: bool,
|
||||||
/// Whether to display infoboxes. Defaults to true.
|
/// Whether to display infoboxes. Defaults to true.
|
||||||
pub auto_info: bool,
|
pub auto_info: bool,
|
||||||
pub file_picker: FilePickerConfig,
|
pub file_picker: FilePickerConfig,
|
||||||
@ -985,6 +988,7 @@ fn default() -> Self {
|
|||||||
},
|
},
|
||||||
text_width: 80,
|
text_width: 80,
|
||||||
completion_replace: false,
|
completion_replace: false,
|
||||||
|
continue_comments: true,
|
||||||
workspace_lsp_roots: Vec::new(),
|
workspace_lsp_roots: Vec::new(),
|
||||||
default_line_ending: LineEndingConfig::default(),
|
default_line_ending: LineEndingConfig::default(),
|
||||||
insert_final_newline: true,
|
insert_final_newline: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user