kaarmu / typst.vim

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

sql.vim loaded before changing filetype to typst #19

Closed Chewt closed 5 months ago

Chewt commented 1 year ago

A bunch of mappings are added from sql.vim since it seem like that is loaded first before changing the filetype to typst. Here are a few of the mappings that are added:

i  <C-C>R      *@<C-\><C-O>:call sqlcomplete#Map("resetCache")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 532
i  <C-C>L      *@<C-Y><C-\><C-O>:call sqlcomplete#Map("column_csv")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 522
i  <C-C>l      *@<C-\><C-O>:call sqlcomplete#Map("column_csv")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 519
i  <C-C>c      *@<C-\><C-O>:call sqlcomplete#Map("column")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 518
i  <C-C>v      *@<C-\><C-O>:call sqlcomplete#Map("view")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 517
i  <C-C>p      *@<C-\><C-O>:call sqlcomplete#Map("procedure")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 516
i  <C-C>t      *@<C-\><C-O>:call sqlcomplete#Map("table")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 515
i  <C-C>s      *@<C-\><C-O>:call sqlcomplete#Map("sqlStatement\\w*")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 512
i  <C-C>T      *@<C-\><C-O>:call sqlcomplete#Map("sqlType\\w*")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 511
i  <C-C>o      *@<C-\><C-O>:call sqlcomplete#Map("sqlOption\\w*")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 510
i  <C-C>f      *@<C-\><C-O>:call sqlcomplete#Map("sqlFunction\\w*")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 509
i  <C-C>k      *@<C-\><C-O>:call sqlcomplete#Map("sqlKeyword\\w*")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 508
i  <C-C>a      *@<C-\><C-O>:call sqlcomplete#Map("syntax")<CR><C-X><C-O>
        Last set from /usr/share/nvim/runtime/ftplugin/sql.vim line 507

Personally I have a binding on <c-c> to <esc>, but with all of these other bindings, it doesn't immediately stop waiting for key commands after I type . This means that if I want to go into normal mode and then move up a line, using <c-c>k, instead of doing what I want it tries to run the command i <C-C>k *@<C-\><C-O>:call sqlcomplete#Map("sqlKeyword\\w*")<CR><C-X><C-O> from sql.vim

kaarmu commented 1 year ago

This is related to #16.

kaarmu commented 1 year ago

You can try this for now: https://stackoverflow.com/a/24931292

kaarmu commented 1 year ago

This should be fixed on normal Vim with f6497ee, I still get SQL loaded with neovim

Chewt commented 1 year ago

I'm running neovim, and it seems like f6497ee fixed the issue! I'm not sure why you are still getting SQL loaded, but I can confirm that it works on my end.

kaarmu commented 1 year ago

Okay, great! Then let's hope it's just my setup

Chewt commented 1 year ago

I'm not really sure why, but the issue has come back. I have tried to go back and use just the commit from when it worked, but it still isn't working. Did you ever get your setup to work with neovim?

kaarmu commented 1 year ago

Yea, I mainly use neovim. Check if it loads the plugin at all (e.g. see if it comes up after calling :scriptnames)

Chewt commented 1 year ago

after running :scriptnames I can confirm that the plugin is showing up. For example this line appears:

~/.config/nvim/plugged/typst.vim/ftdetect/typst.vim
kaarmu commented 1 year ago

And you are certain that typst.vim is updated? Could you include all of :scriptnames? Did you add another plugin since last time?

Chewt commented 1 year ago

I haven't added any plugins since last time

Here is the output from :scriptnames

  1: /usr/share/nvim/runtime/ftplugin.vim
  2: /usr/share/nvim/runtime/indent.vim
  3: /etc/xdg/nvim/sysinit.vim
  4: /usr/share/nvim/archlinux.vim
  5: ~/.dotfiles/neovim/.config/nvim/init.lua
  6: ~/.local/share/nvim/site/autoload/plug.vim
  7: /usr/share/nvim/runtime/filetype.lua
  8: ~/.dotfiles/neovim/.config/nvim/plugged/vimtex/ftdetect/cls.vim
  9: ~/.dotfiles/neovim/.config/nvim/plugged/vimtex/ftdetect/tex.vim
 10: ~/.dotfiles/neovim/.config/nvim/plugged/vimtex/ftdetect/tikz.vim
 11: ~/.dotfiles/neovim/.config/nvim/plugged/ultisnips/ftdetect/snippets.vim
 12: ~/.dotfiles/neovim/.config/nvim/plugged/typst.vim/ftdetect/typst.vim
 13: /usr/share/vim/vimfiles/ftdetect/PKGBUILD.vim
 14: /usr/share/vim/vimfiles/ftdetect/SRCINFO.vim
 15: /usr/share/vim/vimfiles/ftdetect/meson.vim
 16: /usr/share/nvim/runtime/syntax/syntax.vim
 17: /usr/share/nvim/runtime/syntax/synload.vim
 18: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/plugin/airline.vim
 19: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/init.vim
 20: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/parts.vim
 21: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/formatter/short_path.vim
 22: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/util.vim
 23: ~/.dotfiles/neovim/.config/nvim/plugged/vimtex/plugin/vimtex.vim
 24: ~/.dotfiles/neovim/.config/nvim/plugged/ultisnips/plugin/UltiSnips.vim
 25: ~/.dotfiles/neovim/.config/nvim/plugged/ultisnips/autoload/UltiSnips/map_keys.vim
 26: ~/.dotfiles/neovim/.config/nvim/plugged/vim-snippets/plugin/vimsnippets.vim
 27: /usr/share/nvim/runtime/plugin/gzip.vim
 28: /usr/share/nvim/runtime/plugin/health.vim
 29: /usr/share/nvim/runtime/plugin/matchit.vim
 30: /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
 31: /usr/share/nvim/runtime/plugin/matchparen.vim
 32: /usr/share/nvim/runtime/plugin/netrwPlugin.vim
 33: /usr/share/nvim/runtime/plugin/rplugin.vim
 34: /usr/share/nvim/runtime/plugin/shada.vim
 35: /usr/share/nvim/runtime/plugin/spellfile.vim
 36: /usr/share/nvim/runtime/plugin/tarPlugin.vim
 37: /usr/share/nvim/runtime/plugin/tohtml.vim
 38: /usr/share/nvim/runtime/plugin/tutor.vim
 39: /usr/share/nvim/runtime/plugin/zipPlugin.vim
 40: /usr/share/vim/vimfiles/plugin/fzf.vim
 41: ~/.dotfiles/neovim/.config/nvim/plugged/nvim-lspconfig/plugin/lspconfig.lua
 42: ~/.dotfiles/neovim/.config/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.lua
 43: /usr/share/nvim/runtime/plugin/editorconfig.lua
 44: /usr/share/nvim/runtime/plugin/man.lua
 45: /usr/share/nvim/runtime/plugin/nvim.lua
 46: ~/.dotfiles/neovim/.config/nvim/plugged/ultisnips/after/plugin/UltiSnips_after.vim
 47: ~/.dotfiles/neovim/.config/nvim/after/plugin/c.lua
 48: ~/.dotfiles/neovim/.config/nvim/after/plugin/color.lua
 49: ~/.dotfiles/neovim/.config/nvim/plugged/gruvbox/colors/gruvbox.vim
 50: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions.vim
 51: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/quickfix.vim
 52: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline.vim
 53: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/netrw.vim
 54: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/fzf.vim
 55: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/term.vim
 56: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/section.vim
 57: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/highlighter.vim
 58: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/nvimlsp.vim
 59: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/whitespace.vim
 60: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/po.vim
 61: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/wordcount.vim
 62: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/keymap.vim
 63: ~/.dotfiles/neovim/.config/nvim/plugged/vimtex/autoload/vimtex.vim
 64: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/vimtex.vim
 65: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/searchcount.vim
 66: ~/.dotfiles/neovim/.config/nvim/plugged/gruvbox/autoload/airline/themes/gruvbox.vim
 67: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/themes.vim
 68: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/builder.vim
 69: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/default.vim
 70: ~/.dotfiles/neovim/.config/nvim/after/plugin/lsp.lua
 71: ~/.dotfiles/neovim/.config/nvim/after/plugin/python.lua
 72: ~/.dotfiles/neovim/.config/nvim/after/plugin/tex.lua
 73: ~/.dotfiles/neovim/.config/nvim/after/plugin/treesitter.lua
 74: ~/.dotfiles/neovim/.config/nvim/after/plugin/ultisnips.lua
 75: /usr/share/nvim/runtime/ftplugin/sql.vim
 76: /usr/share/nvim/runtime/autoload/sqlcomplete.vim
 77: /usr/share/nvim/runtime/autoload/syntaxcomplete.vim
 78: /usr/share/nvim/runtime/indent/sql.vim
 79: /usr/share/nvim/runtime/indent/sqlanywhere.vim
 80: /usr/share/nvim/runtime/syntax/sql.vim
 81: /usr/share/nvim/runtime/syntax/sqloracle.vim
 82: ~/.dotfiles/neovim/.config/nvim/plugged/typst.vim/ftplugin/typst.vim
 83: ~/.dotfiles/neovim/.config/nvim/plugged/typst.vim/compiler/typst.vim
 84: ~/.dotfiles/neovim/.config/nvim/plugged/typst.vim/syntax/typst.vim
 85: /usr/share/nvim/runtime/autoload/provider/python3.vim
 86: /usr/share/nvim/runtime/autoload/provider/pythonx.vim
 87: /usr/share/nvim/runtime/autoload/remote/host.vim
 88: /usr/share/nvim/runtime/autoload/provider/ruby.vim
 89: /usr/share/nvim/runtime/ftoff.vim
 90: ~/.dotfiles/neovim/.config/nvim/plugged/ultisnips/autoload/UltiSnips.vim
 91: /usr/share/nvim/runtime/autoload/provider.vim
 92: /usr/share/nvim/runtime/ftplugin/vim.vim
 93: /usr/share/nvim/runtime/indent/vim.vim
 94: /usr/share/nvim/runtime/syntax/vim.vim
 95: /usr/share/nvim/runtime/syntax/lua.vim
 96: /usr/share/nvim/runtime/syntax/vim/generated.vim
 97: /usr/share/nvim/runtime/ftplugin/text.vim
 98: ~/.dotfiles/neovim/.config/nvim/plugged/vim-airline/autoload/airline/extensions/wordcount/formatters/default.vim
kaarmu commented 1 year ago

Hmm, okay. this is very strange and difficult to debug. I would guess that this is the behavior I've seen from the beginning. Something causes neovim, but not vim, to load SQL. Another way to see this is through nvim -Vdebug.txt main.typ and opening debug.txt.

I will try to look at it more in the next few days.

kaarmu commented 1 year ago

I just wanted to let you know that I've tried finding the cause for this a few times now. Still haven't found either the cause of the problem or a solution to it. Will continue looking...

Chewt commented 1 year ago

I'm going to look into this further, I've forked the repo and will probably submit a pull request when I've figured it out. So far it looks like the default sql.vim ftplugin uses some non-standard ways of detecting whether or not a ftplugin has been run instead of just respecting b:did_ftplugin like most other ftplugins.

kaarmu commented 1 year ago

Yes exactly. I just saw this on discord though, so maybe it's easiest to wait for upstream changes.

https://github.com/neovim/neovim/pull/23578

Chewt commented 1 year ago

Oh! Well that that pretty much fixes the issue. I eagerly await the release haha.

kaarmu commented 5 months ago

I don't know why it's taken so long for neovim to include this patch in a release, but since my distro's vim package has the patch I will close this issue. It is long overdue :smiley: