1

For .js files, I set a particular filetype in order to enable snippets, like this:

augroup project
    autocmd!
    autocmd BufRead,BufNewFile *.js set filetype=javascript.javascript-es6-react.jsx
augroup END

Of course, I get the section_x that then reads all of the filetype. I wanted to set up sexction_x for *.js files to "js" or "javascript" only and added the following to the augroup:

au BufRead,BufNewFile *.js let g:airline_section_x='js'

and it kind of works. When I load the file via NERDTree, section_x stays the same, but when I switch from buffer to NERDTree and back to buffer, it then registers the new section_x and it works... but, airline doesn't do the 'normal' thing if I load any other filetype then. It stays 'js' throughout the vim session.

I am aware that I am most probably doing the stupid thing here, but I'm asking how should I do the right thing. How can I make this happen only for 'js' files and have it all work?

  • Not sure what you mean. Your second example is how it should be used. Perhaps NerdTree does something different? – Christian Brabandt Nov 1 '18 at 19:50
  • 1. Open vim 2. Open NERDTree 3. open file with NT and it switches to the buffer with that file, but section_x is of filetype 4. switch back and forth from NERDTree and it updates section_x to 'js'. WEIRD! Also, it seems once 'js' is picked up by airline, it stays on for all file types. – Keyframe Nov 1 '18 at 20:02
  • I suppose the autocommand is not triggered for whatever reason. I don't use Nerdtree, so cannot test. Well, if you set a global variable, it won't change if you load another buffer. So that is expected. – Christian Brabandt Nov 2 '18 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.