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

Refactor and type config.lua #335

Merged
merged 6 commits into from
Jun 28, 2024
Merged

Conversation

ujisati
Copy link

@ujisati ujisati commented Jun 17, 2024

Proposed change

Adds more type checking based on https://luals.github.io/wiki/ primarily to config.lua and refactors config.lua to have less unnecessary indirection. This should only modify config.lua internally. I tested by printing the config table that is returned from requiring config.lua and it looks correct, although I have a simple config, but it is merging the defaults with it still.

-- user config
{
  options = {
    home = "/home/ujisati/.notes",
    plug_into_calendar = false
  }
}

require"telekasten.config".debug()
-- returns
{
  auto_set_filetype = true,
  auto_set_syntax = true,
  calendar_opts = {
    calendar_mark = "left-fit",
    calendar_monday = 1,
    weeknm = 4
  },
  clipboard_program = "",
  close_after_yanking = false,
  command_palette_theme = "ivy",
  dailies = "/home/ujisati/.notes",
  dailies_create_nonexisting = true,
  enable_create_new = true,
  extension = ".md",
  filter_extensions = { ".md" },
  find_command = { "rg", "--files", "--sortr", "created" },
  follow_creates_nonexisting = true,
  home = "/home/ujisati/.notes",
  image_link_style = "markdown",
  insert_after_inserting = true,
  journal_auto_open = false,
  media_extensions = { ".png", ".jpg", ".bmp", ".gif", ".pdf", ".mp4", ".webm", ".webp" },
  media_previewer = "telescope-media-files",
  new_note_filename = "title",
  new_note_location = "smart",
  plug_into_calendar = false,
  rename_update_links = true,
  rg_pcre = false,
  show_tags_theme = "ivy",
  sort = "filename",
  subdirs_in_links = true,
  tag_notation = "#tag",
  take_over_my_home = true,
  template_handling = "smart",
  template_new_daily = "none",
  template_new_note = "none",
  template_new_weekly = "none",
  templates = "/home/ujisati/.notes",
  uuid_sep = "-",
  uuid_type = "%Y%m%d%H%M",
  weeklies = "/home/ujisati/.notes",
  weeklies_create_nonexisting = true
}

Let me know how useful ya'll think this kind of documentation is. Typing config.lua made it a lot easier to refactor, FWIW.

Type of change

  • 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.

ujisati added 2 commits June 16, 2024 15:54
@ujisati ujisati changed the base branch from main to refact June 17, 2024 02:20
@ujisati ujisati changed the title Refact Add more lua ls documentation, primarily to config.lua Jun 17, 2024
@ujisati ujisati changed the title Add more lua ls documentation, primarily to config.lua Refactor and type config.lua Jun 17, 2024
@TheTaoOfSu
Copy link

TheTaoOfSu commented Jun 17, 2024

Ah, nice, so there's some substantial overlap between LDoc/LuaDoc and language server support. If I was really forced to choose, I'd pick LS over documentation generation for a project of this size, so this is a welcome find in my eyes. I'm one of the newer contributors, though, so I don't feel well suited to say this is the right move, but I'd definitely agree with it from the little I've seen so far. The fact that it can also generate documentation is a nice perk, though. My main reason for adopting it after seeing it in your PRs was that it gives a clear and consistent comment style, so LS support and documentation generation are just really nice perks that I'd be happy to keep.

@lambtho12 lambtho12 merged commit 609aa7e into nvim-telekasten:refact Jun 28, 2024
2 checks passed
@lambtho12
Copy link
Member

Nice addition and sorry for the delay.

Totally agree with the documentation style. I hope more clarity in that regard will bring other new contributors.

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.

3 participants