Compare commits

...

12 Commits

Author SHA1 Message Date
Nik Revenco e3342e2a0f
Merge 94305a5a82 into 395a71bf53 2025-07-24 00:01:51 +02:00
Nikita Revenco 94305a5a82 style: remove accidentally added newlines 2025-02-01 14:31:25 +00:00
Nikita Revenco 9bf3262152 refactor: evaluate enable_diagnostics first 2024-12-09 15:55:43 +00:00
Nikita Revenco 4b5da9e667 fix: do not pass extra argument 2024-12-09 14:27:52 +00:00
Nikita Revenco 2b28ce94be fix: do not use a Cell for self.active 2024-12-09 14:23:59 +00:00
Nikita Revenco 069ca339a6 feat: complete implementation for toggle diagnostics option 2024-12-09 14:18:17 +00:00
Nikita Revenco be3dea5468 feat: attempt at getting config option to disable diagnostics working 2024-12-09 13:57:54 +00:00
Nikita Revenco 8271a35be2 feat: config option for toggling diagnostics 2024-12-09 04:45:28 +00:00
Nikita Revenco 08deeb48b8 chore: remove pointless comment 2024-12-08 13:47:00 +00:00
Nikita Revenco 1610118d13 docs: add toggle-diagnostic command info 2024-12-06 13:46:45 +00:00
Nikita Revenco a1a2cce23e feat: add `:toggle-diagnostics` command to hide diagnostics 2024-12-06 13:42:21 +00:00
Nikita Revenco 0dce39e0df feat: add command to toggle diagnostics does not work 2024-12-06 12:51:55 +00:00
4 changed files with 23 additions and 14 deletions

View File

@ -60,6 +60,7 @@
| `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` | | `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` |
| `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid` | `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid`
| `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"` | `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"`
| `enable-diagnostics` | Whether to show diagnostics, such as inline diagnostics and overlay diagnostics | `true` |
| `end-of-line-diagnostics` | Minimum severity of diagnostics to render at the end of the line. Set to `disable` to disable entirely. Refer to the setting about `inline-diagnostics` for more details | "disable" | `end-of-line-diagnostics` | Minimum severity of diagnostics to render at the end of the line. Set to `disable` to disable entirely. Refer to the setting about `inline-diagnostics` for more details | "disable"
| `clipboard-provider` | Which API to use for clipboard interaction. One of `pasteboard` (MacOS), `wayland`, `x-clip`, `x-sel`, `win-32-yank`, `termux`, `tmux`, `windows`, `termcode`, `none`, or a custom command set. | Platform and environment specific. | | `clipboard-provider` | Which API to use for clipboard interaction. One of `pasteboard` (MacOS), `wayland`, `x-clip`, `x-sel`, `win-32-yank`, `termux`, `tmux`, `windows`, `termcode`, `none`, or a custom command set. | Platform and environment specific. |
| `editor-config` | Whether to read settings from [EditorConfig](https://editorconfig.org) files | `true` | | `editor-config` | Whether to read settings from [EditorConfig](https://editorconfig.org) files | `true` |

View File

@ -171,12 +171,15 @@ impl EditorView {
primary_cursor, primary_cursor,
}); });
} }
let width = view.inner_width(doc);
let config = doc.config.load(); let config = doc.config.load();
if config.enable_diagnostics {
let width = view.inner_width(doc);
let enable_cursor_line = view let enable_cursor_line = view
.diagnostics_handler .diagnostics_handler
.show_cursorline_diagnostics(doc, view.id); .show_cursorline_diagnostics(doc, view.id);
let inline_diagnostic_config = config.inline_diagnostics.prepare(width, enable_cursor_line); let inline_diagnostic_config =
config.inline_diagnostics.prepare(width, enable_cursor_line);
decorations.add_decoration(InlineDiagnostics::new( decorations.add_decoration(InlineDiagnostics::new(
doc, doc,
theme, theme,
@ -184,6 +187,8 @@ impl EditorView {
inline_diagnostic_config, inline_diagnostic_config,
config.end_of_line_diagnostics, config.end_of_line_diagnostics,
)); ));
}
render_document( render_document(
surface, surface,
inner, inner,
@ -208,7 +213,8 @@ impl EditorView {
} }
} }
if config.inline_diagnostics.disabled() if config.enable_diagnostics
&& config.inline_diagnostics.disabled()
&& config.end_of_line_diagnostics == DiagnosticFilter::Disable && config.end_of_line_diagnostics == DiagnosticFilter::Disable
{ {
Self::render_diagnostics(doc, view, inner, surface, theme); Self::render_diagnostics(doc, view, inner, surface, theme);

View File

@ -371,6 +371,7 @@ pub struct Config {
deserialize_with = "deserialize_alphabet" deserialize_with = "deserialize_alphabet"
)] )]
pub jump_label_alphabet: Vec<char>, pub jump_label_alphabet: Vec<char>,
pub enable_diagnostics: bool,
/// Display diagnostic below the line they occur. /// Display diagnostic below the line they occur.
pub inline_diagnostics: InlineDiagnosticsConfig, pub inline_diagnostics: InlineDiagnosticsConfig,
pub end_of_line_diagnostics: DiagnosticFilter, pub end_of_line_diagnostics: DiagnosticFilter,
@ -1051,6 +1052,7 @@ impl Default for Config {
popup_border: PopupBorderConfig::None, popup_border: PopupBorderConfig::None,
indent_heuristic: IndentationHeuristic::default(), indent_heuristic: IndentationHeuristic::default(),
jump_label_alphabet: ('a'..='z').collect(), jump_label_alphabet: ('a'..='z').collect(),
enable_diagnostics: true,
inline_diagnostics: InlineDiagnosticsConfig::default(), inline_diagnostics: InlineDiagnosticsConfig::default(),
end_of_line_diagnostics: DiagnosticFilter::Disable, end_of_line_diagnostics: DiagnosticFilter::Disable,
clipboard_provider: ClipboardProvider::default(), clipboard_provider: ClipboardProvider::default(),

View File

@ -105,7 +105,7 @@ impl DiagnosticsHandler {
.store(self.generation.get(), atomic::Ordering::Relaxed); .store(self.generation.get(), atomic::Ordering::Relaxed);
} }
pub fn show_cursorline_diagnostics(&self, doc: &Document, view: ViewId) -> bool { pub fn show_cursorline_diagnostics(&self, doc: &Document, view: ViewId) -> bool {
if !self.active { if !self.active || !doc.config.load().enable_diagnostics {
return false; return false;
} }
let cursor_line = doc let cursor_line = doc