From a9102eaed7942ca5cf5de48806d00c375eebfb00 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Sat, 11 Dec 2021 00:32:12 +0100 Subject: [PATCH] telekasten, take over my home! --- README.md | 5 +++++ doc/telekasten.txt | 9 +++++++++ lua/telekasten.lua | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 7ca432e..55d3eb9 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ lua << END local home = vim.fn.expand("~/zettelkasten") require('telekasten').setup({ home = home, + + -- if true, telekasten will be enabled when opening a note within the configured home + take_over_my_home = true, + dailies = home .. '/' .. 'daily', weeklies = home .. '/' .. 'weekly', templates = home .. '/' .. 'templates', @@ -249,6 +253,7 @@ END | setting | description | example | | --- | --- | --- | | `home` | path to your zettelkasten folder (folder with markdown files) | ~/zettelkasten | +| **`take_over_my_home`** | if set to `true` (default), telekasten will take over your home. Any notes from the configured `home` directory will receive a `set filetype=telekasten`, no matter if opened by telekasten or another way. | true | | `dailies` | path where your daily notes go | ~/zettelkasten/daily | | `weeklies` | path where your weekly notes go | ~/zettelkasten/weekly | | `templates` | path where your note templates go | ~/zettelkasten/templates | diff --git a/doc/telekasten.txt b/doc/telekasten.txt index b93c6dd..cd8c325 100644 --- a/doc/telekasten.txt +++ b/doc/telekasten.txt @@ -127,6 +127,15 @@ telekasten.setup({opts}) Default: '~/zettelkasten' + *telekasten.settings.take_over_my_home* + take_over_my_home: ~ + If set to `true`, telekasten.nvim will take over your home. Any notes + from the configured `home` directory will receive a `set` + `filetype=telekasten`, no matter if opened by telekasten or another + way. + + Default: `true` + *telekasten.settings.daily* daily: ~ Path to your daily notes, to separate them from 'normal' notes. diff --git a/lua/telekasten.lua b/lua/telekasten.lua index efbddca..a714fb3 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -25,6 +25,10 @@ local M = {} M.Cfg = { home = home, + + -- if true, telekasten will be enabled when opening a note within the configured home + take_over_my_home = true, + dailies = home .. "/" .. "daily", weeklies = home .. "/" .. "weekly", templates = home .. "/" .. "templates", @@ -1591,6 +1595,10 @@ local function Setup(cfg) -- setting the syntax moved into plugin/telekasten.vim -- and does not work + if M.Cfg.take_over_my_home == true then + vim.cmd('au BufEnter ' .. M.Cfg.home .. '/*' .. M.Cfg.extension .. ' set ft=telekasten') + end + if debug then print("Resulting config:") print("-----------------")