From bc9fb8e813ba2b60a0113051f068e9abff80245c Mon Sep 17 00:00:00 2001 From: AustinS <59460358+AuLaSW@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:46:40 -0600 Subject: [PATCH 1/7] Add CleanPath() to telekasten.lua The function CleanPath() cleans up the file paths for Windows users. Removes all content of the path up to the first `\\`, which should fix the issues related to Windows file paths. --- lua/telekasten.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index efad941..bbcf08d 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -23,10 +23,35 @@ local Path = require("plenary.path") -- declare locals for the nvim api stuff to avoid more lsp warnings local vim = vim +-- Cleans home path for Windows users +-- Needs to be before default config, else with no use config +-- home will not be cleaned and issues will still occur +local function CleanPath(path) + -- File path delimeter for Windows machines + local windows_delim = "\\" + -- Returns the path delimeter for the machine + -- '\\' for Windows, '/' for Unix + local system_delim = package.config:sub(1,1) + local new_path_start + + -- Removes portion of path before '\\' for Windows machines + -- since Telescope does not like that + if system_delim == windows_delim then + new_path_start = path:find(windows_delim) -- Find the first '\\' + if new_path_start ~= nil then + path = path:sub(new_path_start) -- Start path at the first '\\' + end + end + + -- Returns cleaned path + return path +end + -- ---------------------------------------------------------------------------- -- DEFAULT CONFIG -- ---------------------------------------------------------------------------- local home = vim.fn.expand("~/zettelkasten") +home = CleanPath(home) local M = {} M.Cfg = { @@ -2487,6 +2512,8 @@ local function Setup(cfg) -- merge everything but calendar opts -- they will be merged later if k ~= "calendar_opts" then + if k == "home" then + v = CleanPath(v) M.Cfg[k] = v if debug then print( From 6c468934c4b6151ad5a811452ac4671be1697e58 Mon Sep 17 00:00:00 2001 From: AustinS <59460358+AuLaSW@users.noreply.github.com> Date: Thu, 20 Jan 2022 14:55:01 -0600 Subject: [PATCH 2/7] Fix #70 Cleaned Windows Home Paths Added the function `CleanPath()` to clean up Windows paths for setting up home. Still some other issues (primarily with reading links) that need to be ironed out. --- lua/telekasten.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index bbcf08d..4ebc096 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -24,7 +24,7 @@ local Path = require("plenary.path") local vim = vim -- Cleans home path for Windows users --- Needs to be before default config, else with no use config +-- Needs to be before default config, else with no user config -- home will not be cleaned and issues will still occur local function CleanPath(path) -- File path delimeter for Windows machines From ef687a9739f2795d01bffedc7d48679e71bde800 Mon Sep 17 00:00:00 2001 From: AustinS <59460358+AuLaSW@users.noreply.github.com> Date: Thu, 20 Jan 2022 15:05:37 -0600 Subject: [PATCH 3/7] Update README.md Added notes about using `vim.fn.expand()` for the home directory working now for opening and browsing files. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 370cd45..ef0246d 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ To avoid the most common Windows issue: - Second best option: try WSL2 on Windows and pretend you're on Linux - if you **must** use Windows, use `/Users/myname/zettelkasten` instead of `~/zettelkasten` - **NEVER** use `C:\Users\myname` style paths +- Using `vim.fn.expand("~/zettelkasten")` should work now but mileage will vary with anything outside of finding and opening files ```lua lua << END @@ -215,6 +216,7 @@ local home = vim.fn.expand("~/zettelkasten") -- - try WSL2 on Windows and pretend you're on Linux -- - if you **must** use Windows, use "/Users/myname/zettelkasten" instead of "~/zettelkasten" -- - NEVER use "C:\Users\myname" style paths +-- - Using `vim.fn.expand("~/zettelkasten")` should work now but mileage will vary with anything outside of finding and opening files require('telekasten').setup({ home = home, @@ -331,6 +333,7 @@ END | | - try WSL2 on Windows and pretend you're on Linux | | | | - if you **must** use Windows, use `/Users/myname/zettelkasten` instead of `~/zettelkasten` | | | | - **NEVER** use `C:\Users\myname` style paths | | +| | - Using `vim.fn.expand("~/zettelkasten")` should work now but mileage will vary with anything outside of finding and opening files | | | **`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 | From e72adb40129a4e4600a45791e7e874bf585913ac Mon Sep 17 00:00:00 2001 From: "austin.swanlaw" Date: Sat, 22 Jan 2022 08:33:10 -0600 Subject: [PATCH 4/7] Fix function Seteup(cfg) Added `end` to the end of the if statement I added. --- lua/telekasten.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 4ebc096..7286113 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2514,6 +2514,7 @@ local function Setup(cfg) if k ~= "calendar_opts" then if k == "home" then v = CleanPath(v) + end M.Cfg[k] = v if debug then print( From 06e9eeaf055427ae878e53ef8563aefde970c911 Mon Sep 17 00:00:00 2001 From: "austin.swanlaw" Date: Sat, 22 Jan 2022 10:57:16 -0600 Subject: [PATCH 5/7] Update doc\telekasten.txt Included notes at both the beginning and under setup discussing the use of Windows directory paths. --- doc/telekasten.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/telekasten.txt b/doc/telekasten.txt index 65596d2..3a3a048 100644 --- a/doc/telekasten.txt +++ b/doc/telekasten.txt @@ -16,6 +16,10 @@ daily note (or cancel out and keep browsing your calendar). The daily note will be created if it doesn't exist. Days with daily notes get marked in the calendar. +For Windows users, many of the functions that require navigating file folders +do not work. This is due to how Telescope handles paths and the odd way that +Windows structures its paths. It is advised you don't use Windows. + To find out more: https://github.com/renerocksai/telekasten.nvim @@ -138,6 +142,20 @@ telekasten.setup({opts}) Default: '~/zettelkasten' + ---------------------- + Note to Windows users: + + If you must use Windows, avoid using the drive path. You may use it, + but telekasten will ignore the drive name and create your main markdown + / zettelkasten folder in the same drive that neovim executes from. This + is because of how Telescope handles files paths. Windows paths must be + stripped of the drive name or else the path will not be read correctly. + This is done automatically but is advised that you avoid adding it. + + It is recommended that if your path is not the default to write it + like a Unix path with '/' instead of '\', or to escape the '\' as '\\'. + ---------------------- + *telekasten.settings.take_over_my_home* take_over_my_home: ~ If set to `true`, telekasten.nvim will take over your home. Any notes From 28e0c6259defd25f446341d0bde99bc492605cdc Mon Sep 17 00:00:00 2001 From: AustinS <59460358+AuLaSW@users.noreply.github.com> Date: Wed, 26 Jan 2022 14:30:09 -0600 Subject: [PATCH 6/7] Update telekasten.lua Correct Stylua and Luacheck errors --- lua/telekasten.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 818f9fb..fffdedd 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -31,9 +31,9 @@ local function CleanPath(path) local windows_delim = "\\" -- Returns the path delimeter for the machine -- '\\' for Windows, '/' for Unix - local system_delim = package.config:sub(1,1) + local system_delim = package.config:sub(1, 1) local new_path_start - + -- Removes portion of path before '\\' for Windows machines -- since Telescope does not like that if system_delim == windows_delim then From f0e6914a7cfb8b367442f75b1eba66528f2c559d Mon Sep 17 00:00:00 2001 From: AustinS <59460358+AuLaSW@users.noreply.github.com> Date: Wed, 26 Jan 2022 14:31:36 -0600 Subject: [PATCH 7/7] Update telekasten.lua Fix stylua and luacheck errors --- lua/telekasten.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index fffdedd..f3c055a 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -42,7 +42,7 @@ local function CleanPath(path) path = path:sub(new_path_start) -- Start path at the first '\\' end end - + -- Returns cleaned path return path end