nvim-telekasten / telekasten.nvim

A Neovim (lua) plugin for working with a markdown zettelkasten / wiki and mixing it with a journal, based on telescope.nvim
MIT License
1.42k stars 91 forks source link

Make filetype telekasten optional #49

Closed yigothu closed 2 years ago

yigothu commented 2 years ago

I would prefer if Telekasten didn’t automatically set files it creates to have filetype telekasten. This messes with my custom markdown treesitter implementation. Can it be made optional please?

renerocksai commented 2 years ago

I understand what you're asking here for. I can certainly make the filetype optional but then you would not get the syntax for tags and wiki links out-of-the-box. So I am asking myself: if you've managed to set up a custom markdown treesitter configuration, what stops you from duplicating the markdown stuff for the telekasten filetype? That way you would get both -- assuming your markdown stuff doesn't yet support syntax for tags and wiki links.

Edit: Forgot to add: the main reason for the telekasten filetype is so that it does not mess with arbitrary markdown files, e.g. syntax-wise. Instead markdown stays markdown and telekasten inherits the neovim markdown syntax and extends it into its own syntax. Maybe this helps with un-messing your treesitter config while we wait for the optional filetype.

renerocksai commented 2 years ago

set auto_set_filetype to false

yigothu commented 2 years ago

Thank you very much and sorry for the late reply.

kurotych commented 2 years ago

Hi guys, thank you again. It was a mess for me too. @renerocksai, @yigothu Is auto_set_filetype affect only syntax? Do I lose something except syntax support with this option? Thank you for your answer

lambtho12 commented 2 years ago

@kurotych, this could also possibly cause issues with auto-renaming files.

When you rename a file and update all links, telekasten will save automatically all open buffers with ft=telekasten to prevent issues. I did not test what would happen if the filetype is not telekasten when I implemented this feature.

FYI, the main idea behind setting a specific filetype for telekasten was to be able to differentiate telekasten notes from regular mardown (readmes, etc) so I could have specific snippets only for my zettelkasten. So far, the filetype is not a key part of the telekasten process/workflow. Although, it may be more integrated in the future.

kurotych commented 2 years ago

@lambtho12 Thank you for your answer! I'll be more careful with renaming my notes ;)

lambtho12 commented 2 years ago

@kurotych more info regarding the renaming issue:

When you rename a note, telekasten will run sed -i on all your telekasten folders to update the link with the new filename. If you have some notes with links to the renamed file that opened in other buffers, sed will update the links and you will lose you unsaved changes. This is why the default behavior is to always save open buffers. So it is not a super critical issue, but just something to bear in mind.

Now that I think of it, if you have auto_set_filetype=false, it could be a good idea to ask if you want to save all open buffers anyway (it will also save non-telekasten files if you have some). That way there is nothing to worry about. What do you think of that?

lambtho12 commented 2 years ago

@kurotych, you can now decide to save all modified buffers before renaming, even if you have auto_set_filetype==false (fixed in https://github.com/renerocksai/telekasten.nvim/commit/e0c7d296795ca3343869744517d4ad0a954e8513). So the filetype only impacts the syntax now and not any major feature of telekasten.

kurotych commented 2 years ago

@lambtho12 Great job! Thank you!

So the filetype only impacts the syntax now and not any major feature of telekasten.

I am very happy to hear that :)