mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Merge pull request #76 from AuLaSW/windows_file_path_clean
Windows file path clean
This commit is contained in:
@@ -208,6 +208,7 @@ To avoid the most common Windows issue:
|
|||||||
- Second best option: try WSL2 on Windows and pretend you're on Linux
|
- 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`
|
- if you **must** use Windows, use `/Users/myname/zettelkasten` instead of `~/zettelkasten`
|
||||||
- **NEVER** use `C:\Users\myname` style paths
|
- **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
|
||||||
lua << END
|
lua << END
|
||||||
@@ -217,6 +218,7 @@ local home = vim.fn.expand("~/zettelkasten")
|
|||||||
-- - try WSL2 on Windows and pretend you're on Linux
|
-- - try WSL2 on Windows and pretend you're on Linux
|
||||||
-- - if you **must** use Windows, use "/Users/myname/zettelkasten" instead of "~/zettelkasten"
|
-- - if you **must** use Windows, use "/Users/myname/zettelkasten" instead of "~/zettelkasten"
|
||||||
-- - NEVER use "C:\Users\myname" style paths
|
-- - 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({
|
require('telekasten').setup({
|
||||||
home = home,
|
home = home,
|
||||||
|
|
||||||
@@ -336,6 +338,7 @@ END
|
|||||||
| | - try WSL2 on Windows and pretend you're on Linux | |
|
| | - try WSL2 on Windows and pretend you're on Linux | |
|
||||||
| | - if you **must** use Windows, use `/Users/myname/zettelkasten` instead of `~/zettelkasten` | |
|
| | - if you **must** use Windows, use `/Users/myname/zettelkasten` instead of `~/zettelkasten` | |
|
||||||
| | - **NEVER** use `C:\Users\myname` style paths | |
|
| | - **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 |
|
| **`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 |
|
| `dailies` | path where your daily notes go | ~/zettelkasten/daily |
|
||||||
| `weeklies` | path where your weekly notes go | ~/zettelkasten/weekly |
|
| `weeklies` | path where your weekly notes go | ~/zettelkasten/weekly |
|
||||||
|
|||||||
@@ -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
|
will be created if it doesn't exist. Days with daily notes get marked in the
|
||||||
calendar.
|
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:
|
To find out more:
|
||||||
https://github.com/renerocksai/telekasten.nvim
|
https://github.com/renerocksai/telekasten.nvim
|
||||||
|
|
||||||
@@ -138,6 +142,20 @@ telekasten.setup({opts})
|
|||||||
|
|
||||||
Default: '~/zettelkasten'
|
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*
|
*telekasten.settings.take_over_my_home*
|
||||||
take_over_my_home: ~
|
take_over_my_home: ~
|
||||||
If set to `true`, telekasten.nvim will take over your home. Any notes
|
If set to `true`, telekasten.nvim will take over your home. Any notes
|
||||||
|
|||||||
@@ -23,10 +23,35 @@ local Path = require("plenary.path")
|
|||||||
-- declare locals for the nvim api stuff to avoid more lsp warnings
|
-- declare locals for the nvim api stuff to avoid more lsp warnings
|
||||||
local vim = vim
|
local vim = vim
|
||||||
|
|
||||||
|
-- Cleans home path for Windows users
|
||||||
|
-- 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
|
||||||
|
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
|
-- DEFAULT CONFIG
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
local home = vim.fn.expand("~/zettelkasten")
|
local home = vim.fn.expand("~/zettelkasten")
|
||||||
|
home = CleanPath(home)
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.Cfg = {
|
M.Cfg = {
|
||||||
@@ -2696,6 +2721,9 @@ local function Setup(cfg)
|
|||||||
-- merge everything but calendar opts
|
-- merge everything but calendar opts
|
||||||
-- they will be merged later
|
-- they will be merged later
|
||||||
if k ~= "calendar_opts" then
|
if k ~= "calendar_opts" then
|
||||||
|
if k == "home" then
|
||||||
|
v = CleanPath(v)
|
||||||
|
end
|
||||||
M.Cfg[k] = v
|
M.Cfg[k] = v
|
||||||
if debug then
|
if debug then
|
||||||
print(
|
print(
|
||||||
|
|||||||
Reference in New Issue
Block a user