fold-logging.nvim enhances the Neovim experience by automatically folding logging and debug-print statements while allowing for full compatibility with existing folding setups like Treesitter and LSP. Focus on writing code instead of managing folds, and customize your workflow with support for various languages and logging APIs.
fold-logging.nvim is a Neovim plugin designed to automatically manage the folding of logging and debug-print statements, streamlining the code review process without disrupting existing folding configurations, like Treesitter or LSP setups.
expr folds for functions, classes, and code blocks, integrating seamlessly with other systems.print(...) and pprint(...).Activating fold-logging.nvim is straightforward. Logging folds are automatically created and closed as files are opened, ensuring that developers face no distractions from logging statements. Manual control over folds can be achieved through various commands:
| Command | Action |
|---|---|
:FLFold | Close logging folds in the current buffer. |
:FLUnfold | Open logging folds in the current buffer. |
:FLToggle | Toggle logging folds in the current buffer. |
:FLRefresh | Recompute logging folds after edits. |
:FLList | Display detected calls in the quickfix window. |
:FLEnable | Re-enable functionality for open buffers. |
:FLDisable | Disable and revert to previous folding methods. |
fold-logging.nvim can be customized via options passed through opts (or using require("fold-logging").setup{}). Here are the default settings:
{
enable = true,
auto_fold = true,
fold_print = false,
min_lines = 2,
base_foldexpr = nil,
languages = {
python = {
call_node_types = { "call" },
patterns = {
"%.debug$",
"%.info$",
"%.warning$",
"%.warn$",
"%.error$",
"%.critical$",
"%.exception$",
"%.fatal$",
"%.log$",
},
print_patterns = {
"^print$",
"^pprint$",
},
},
},
}
Each option is designed to enhance the functionality:
enable: Master toggle for the plugin's operations.auto_fold: Enables automatic folding of logging statements on file open and when the file is saved.fold_print: Optionally includes basic print calls in folding behavior.min_lines: Sets the minimum line count a logging region must have to be folded.base_foldexpr: Custom folding expression that can be set if auto-detection is not desired.languages: Allows the addition of custom pattern specifications for logging across multiple languages.To support new languages, fold-logging.nvim can define folding behavior for various Neovim filetypes. Each specification includes callable types and patterns relevant to that language:
opts = {
languages = {
go = {
call_node_types = { "call_expression" },
patterns = { "^fmt%.Print", "^log%.", "%.Debug$", "%.Info$" },
},
},
}
This setup allows the plugin to fold logging statements as defined by the custom patterns. For further customization, utilize :InspectTree to determine the appropriate call node types for new languages.
No comments yet.
Sign in to be the first to comment.