Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking filetype plugins seriously #271

Closed
clason opened this issue Aug 3, 2021 · 4 comments
Closed

Taking filetype plugins seriously #271

clason opened this issue Aug 3, 2021 · 4 comments

Comments

@clason
Copy link
Contributor

clason commented Aug 3, 2021

(I apologize for the cheeky title, but I couldn't resist...)

This was already touched on in #269 but I want to raise the issue separately to get more feedback on it.

Fundamentally, julia-vim is what is called a "filetype plugin" in that it adds support (syntax highlighting, indentation, etc.) for a file type that is not known to vim natively. This is very nice.

However, julia-vim also does something that filetype plugins usually don't, namely provide a "Latex2Unicode" function globally (i.e., for all filetypes). This is very unusual, and unwanted since it noticeably increases both startup time and the chance for conflicts unconditionally. To put it bluntly, This Is Not The Way in vimland.

So my first question is: Who is actually relying on/seriously using the L2U functionality in non-Julia (related) files? (Poll via thumbs up/down suffices.)

Second question: Would there be support for making this "global L2U" functionality opt-in (or at the very least opt-out)?

@carlobaldassi
Copy link
Contributor

I'm not sure how widespread is the use of the L2U functionality outside of julia files. I just know that I use it all the time.
See #33 for how this came up and why it's been done this way.
See also related issues #261 and #263.
As for the noticeable increase in startup time, as reported in #263, I measured 5 ms on my laptop.

@clason
Copy link
Contributor Author

clason commented Aug 3, 2021

Thank you; I missed that issue.

(Clearly everbody's priorities are different, but some people do care about 5ms, especially if they personally don't get anything out of it. Compared to other comparable plugins, 5ms is a lot.)

@clason
Copy link
Contributor Author

clason commented Aug 3, 2021

(And the issue would be much ameliorated if you gave permission to include the runtime files in upstream vim. I'd be happy to do the work, but cannot and will not without explicit permission.)

@clason
Copy link
Contributor Author

clason commented Aug 3, 2021

Since this has apparently been discussed before and was decided not to pursue, I'm closing this too. For the record (in case anyone stumbles on this) the following diff (which I'm using locally) makes julia-vim activate only on Julia files and reduces its startup time contribution (on non-.jl files) by 10x:

diff --git a/ftdetect/julia.vim b/ftdetect/julia.vim
index 9a4e8cb..d0cf578 100644
--- a/ftdetect/julia.vim
+++ b/ftdetect/julia.vim
@@ -7,20 +7,20 @@ endif
 
 autocmd BufRead,BufNewFile *.jl      set filetype=julia
 
-autocmd FileType *                   call LaTeXtoUnicode#Refresh()
-autocmd BufNew *                     call LaTeXtoUnicode#Refresh()
-autocmd BufEnter *                   call LaTeXtoUnicode#Refresh()
-autocmd CmdwinEnter *                call LaTeXtoUnicode#Refresh()
+autocmd FileType *.jl                call LaTeXtoUnicode#Refresh()
+autocmd BufNew *.jl                  call LaTeXtoUnicode#Refresh()
+autocmd BufEnter *.jl                call LaTeXtoUnicode#Refresh()
+autocmd CmdwinEnter *.jl             call LaTeXtoUnicode#Refresh()
 
 " This autocommand is used to postpone the first initialization of LaTeXtoUnicode as much as possible,
 " by calling LaTeXtoUnicode#SetTab and LaTeXtoUnicode#SetAutoSub only at InsertEnter or later
 function! s:L2UTrigger()
   augroup L2UInit
     autocmd!
-    autocmd InsertEnter *            let g:did_insert_enter = 1 | call LaTeXtoUnicode#Init(0)
+    autocmd InsertEnter *.jl         let g:did_insert_enter = 1 | call LaTeXtoUnicode#Init(0)
   augroup END
 endfunction
-autocmd BufEnter *                   call s:L2UTrigger()
+autocmd BufEnter *.jl                call s:L2UTrigger()
 
 function! s:HighlightJuliaMarkdown()
   if !exists('g:markdown_fenced_languages')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants