kaarmu / typst.vim

Vim plugin for Typst
MIT License
282 stars 24 forks source link

Plugin installed, but commands not available #16

Closed wychwitch closed 1 year ago

wychwitch commented 1 year ago

Hello! This might be something obvious I'm doing wrong, but I installed the plugin and everything but :make does not work (it complains about lacking a makefile), and TypstWatch isn't available as a command for me.

I am on Arch Linux (WSL), using latest neovim with the kickstart.nvim dist

I use lazy.nvim so I have it loaded with the recommended code:

return {
  'kaarmu/typst.vim',
  ft = 'typ',
  lazy=false,
}

I doublechecked if it was actually installed and yea, lazy.nvim reports it as installed.

If there's any other information I can provide let me know! Again, I wouldn't be surprised if it was something small I'm overlooking. Thank you so much for this extension.

kaarmu commented 1 year ago

Have you checked which filetype neovim thinks you're opening, i.e. set ft?? I should have fixed this by detecting the file type in after (ed77f98); before doing this I could get filetype=sql instead of filetype=typst. If that's the case then the highlighting should also be messed up.

wychwitch commented 1 year ago

@kaarmu yep that was exactly it! It thinks it's an SQL file. I couldn't find an example of what the syntax highlighting was so I wasn't sure if it was incorrect or not.

I checked and it is up to date through lazy.nvim, however it turns out it's actually not being loaded for some reason! It's all the way at the bottom of the plugin list as the only item in the 'Not Loaded' category, I'm not sure why. Sorry about this, I'm still new to neovim!

kaarmu commented 1 year ago

Great! Then we know the problem. Sadly I'm not using/familiar with lazy.nvim so I cannot say much about fixing this problem. Just briefly looking through their README they say

When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically
loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers

about the lazy option. I guess you force lazy.nvim to load the plugin somehow.

wychwitch commented 1 year ago

Huh, that's so weird I have the Lazy option turned to false! I'll look into it a bit more and update when I find out anything else!

wychwitch commented 1 year ago

Okay some findings:

removing the ft and lazy sections from the lazy code now lets it correctly automatically load! However it's still being detected as SQL and not Typst. I'm not sure why? It's fully updated too. I'll keep looking into ways to override filetypes and get back to you!

wychwitch commented 1 year ago

Ok I figured it out! This may be more of a workaround than a full solution, but I just added this autocommand at the end of my init.lua:

vim.cmd 'autocmd BufNewFile,BufRead *.typ set filetype=typst'

After doing that, everything works perfectly!! Thank you

kaarmu commented 1 year ago

Great that you got it to work!

This is definitely a workaround. I will try to fix this properly soon since it seems to still be a problem.

kaarmu commented 1 year ago

I found why SQL was still being loaded in #19. Can you confirm that it works on your end as well? (Without the workaround)

wychwitch commented 1 year ago

Sorry I hadn't checked github in a bit! it does indeed work now without the workaround!! Thank you for your quick work