Closed wakatara closed 2 years ago
Did you try not using the variable at all in the config? i.e.
{
"renerocksai/telekasten.nvim",
after = "telescope.nvim",
config = function()
-- this is the line that's problematic, it seems...
require('telekasten').setup({
home = vim.fn.expand("~/Documents/tk"), -- have also tried just setting this to the directories directly and removing local home above
take_over_my_home = true,
auto_set_filetype = true,
-- dir names for special notes (absolute path or subdir name)
dailies = vim.fn.expand("~/Documents/tk") .. '/' .. 'dailies',
weeklies = vim.fn.expand("~/Documents/tk") .. '/' .. 'weeklies',
templates = vim.fn.expand("~/Documents/tk") .. '/' .. 'templates',
-- image (sub)dir for pasting
image_subdir = "img",
-- markdown file extension
extension = ".md",
-- following a link to a non-existing note will create it
follow_creates_nonexisting = true,
dailies_create_nonexisting = true,
weeklies_create_nonexisting = true,
-- template for new notes (new_note, follow_link)
template_new_note = vim.fn.expand("~/Documents/tk") .. '/' .. 'templates/new_note.md',
template_new_daily = vim.fn.expand("~/Documents/tk") .. '/' .. 'templates/daily.md',
template_new_weekly= vim.fn.expand("~/Documents/tk") .. '/' .. 'templates/weekly.md',
-- image link style, wiki:v![[image name]], markdown: ![](image_subdir/xxxxx.png)
image_link_style = "markdown",
-- integrate with calendar-vim
plug_into_calendar = true,
calendar_opts = {
-- calendar week display mode: 1 .. 'WK01', 2 .. 'WK 1', 3 .. 'KW01', 4 .. 'KW 1', 5 .. '1'
weeknm = 2,
-- use monday as first day of week: 1 .. true, 0 .. false
calendar_monday = 4,
-- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
calendar_mark = 'left-fit',
},
-- telescope actions behavior
close_after_yanking = false,
insert_after_inserting = true,
-- tag notation: '#tag', ':tag:', 'yaml-bare'
tag_notation = "#tag",
command_palette_theme = "dropdown",
show_tags_theme = "dropdown",
subdirs_in_links = false,
template_handling = "smart",
new_note_location = "smart",
-- should all links be updated when a file is renamed
rename_update_links = true,
})
end,
}
Or maybe replace vim.fn.expand("~/Documents/tk")
directly with "~/Documents/tk"
. That way we could be sure if it is indeed the variable that causes the issue.
Heya @lambtho12
Yes, tried just hardcoding the directory and it still asks if I want to create a ~/zettelkasten
directory since it can't find the one I've specified (the issue here being I already have notes under ~/Documents/tk
I want it to use that I've migrated.
lemme check what happens if I just let it start using the zettelkasten directory it creates to help diagnose. The issue definitely seems to be with passing the variables in the setup though.
NVChad does use a chadrc.lua
file under custom to interact with its api so the telekasten plugin setup is in a file wrapped in return { ... }
in init.lua under the directory custom/plugins
. My chadrc.lua is below in case it makes sense somehow that part of the setup to get the home directory initialized by telekasten needs to be there.
(NVCHad is pretty nifty actually, though as everything is lua it's a slight jump from classic vim configuration.
-- /lua/custom/chadrc.lua
local M = {}
local userPlugins = require "custom.plugins" -- path to table
M.plugins = {
install = userPlugins,
}
M.ui = {
theme = "catppuccin",
}
return M
Not sure if that helps of gives clues. If not, I'll let the plugin create the suggested ~/zettelkasten
directory and move files over to that to see if the rest of the config variables like ~/z/dailies
and such are read. My guess is that only the defaults in the plugin will be picked up though.
Hey @lambtho12
Hardcoded in the directories as suggested, though sadly that did not work (and those directories exist already and work with a vanilla neovim installation as per the Installation guide on telekasten github repo. Quite stumped actually. Perhaps this is something to do with packer itself? (I don't think it's NVChad though it does have an API for these sorts of things - nice project btw, check it out.).
thanks again for taking a boo at this. Any ideas as to how I might diagnose the problem? Kinda stumped now I've thrashed round with various config options.
So, considering that:
I would tend to think that the issue is somewhere with NVChad. It seems to be importing the default config AFTER loading the custom one and thus erasing it (or not loading the custom config at all). Maybe this is due to a wrong configuration no your side.
To verify that this is the case, try changing an other option such as command_palette_theme = "dropdown",
. If this is not changed either, we can be sure that the config is not loaded at all (or erased at some point). You could also just put a print statement in the config
{
"renerocksai/telekasten.nvim",
after = "telescope.nvim",
config = function()
print('Test to see if this pass')
require('telekasten').setup({
...
})
end,
}
This should print something at the bottom of the command bar in neovim.
I do not think Packer has anything to do here. AFAIK, it is just a plugin manager. Its role is to sync the git repos of each plugins and install them somewhere neovim will find them.
I just had a look on how to setup NVChad. Would it be possible to have a peek at your full NVChad config and full telekasten config? Especially plugins/init.lua
and plugins/configs/telekasten.lua
if it exist. I think that the most probable cause is an issue with the way you put the TK config in NVChad.
@lambtho12
Mystery solved. I messed around some more with this here on Good Friday, and the key problem appears to be that you need to use the directive requires
rather than after
.
I have to admit, as someone new to using Packer (big plug fan myself), I find the use of Packer's requires, wants, and after to be highly confusing. :-/
Anyway. Solved! Woo!
Would you guys like me to fork the code and update the documentation here so there's an example for for vanilla packer config (I also have working with the nvim kickstart template) and specifically for NVChad?
lemme know!
Glad you sorted it out!
Regarding forking and updating the doc, I do not think this is required. I have started a complete revamp of the doc using the wiki a while ago. This still has to be merged here at some point.
Thanks for proposing it though!
Please confirm
Describe the bug
NVChad custom plugins under lua and Packer appear to not be able to have variables working in config (or I'm doing something very wrong) via a
local home = vim.fn.expand("~/custom_dir")
call preventing usage. Should this be set another way in theconfig = function()
under NVchad (the lua works fine in vanilla neovim as alua << EOF ... EOF
directive.)?Basically, I am unable to set a home directory. It works fine in vanilla neovim where I am using Plug. I have all other custom plugins working in NVChad under
/lua/custom/
.To Reproduce
I have the following block in my
lua/custom/plugins/init.lua
- all other plugins in the block work fine (and plugin in installed).Note: I am also unable to manually change the directory to
home = "~/Documents/tk"
in the block and have it work either. Telekasten keeps asking if it can create the~/zettelkasten
directory for me.Expected behavior
I would expect the telekasten plugin to pick up the home variable and incorporate it into the settings, so it can both find and create files for my zk system. Instead it keeps claiming no directory is configured/exists and offers to create
~/zettelkasten
.(I should also point out I've removed the
local home = vim.fn.expand("~/Documents/tk")
and simply replaced thehome = home
withhome = "~/Documents/tk"
andhome = "/Users/me/Documents/tl"
but get the same error message.Basically, how do you get variables inside a custom config block in NVChad?
Screenshots nopes
Desktop (please complete the following information):
Additional context
Lua is a pretty new language to me, as is packer but happy to help try and resolve this issue. I also filed this with the NVChad repo but they pointed back at this most likely being an issue with telekasten (due to your note on setting the windows directory and
vim.fn.expand
being a thing.