Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance note creation with custom extensions and improved filefiltering #339

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ertwro
Copy link

@ertwro ertwro commented Aug 2, 2024

Proposed change

New feature.
Enhanced the note creation functionality to handle custom file extensions provided by the user in a single input prompt. This update allows users to specify the note title and desired file extension together. The change ensures that the global M.Cfg.extension is temporarily overridden to prevent appending an additional default extension during file creation. Additionally, support for filtering files in the vault based on multiple extensions has been added, allowing more flexible file type management.

Type of change

New feature

Added CreateNoteWithCustomExtension function to correctly handle custom file extensions provided by the user. The function now prompts the user to enter the note title with the desired extension in a single input. To avoid appending the globally defined extension, the global M.Cfg.extension is temporarily overridden during the file creation process.

Refactoring the custom extension handling function to support multiple extensions was challenging due to the extensive use of the global extension variable (M.Cfg.extension) across various inherited functions. This global dependency made it difficult to directly modify the extension handling without affecting core functionalities.

To enable file filtering in the vault based on multiple extensions, users can configure this by assigning a table with one or more file extensions in the configuration. Example:

    require("telekasten").setup({
      -- ... rest of the code
      extension = ".qmd",
      filter_extensions = { ".md", ".qmd", ".rmd", ".org", ".norg" },
      -- ... rest of the code
    )}

This enhancement addresses significant challenges due to existing dependencies on the global extension variable and improves file management within the vault.

While backlinks, file searching and creating new files works the gf doesn't follow the links for the default extension if it doesn't have an extension. E.g. [[test]] would work but [[test.md]] would

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Code quality improvements to existing code or addition of tests
  • Documentation update

Additional information

Checklist

  • I am running the latest version of the plugin.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • The code has been formatted using Stylua (a .stylua.toml file is provided)
  • The code has been checked with luacheck (a .luacheckrc file is provided)
  • The README.md has been updated according to this change.
  • The doc/telekasten.txt helpfile has been updated according to this change.

ertwro added 6 commits August 2, 2024 12:26
…filtering

Custom Extensions Handling: Modified the CreateNoteWithCustomExtension function to correctly handle custom file extensions provided by the user. The function now prompts the user to enter the note title with the desired extension in a single input. To avoid appending the globally defined extension, the global M.Cfg.extension is temporarily overridden during the file creation process.

Challenges: Refactoring the custom extension handling function to support multiple extensions was challenging due to the extensive use of the global extension variable (M.Cfg.extension) across various inherited functions. This global dependency made it difficult to directly modify the extension handling without affecting core functionalities.

File Filtering in Vault: Added support for filtering files in the vault based on multiple extensions. This can be configured by assigning a table with one or more file extensions in the configuration. Example:

lua
Copy code
filter_extensions = { ".qmd", ".md", ".rmd" }
This allows more flexible and comprehensive file type management within the vault.

Summary: These changes enhance the note creation process by allowing user-defined extensions and improve file management through configurable file filtering, addressing significant challenges due to existing dependencies on the global extension variable.
It explains how to filter multiple extensions and how to create a new note without using the default extension.
add the explanation for multiple filetypes in the vault
minor change to add extensions in the new filter_extensions variable
Restores the default <kbd>gf</kbd> expected behavior for markdown files
This allows multiple file extensions to be used in the backlinks, insert
links and file filtering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility of using more than one extension eg. {'.md', '.qmd'} [FR]
1 participant