sile-typesetter / vim-sile

A filetype plugin for SILE’s TeX-like input format providing syntax highlighting and other goodies compatible with Vim and Neovim.
8 stars 1 forks source link

Doesn't work without `:setf sile` #4

Closed ctrlcctrlv closed 2 years ago

ctrlcctrlv commented 3 years ago

I could very well be stupid, but after trying to install this both the traditional way in ~/.vim and via Vundle.vim (Plugin 'sile-typesetter/vim-sile') I can't get it to work.

I always have to do :setf sile.

On Arch there was a file called sil.vim already, /usr/share/vim/vim82/syntax/sil.vim, which seems to implement some Apple :hankey: I don't use. I moved it out of the way but problem persists.

What else can I do

alerque commented 3 years ago

Bizarrely sile file type detection stopped working for me sometime a week or two ago. Neither NeoVim nor this plugin had any related updates in the same window so I don't know what the deal is. I hadn't see the VIM addition of sil.vim, but that could be part of the issue. I'll look into this when I get a chance (currently in earthquake recovery mode).

ctrlcctrlv commented 2 years ago

I'm really stupid because I only figured out how to fix his today, more than one year later.

$HOME/.vimrc

autocmd BufRead *.sil set syntax=sile

sigh

alerque commented 2 years ago

Don't feel too stupid, that should absolutely not be necessary. You having to do that manually means something is messed up—this plugin should be using the ftdetect mechanism to inject that on its own.

By the way I don't know what my 2020 comment was about because this has been working for me again and I hence I forgot about the issue. I‌ do not have that hack to load it manually, the ftdetect is working for me. I'd be happy to fix it so it works for you too but I don't know what's wrong.

Are you using VIM or‌ NeoVIM?

ctrlcctrlv commented 2 years ago

regular vim :)

alerque commented 2 years ago

Any chance you could tinker with your local plugin, specifically the ftdetect/sile.vim file and drop the VimSile aurgroup and just use a bare autocmd? I ran across some code in another plugins that suggests VIM has an issue with that (technically correct) usage. Or at least some chap thought it did.

ctrlcctrlv commented 2 years ago

@alerque It does not work to make it bare, as…

diff --git a/tmp/sile.vim b/.vim/bundle/vim-sile/ftdetect/sile.vim
index 248f57a..61642a0 100644
--- a/tmp/sile.vim
+++ b/.vim/bundle/vim-sile/ftdetect/sile.vim
@@ -1,8 +1,4 @@
-augroup VimSile
-    autocmd!
-augroup END
-
-autocmd VimSile BufNewFile,BufRead *.sil
+autocmd BufNewFile,BufRead *.sil
             \ if &ft =~# '^\%(conf\|modula2\)$' |
             \   set ft=sile |
             \ else |

(To cover all bases, also tried to leave augroup block intact.)

But it does work, starting from there, to write autocmd!:

diff --git a/tmp/sile.vim b/.vim/bundle/vim-sile/ftdetect/sile.vim
index 8978bad..61642a0 100644
--- a/tmp/sile.vim
+++ b/.vim/bundle/vim-sile/ftdetect/sile.vim
@@ -1,4 +1,4 @@
-autocmd BufNewFile,BufRead *.sil
+autocmd! BufNewFile,BufRead *.sil
             \ if &ft =~# '^\%(conf\|modula2\)$' |
             \   set ft=sile |
             \ else |

So, I can say that you were close—dropping augroup needed, but autocmd! ! still needed.

alerque commented 2 years ago

Interesting. This does not jive with docs or linters but does jive with pretty widespread usage.

What about this variant?

diff --git a/ftdetect/sile.vim b/ftdetect/sile.vim
index 248f57a..3f31ea5 100644
--- a/ftdetect/sile.vim
+++ b/ftdetect/sile.vim
@@ -1,12 +1,11 @@
 augroup VimSile
     autocmd!
+    autocmd BufNewFile,BufRead *.sil
+                \ if &ft =~# '^\%(conf\|modula2\)$' |
+                \   set ft=sile |
+                \ else |
+                \   setf sile |
+                \ endif
 augroup END

-autocmd VimSile BufNewFile,BufRead *.sil
-            \ if &ft =~# '^\%(conf\|modula2\)$' |
-            \   set ft=sile |
-            \ else |
-            \   setf sile |
-            \ endif
-
 " vim: set fdm=marker et ts=4 sw=4 sts=4:
alerque commented 2 years ago

Never mind. I should have started with the official docs: :help ftdetect. The issue is that VIM wraps these in an augroup automatically and nested groups are finicky. I'll clean this up.

ctrlcctrlv commented 2 years ago

Um, you didn't actually fix this in #6 @alerque.

Against master, I still need a patch.

diff --git a/ftdetect/sile.vim b/ftdetect/sile.vim
index 0791991..268afb4 100644
--- a/ftdetect/sile.vim
+++ b/ftdetect/sile.vim
@@ -1,5 +1,5 @@
 " vint: -ProhibitAutocmdWithNoGroup
-autocmd BufNewFile,BufRead *.sil
+autocmd! BufNewFile,BufRead *.sil
                        \ if &ft =~# '^\%(conf\|modula2\)$' |
                        \   set ft=sile |
                        \ else |
ctrlcctrlv commented 2 years ago

I have no idea what are all the new vim's the cool kids are playing with, I still use vim the same way I did a decade ago. Works for me (until it doesn't).

$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 16 2022 12:09:56)
Included patches: 1-4106
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       +tcl/dyn
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.34/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto -L/usr/local/lib -o vim -lm -ltinfo -lelf -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.34/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.34/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm