source ~/.vimrc working in file but not automatically source coffee - ruby-on-rails-3

I have added the coffee syntax and indent plugin for vim. Here is my ~/.vimrc:
colorscheme peachpuff
syntax on
filetype on
source /Users/(myusername)/.vim/vim-coffee-script-master/indent/coffee.vim
source /Users/(myusername)/.vim/vim-coffee-script-master/syntax/coffee.vim
au BufNewFile,BufRead *.js set filetype=javascript
au BufNewFile,BufRead *.coffee set filetype=coffee
au BufNewFile,BufRead *.rake set filetype=ruby
au BufNewFile,BufRead *.rb set filetype=ruby
au BufNewFile,BufRead Gemfile set filetype=ruby
au BufNewFile,BufRead Guardfile set filetype=ruby
au BufNewFile,BufRead *.less set filetype=scss
set autoindent
set expandtab
set softtabstop=2
set shiftwidth=2
This doesn't have the syntax highlighting when I open a .coffee file. I then run :so ~/.vimrc while I am in the file and the syntax highlighting appears. Also, when I split the screen and run :so ~/.vimrc in one window it disappears in the other. Any ideas?

The .vimrc file is for global settings. By sourcing coffee-specific scripts in there, you only temporarily apply them to the bare Vim during startup; any files you open aren't affected by it.
Instead, Vim has an elaborate mechanism for detecting various types of programming languages and other file types; cp. :help filetypes. Syntax files should be placed into ~/.vim/syntax/ and indents into ~/.vim/indent/. Then, once you :setf coffee (or if there is a detection defined for *.coffee), it'll all be automatically activated.

Related

Run code formatter from the command line with PhpStorm open

If I go to my PhpStorm\bin folder I can run the format.bat command to format files from the command line e.g.
phpstorm format -r C:\path\to\my\code -r -s c:\path\to\my\settings.xml
and that works great. However I cannot run the command if PhpStorm is open, I get an error:
Only one instance of PhpStorm can be run at a time
Not ideal to have to close my IDE or have to use a 3rd party code formatter. Is there any workaround? Without installing another copy of PhpStorm.
It's a known issue, please see: https://youtrack.jetbrains.com/issue/IDEA-160462
The link from y.bedrov led me to here https://confluence.jetbrains.com/display/IDEADEV/Command-Line+Source+Code+Formatter with a potential solution.
Unfortunately I don't seem to be able to get it to work, I had to resort to copying my PhpStorm directory and using the copy instead. But I add it here in hopes that it helps others
Running Command-Line Formatter when the IDE is Running
On Linux/MacOS
Go to /bin directory where is a directory where Intellij IDEA or Intellij IDEA-based product is installed.
Copy idea.properties to some other file, for example, format.properties
Modify format.properties as follows:
Uncomment the lines:
# idea.config.path=${user.home}/.IntelliJIdea/config
# idea.system.path=${user.home}/.IntelliJIdea/system
Change them to point to some directories which differ from defaults, for example:
idea.config.path=${user.home}/.IntelliJIdea/format/config
idea.system.path=${user.home}/.IntelliJIdea/format/system
Modify format.sh by adding the line with IDEA_PROPERTIES variable:
\#!/bin/sh
\# ------------------------------------------------------
\# IntelliJ IDEA formatting script.
\# ------------------------------------------------------
IDE_BIN_HOME="${0%/*}"
export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
exec "$IDE_BIN_HOME/idea.sh" format "$#"
Run format.sh without closing the IDE, it should give the following output:
IntelliJ IDEA ..., build ... Formatter
Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
-h|-help Show a help message and exit.
-s|-settings A path to Intellij IDEA code style settings .xml file.
-r|-R Scan directories recursively.
-m|-mask A comma-separated list of file masks.
path.. A path to a file or a directory.
On Windows
You have to create a separate format.properties file as described above for Linux/MacOS.
Change format.bat file by adding a line with IDEA_PROPERTIES variable as follows:
#ECHO OFF
::----------------------------------------------------------------------
:: IntelliJ IDEA formatting script.
::----------------------------------------------------------------------
SET IDE_BIN_DIR=%~dp0
SET IDEA_PROPERTIES=%IDE_BIN_DIR%\format.properties
CALL "%IDE_BIN_DIR%\idea.bat" format %*
Run format.bat, it will list the command-line formatter options.
This guide works for me. But ensure use PHPSTORM_PROPERTIES instead of IDEA_PROPERTIES when export environment variable as described in the article:
export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
And what's more, from version 2022.1, IntelliJ IDEA supports dry run which is very useful for format validation based pre-commit git hook.

Jetbrains - Include ignored files when committing

I'm working on quite a large modular project in Webstorm. The js code is compiled with Babel to ./dist folder, so are the assets like html templates and other files.
I would like to EXCLUDE ./dist since when I do a global search of "Navigate to Symbol/Class/etc", I don't want results from ./dist to be shown, so I mark the ./dist folder as excluded.
BUT due to the workflow and the modularity (projects are modules loaded with jspm), I need to commit changed ./dist into VCS (Git). This is our workflow and I can't do anything about that.
The problem:
When I click "Commit changes" I don't see the newly changed files in ./dist when I exclude this folder. Clicking on "Refresh changes" doesn't help.
Can I solve this issue somehow?
UPD
The ./dist directory is NOT in .gitignore
You shouldn't exclude this directory from vcs, if you want or need to have it under version control. But for setting the directory, where IDE shouldn't search, you should set up IDE.
You have to remove your directory from git ignore or what ever, and set up ContentRoot in your IDE. I'm using PhpStorm and IntelijIdea, but the settings are common for all JetBrains Products.
Here is the part of JetBrains instruction :
To have files or folders excluded by name
1. Do one of the following: – Open the Settings dialog box, and click Deployment, then click Options below the Deployment node .
– Choose Tools | Deployment | Options on the main menu.
2. In the Options dialog box that opens, specify the patterns that define the names of these files and folders in the Exclude items by name text box. Use semicolons as delimiters. Wildcards are welcome.
The exclusion is applied recursively. This means that if a matching folder has subfolders, the contents of these subfolders are not deployed either.
So , you can read this : exclude files and restore the settings, and after that, use the next link, to set up the root directory.
Here is the instruction from JetBrains : JetBrains-Content Root

How to remove custom vim syntax and filetype settings for a specific

I somehow botched the default syntax highlighting and filetype recognition for my apache httpd-vhosts.conf file, such that every time I open it in vim, the syntax and filetype are both set to "conf". All of the other files in the ../conf.d/ directory are recognized properly, i.e. as syntax and filetype both set to "apache". I've tried the following:
manually setting both in vim, i.e.
:set syntax=apache, :set filteype=apache
This works for the session, but they both reset back to "conf" when the file is reopened
Looking for the ~/.vimrc
I don't seem to have one, since I typically edit this file as root
yum remove and reinstall of vim
no change.
I know that there are a lot of posts regarding similar issues with vim syntax and filetype problems, but I cannot figure out how to resolve mine. My guess is that there is a mapping somewhere that says this one particular file should be recognized as a "conf", but that's all I've got. tia.
edit: to clarify, what I would like to know is how this one file got "stuck" on the "conf" syntax and filetype, whereas all of the other .conf files are "apache" syntax and filetype.
I would recommend using a modeline. Put this at the top of your file:
# vim: ft=apache
If you do not have a .vimrc file, you can create one. Keep in mind that each user has a separate .vimrc in their home folder. You can also look for the system default vimrc (without a dot) located in your vim installation folder. To find out where that is, type :echo $VIM in vim.
If you do create a new .vimrc for your user, you can set all .conf files to have apache highlighting as follows:
au BufRead,BufNewFile *.conf set filetype=apache

Compass set permissions on generated CSS files

Very simple, when Compass encounters a new SCSS file it generates a new CSS file. Can I set default permissions for these, as by default it sets them without correct permissions for browsers to read them (gives 403 forbidden errors). If there's a way I can set files to inherit the permissions of their directory that would also be acceptable, as would a way to alter permissions during the copy task in Phing.
I do not know how your development environment is set up, but I use grunt to compile my sass files. With grunt you have full control over the build process and can execute scripts after successful building (fx clear frontend caches or set file permissions if necessary).
Markus

How to unload all the plugins from vim and change VIMRUNTIME?

I have an account at my hosting providers server and I can't install my own copy of vim.
So the only personalization I can make is editing .vimrc in my account, but it won't suffice
What I'd Like to do is:
on startup I'd like to unload all the plugins and loaded stuff, and tell vim to use other folder as its' runtime.
Any idea how to aproach it?
You can start your vim with -u NONE. From the man-page:
-u {vimrc} Use the commands in the file {vimrc} for initializations.
All the other initializations are skipped. Use this to
edit a special kind of files. It can also be used to skip
all initializations by giving the name "NONE". See ":help
initialization" within vim for more details.
For changing $VIMRUNTIME at runtime, use
:let $VIMRUNTIME = "/new/path/"
To answer your question: you just need to set the runtimepath option in your .vimrc file, because your .vimrc is read before any plugins are loaded.
However, the default runtimepath value usually includes the ~/.vim folder (use :set runtimepath? to check), so you should be able to add whatever plugins you need to the ~/.vim folder. Also you can prevent many plugins from loading by adding a line such as :let g:loaded_<plugin name> = 1 to your .vimrc file. Check the help docs for each plugin to find out how to do this.